Home >Backend Development >PHP Tutorial >php怎么获取centos的cpu当前使用率

php怎么获取centos的cpu当前使用率

WBOY
WBOYOriginal
2016-06-13 11:37:491382browse

php如何获取centos的cpu当前使用率
如题。

我用
$str = shell_exec('more /proc/stat');
或者
popen('top -b -n 2 | grep -E "(Cpu)"',"r");
取的好象都不准确,每次都是0.4%,但在服务器上用top查看 变化是0.7,1.0,14.....

一般如何快速获取啊

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn