From c0a28c5f59822c347503c0b856000232c0ba4f42 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 6 Mar 2010 10:48:27 +0100 Subject: configuration option to show load averages on overview page --- conf/config.php | 3 +++ inc/html.inc.php | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/conf/config.php b/conf/config.php index b402b7f..d31b129 100644 --- a/conf/config.php +++ b/conf/config.php @@ -15,6 +15,9 @@ $CONFIG['rrdtool'] = '/usr/bin/rrdtool'; # default plugins to show on host page $CONFIG['overview'] = array('load', 'cpu', 'memory', 'swap'); +# show load averages on overview page +$CONFIG['showload'] = true; + # browser cache time for the graphs (in seconds) $CONFIG['cache'] = 90; diff --git a/inc/html.inc.php b/inc/html.inc.php index c524e46..a05aab6 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -67,24 +67,26 @@ function host_summary($hosts) { echo "
%s | ', $CONFIG['weburl'],$host, $host); - if (isset($rrd_info['ds[shortterm].last_ds']) && - isset($rrd_info['ds[midterm].last_ds']) && - isset($rrd_info['ds[longterm].last_ds'])) { + if ($CONFIG['showload']) { + collectd_flush(sprintf('%s/load/load', $host)); + $rrd_info = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/load/load.rrd'); + + # ignore if file does not exist + if (!$rrd_info) + continue; + + if (isset($rrd_info['ds[shortterm].last_ds']) && + isset($rrd_info['ds[midterm].last_ds']) && + isset($rrd_info['ds[longterm].last_ds'])) { - printf('%.2f | %.2f | %.2f | ', - $rrd_info['ds[shortterm].last_ds'], - $rrd_info['ds[midterm].last_ds'], - $rrd_info['ds[longterm].last_ds']); + printf('%.2f | %.2f | %.2f | ', + $rrd_info['ds[shortterm].last_ds'], + $rrd_info['ds[midterm].last_ds'], + $rrd_info['ds[longterm].last_ds']); + } } print "
---|