Update user_dashboard.php

Fix the CPU usage on the dashboard.
This commit is contained in:
FusionPBX
2016-05-06 01:20:57 -06:00
parent 32223dc77c
commit 170d4be4a1

View File

@@ -1049,10 +1049,15 @@
//cpu usage
if (stristr(PHP_OS, 'Linux')) {
$ps = shell_exec("/usr/bin/which top");
$sed = shell_exec("/usr/bin/which sed");
$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}' ");
$result = shell_exec('ps -A -o pcpu');
$percent_cpu = 0;
foreach (explode("\n", $result) as $value) {
if (is_numeric($value)) { $percent_cpu = $percent_cpu + $value; }
}
$result = trim(shell_exec("grep -P '^processor' /proc/cpuinfo"));
$cores = count(explode("\n", $result));
if ($percent_cpu > 1) { $percent_cpu = $percent_cpu / $cores; }
$percent_cpu = round($percent_cpu, 2);
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";