Skip to content

Instantly share code, notes, and snippets.

@jagad89
Created April 24, 2023 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagad89/f56fd941e6e83c7cb0a8c0cbe67b3f03 to your computer and use it in GitHub Desktop.
Save jagad89/f56fd941e6e83c7cb0a8c0cbe67b3f03 to your computer and use it in GitHub Desktop.
finding percentage cpu utilization and top 10 processes
<?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