Skip to content

Commit

Permalink
Merge pull request #47 from ThomasKaiser/patch-1
Browse files Browse the repository at this point in the history
Do not consider %iowait when calculating CPU utilization
  • Loading branch information
votdev committed Dec 9, 2017
2 parents 5813c8d + c47832e commit 538caf7
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class System {
$tnowTotal = array_sum($tnow);
// Calculate the CPU usage since we last checked.
$diffIdle = $tnow[3] - $tprev[3];
$diffIowait = $tnow[4] - $tprev[4];
$diffTotal = $tnowTotal - $tprevTotal;
// Get the processor name.
// Parse output:
Expand All @@ -353,7 +354,7 @@ class System {
"modelname" => $modelName,
"cpumhz" => $cpuInfo->exists("cpumhz") ?
$cpuInfo->get("cpumhz") : gettext("n/a"),
"usage" => (0 == $diffTotal) ? 0 : (($diffTotal - $diffIdle) /
"usage" => (0 == $diffTotal) ? 0 : (($diffTotal - $diffIowait - $diffIdle) /
$diffTotal) * 100
];
}
Expand Down

0 comments on commit 538caf7

Please sign in to comment.