Created
April 24, 2023 11:19
-
-
Save jagad89/f56fd941e6e83c7cb0a8c0cbe67b3f03 to your computer and use it in GitHub Desktop.
finding percentage cpu utilization and top 10 processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ideal = exec('echo ""$(vmstat 1 2|tail -1|awk \'{print $15}\')""'); | |
$cpu = 100 - $ideal; | |
echo $cpu; | |
exec('ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10',$top); | |
echo '<pre>'.json_encode($top); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment