Update user_dashboard.php

Use a different approach to get the CPU usage.
This commit is contained in:
FusionPBX
2016-05-05 22:52:30 -06:00
parent 7a1d650359
commit 32223dc77c

View File

@@ -1049,13 +1049,10 @@
//cpu usage
if (stristr(PHP_OS, 'Linux')) {
$ps = shell_exec("/usr/bin/which ps");
$ps = shell_exec("/usr/bin/which top");
$sed = shell_exec("/usr/bin/which sed");
$tmp = shell_exec($ps." -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | ".$sed." '/^ 0.0 /d'");
$tmp = explode("\n", $tmp);
$tmp = preg_replace('!\s+!', ' ', $tmp[1]); // multiple > single space
$tmp = explode(' ', trim($tmp));
$percent_cpu = $tmp[0];
$awk = shell_exec("/usr/bin/which awk");
$percent_cpu = shell_exec($top." -bn1 | grep 'Cpu(s)' | ".$sed." 's/.*, *\([0-9.]*\)%* id.*/\1/' | ".$awk." '{print 100 - $1}' ");
if ($percent_cpu != '') {
$hud[$n]['html'] .= "<tr class='tr_link_void'>\n";
$hud[$n]['html'] .= "<td valign='top' class='".$row_style[$c]." hud_text'>".$text['label-processor_usage']."</td>\n";