From 425fb1db95dca3a7025ad2d7101e65f91663ec2a Mon Sep 17 00:00:00 2001
From: Bogdan Rădulescu
Date: Mon, 14 Apr 2014 13:16:27 +0000
Subject: overview: show used memory percentage
---
inc/html.inc.php | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
(limited to 'inc')
diff --git a/inc/html.inc.php b/inc/html.inc.php
index b4d295a..c657f86 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -219,7 +219,31 @@ function host_summary($cat, $hosts) {
printf('
%.2f | ', $class, $rrd_info[$info]);
}
}
- }
+ }
+
+ if ($CONFIG['showmem']) {
+ $rrd_info_mu = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-used.rrd');
+ $rrd_info_mf = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-free.rrd');
+ $rrd_info_bf = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-buffered.rrd');
+ $rrd_info_ca = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-cached.rrd');
+
+ # ignore if file does not exist
+ if (!$rrd_info_mu || !$rrd_info_mf || !$rrd_info_bf || !$rrd_info_ca)
+ continue;
+
+ $info='ds[value].last_ds';
+ if (isset($rrd_info_mu[$info]) && isset($rrd_info_mf[$info]) && isset($rrd_info_bf[$info]) && isset($rrd_info_ca[$info]) ) {
+ $percent_mem = $rrd_info_mu[$info] * 100 / ($rrd_info_mu[$info] + $rrd_info_mf[$info] + $rrd_info_bf[$info] + $rrd_info_ca[$info]);
+
+ $class = '';
+ if ($percent_mem > 90)
+ $class = ' class="crit"';
+ elseif ($percent_mem > 70)
+ $class = ' class="warn"';
+
+ printf('%d | ', $class, $percent_mem);
+ }
+ }
print "\n";
}
--
cgit v1.1