aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorBogdan Rădulescu2014-04-14 13:16:27 +0000
committerBogdan Rădulescu2014-04-14 13:34:05 +0000
commit425fb1db95dca3a7025ad2d7101e65f91663ec2a (patch)
tree7360f33c55b615d1ebabd0ae533622fdaf65d249
parentMerge pull request #61 from young-druid/patch-1 (diff)
downloadapt-panopticon_cgp-425fb1db95dca3a7025ad2d7101e65f91663ec2a.zip
apt-panopticon_cgp-425fb1db95dca3a7025ad2d7101e65f91663ec2a.tar.gz
apt-panopticon_cgp-425fb1db95dca3a7025ad2d7101e65f91663ec2a.tar.bz2
apt-panopticon_cgp-425fb1db95dca3a7025ad2d7101e65f91663ec2a.tar.xz
overview: show used memory percentage
-rw-r--r--conf/config.php3
-rw-r--r--inc/html.inc.php26
2 files changed, 27 insertions, 2 deletions
diff --git a/conf/config.php b/conf/config.php
index b9a5098..246d378 100644
--- a/conf/config.php
+++ b/conf/config.php
@@ -26,8 +26,9 @@ $CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap');
26$CONFIG['time_range']['default'] = 86400; 26$CONFIG['time_range']['default'] = 86400;
27$CONFIG['time_range']['uptime'] = 31536000; 27$CONFIG['time_range']['uptime'] = 31536000;
28 28
29# show load averages on overview page 29# show load averages and used memory on overview page
30$CONFIG['showload'] = true; 30$CONFIG['showload'] = true;
31$CONFIG['showmem'] = true;
31 32
32$CONFIG['term'] = array( 33$CONFIG['term'] = array(
33 '2hour' => 3600 * 2, 34 '2hour' => 3600 * 2,
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) {
219 printf('<td%s>%.2f</td>', $class, $rrd_info[$info]); 219 printf('<td%s>%.2f</td>', $class, $rrd_info[$info]);
220 } 220 }
221 } 221 }
222 } 222 }
223
224 if ($CONFIG['showmem']) {
225 $rrd_info_mu = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-used.rrd');
226 $rrd_info_mf = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-free.rrd');
227 $rrd_info_bf = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-buffered.rrd');
228 $rrd_info_ca = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/memory/memory-cached.rrd');
229
230 # ignore if file does not exist
231 if (!$rrd_info_mu || !$rrd_info_mf || !$rrd_info_bf || !$rrd_info_ca)
232 continue;
233
234 $info='ds[value].last_ds';
235 if (isset($rrd_info_mu[$info]) && isset($rrd_info_mf[$info]) && isset($rrd_info_bf[$info]) && isset($rrd_info_ca[$info]) ) {
236 $percent_mem = $rrd_info_mu[$info] * 100 / ($rrd_info_mu[$info] + $rrd_info_mf[$info] + $rrd_info_bf[$info] + $rrd_info_ca[$info]);
237
238 $class = '';
239 if ($percent_mem > 90)
240 $class = ' class="crit"';
241 elseif ($percent_mem > 70)
242 $class = ' class="warn"';
243
244 printf('<td%s>%d</td>', $class, $percent_mem);
245 }
246 }
223 247
224 print "</tr>\n"; 248 print "</tr>\n";
225 } 249 }