summaryrefslogtreecommitdiffstats
path: root/usr/local/www/includes/functions.inc.php
diff options
context:
space:
mode:
authorphildd <ict.advisor@nepal.inf.org>2013-12-22 03:49:56 -0800
committerphildd <ict.advisor@nepal.inf.org>2013-12-22 03:49:56 -0800
commit15183bcb2b671874cf79ad0baffc8578ce9cdc90 (patch)
tree758f37860d5a583643469d73bba56d79c8207fb0 /usr/local/www/includes/functions.inc.php
parent3e5933f2c33b8d225f2f5c18aa63ed2b338ee67b (diff)
downloadpfsense-15183bcb2b671874cf79ad0baffc8578ce9cdc90.zip
pfsense-15183bcb2b671874cf79ad0baffc8578ce9cdc90.tar.gz
Avoid dashboard divide by zero errors
Diffstat (limited to 'usr/local/www/includes/functions.inc.php')
-rw-r--r--usr/local/www/includes/functions.inc.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php
index 4a8ffc8..198da00 100644
--- a/usr/local/www/includes/functions.inc.php
+++ b/usr/local/www/includes/functions.inc.php
@@ -146,7 +146,10 @@ function get_pfstate($percent=false) {
$curentries = $matches[1];
}
if ($percent)
- return round(($curentries / $maxstates) * 100, 0);
+ if ($maxstates > 0)
+ return round(($curentries / $maxstates) * 100, 0);
+ else
+ return "NA";
else
return $curentries . "/" . $maxstates;
}
@@ -166,7 +169,10 @@ function get_mbuf($percent=false) {
$mbufs_output=trim(`/usr/bin/netstat -mb | /usr/bin/grep "mbuf clusters in use" | /usr/bin/awk '{ print $1 }'`);
list( $mbufs_current, $mbufs_cache, $mbufs_total, $mbufs_max ) = explode( "/", $mbufs_output);
if ($percent)
- return round(($mbufs_total / $mbufs_max) * 100, 0);
+ if ($mbufs_max > 0)
+ return round(($mbufs_total / $mbufs_max) * 100, 0);
+ else
+ return "NA";
else
return "{$mbufs_total}/{$mbufs_max}";
}
@@ -211,7 +217,10 @@ function mem_usage() {
$totalMem = $memory[0];
$availMem = $memory[1] + $memory[2] + $memory[3];
$usedMem = $totalMem - $availMem;
- $memUsage = round(($usedMem * 100) / $totalMem, 0);
+ if ($totalMem > 0)
+ $memUsage = round(($usedMem * 100) / $totalMem, 0);
+ else
+ $memUsage = "NA";
return $memUsage;
}
OpenPOWER on IntegriCloud