From 9e868f2ccd26df199d13db394a1d0e472c4833c6 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 14 Sep 2012 11:04:43 +0200 Subject: [PATCH] fixed a division error --- webui/model/health/health.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webui/model/health/health.php b/webui/model/health/health.php index 55037c2c..d6316cb6 100644 --- a/webui/model/health/health.php +++ b/webui/model/health/health.php @@ -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); }