From c8513a22ba223a26f65d4d73adc792b360719746 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 1 Aug 2010 15:58:25 +0000 Subject: [PATCH] collectd improvements git-svn-id: http://www.observium.org/svn/observer/trunk@1602 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/collectd/functions.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/html/includes/collectd/functions.php b/html/includes/collectd/functions.php index 095556b71d..98ed3b2e66 100644 --- a/html/includes/collectd/functions.php +++ b/html/includes/collectd/functions.php @@ -501,6 +501,18 @@ function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null, else if ($v['cf'] == 'MIN') $has_min = true; } + + ### Build legend. This may not work for all RRDs, i don't know :) + if ($has_avg) + $graph[] = "COMMENT: Last"; + if ($has_min) + $graph[] = "COMMENT: Min"; + if ($has_max) + $graph[] = "COMMENT: Max"; + if ($has_avg) + $graph[] = "COMMENT: Avg\\n"; + + reset($rrdinfo['DS']); while (list($k, $v) = each($rrdinfo['DS'])) { if (strlen($k) > $l_max) @@ -529,13 +541,13 @@ function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null, if (isset($opts['tinylegend']) && $opts['tinylegend']) continue; if ($has_avg) - $graph[] = sprintf('GPRINT:%s_avg:AVERAGE:%%5.1lf%%s Avg%s', $k, $has_max || $has_min || $has_avg ? ',' : "\\l"); + $graph[] = sprintf('GPRINT:%s_avg:AVERAGE:%%5.1lf%%s', $k, $has_max || $has_min || $has_avg ? ',' : "\\l"); if ($has_min) - $graph[] = sprintf('GPRINT:%s_min:MIN:%%5.1lf%%s Max%s', $k, $has_max || $has_avg ? ',' : "\\l"); + $graph[] = sprintf('GPRINT:%s_min:MIN:%%5.1lf%%s', $k, $has_max || $has_avg ? ',' : "\\l"); if ($has_max) - $graph[] = sprintf('GPRINT:%s_max:MAX:%%5.1lf%%s Max%s', $k, $has_avg ? ',' : "\\l"); + $graph[] = sprintf('GPRINT:%s_max:MAX:%%5.1lf%%s', $k, $has_avg ? ',' : "\\l"); if ($has_avg) - $graph[] = sprintf('GPRINT:%s_avg:LAST:%%5.1lf%%s Last\\l', $k); + $graph[] = sprintf('GPRINT:%s_avg:LAST:%%5.1lf%%s\\l', $k); } #$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds'], '-t', $rrdfile);