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 +++++++++++----
layout/style.css | 11 +++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
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]);
+ }
}
}
diff --git a/layout/style.css b/layout/style.css
index a828a8d..3d5c94b 100644
--- a/layout/style.css
+++ b/layout/style.css
@@ -138,3 +138,14 @@ legend {
font-size: 1.4em;
font-weight: normal;
}
+
+.warn {
+ color: darkorange;
+ font-weight: normal;
+ text-shadow: 0 0 1px darkorange;
+}
+.crit {
+ color: red;
+ font-weight: normal;
+ text-shadow: 0 0 1px red;
+}
--
cgit v1.1