mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:21:59 +01:00
fixed a division error
This commit is contained in:
parent
731c953bd6
commit
9e868f2ccd
@ -70,8 +70,8 @@ class ModelHealthHealth extends Model {
|
||||
if(isset($a[0]) && $a[0]) { $_m[$a[0]] = $a[1]; }
|
||||
}
|
||||
|
||||
$mem_percentage = isset($_m['MemTotal:']) ? sprintf("%.2f", 100*($_m['MemTotal:'] - $_m['MemFree:'] - $_m['Cached:']) / $_m['MemTotal:']) : "0";
|
||||
$swap_percentage = isset($_m['SwapTotal:']) ? sprintf("%.2f", 100*($_m['SwapTotal:'] - $_m['SwapFree:']) / $_m['SwapTotal:']) : "0";
|
||||
$mem_percentage = isset($_m['MemTotal:']) && $_m['MemTotal:'] > 0 ? sprintf("%.2f", 100*($_m['MemTotal:'] - $_m['MemFree:'] - $_m['Cached:']) / $_m['MemTotal:']) : "0";
|
||||
$swap_percentage = isset($_m['SwapTotal:']) && $_m['SwapTotal:'] > 0 ? sprintf("%.2f", 100*($_m['SwapTotal:'] - $_m['SwapFree:']) / $_m['SwapTotal:']) : "0";
|
||||
|
||||
return array(sprintf("%.0f", @$_m['MemTotal:'] / 1000), $mem_percentage, sprintf("%.0f", @$_m['SwapTotal:'] / 1000), $swap_percentage);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user