From 41a8b01c6dfb5e5660a7d0029338777d01019feb Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 22 Jun 2013 12:55:06 +0200 Subject: overview: add color to load averages The load average number turns: * orange When the load is higher than the number of cpu cores. * red When the load is more than twice as high as the number of cpu cores. --- inc/html.inc.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'inc/html.inc.php') diff --git a/inc/html.inc.php b/inc/html.inc.php index 0a33da5..015225e 100644 --- a/inc/html.inc.php +++ b/inc/html.inc.php @@ -173,6 +173,8 @@ function host_summary($cat, $hosts) { foreach($hosts as $host) { $host_counter++; + $cores = count(group_plugindata(collectd_plugindata($host, 'cpu'))); + printf('', $row_style[$host_counter % 2]); printf('%s', $CONFIG['weburl'],$host, $host); @@ -189,10 +191,15 @@ function host_summary($cat, $hosts) { 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']); + foreach (array('ds[shortterm].last_ds', 'ds[midterm].last_ds', 'ds[longterm].last_ds') as $info) { + $class = ''; + if ($cores > 0 && $rrd_info[$info] > $cores * 2) + $class = ' class="crit"'; + elseif ($cores > 0 && $rrd_info[$info] > $cores) + $class = ' class="warn"'; + + printf('%.2f', $class, $rrd_info[$info]); + } } } -- cgit v1.1