How does php obtain the current cpu usage of centos?

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.