How does php obtain the current cpu usage of centos.
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?
Reply to discussion (solution)
The top one doesn't talk about cpu utilization.
No
The top one doesn't talk about cpu utilization.
No
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.
Command for viewing CPU usage in LINUX
No
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