Created
July 10, 2015 21:29
-
-
Save gcphost/92aa9af61d919d348934 to your computer and use it in GitHub Desktop.
PHP Simple Stats, CPU, Memory, Disc and Load Usage
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 | |
$load=sys_getloadavg(); | |
$results=array( | |
'memory' => round(exec("printf \$(free -m| grep Mem | awk '{ print \$3/\$2*100 }')"),2), | |
'disc' => (100-round(disk_free_space(getcwd())/disk_total_space (getcwd()) * 100,2)), | |
'cpu' => round(exec("grep 'cpu ' /proc/stat | awk '{cpu_usage=($2+$4)*100/($2+$4+$5)} END {print cpu_usage}'"),2), | |
'load' => $load[0] | |
); | |
die(json_encode($results)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment