How does php obtain the current cpu usage of centos. I use $ str & nbsp; shell_exec (more & nbsp; procstat); or popen (top & nbsp;-B & nbsp;-n & nbsp; 2 & nbsp; | & nbsp; grep & nbsp;-E & nbsp; (Cpu), r); the result seems to be inaccurate. how does php obtain the current cpu usage of centos?
As the question.
I use
$ Str = shell_exec ('more/proc/stat ');
Or
Popen ('top-B-n 2 | grep-E "(Cpu)" ', "r ");
It seems that the result is not accurate. The result is 0.4% every time, but the top check on the server changes to 0.7, 1.0, 14 .....
How can I get it quickly?
Share:
------ Solution --------------------
Command for viewing CPU usage in LINUX
------ Solution --------------------
Reference:
Quote: reference:
No
Quote: reference:
The top one doesn't talk about cpu utilization.
Oh, can PHP get the real-time CPU usage percentage? Or it's the same as top, just to get data.
Does your system have sysstat installed? you can use mpstat, sar, etc.
Http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html