From 8a83bc09aac260c9b35f5ab68d6685fad44c3113 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sun, 29 Dec 2013 17:00:23 +0100 Subject: plugin/tail: collectd < 5 backwards compatibility Closes: https://github.com/pommi/CGP/issues/36 --- plugin/tail.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugin/tail.php b/plugin/tail.php index 0d3ca46..3afcc2e 100644 --- a/plugin/tail.php +++ b/plugin/tail.php @@ -12,5 +12,20 @@ $obj = new Type_Default($CONFIG); $obj->rrd_title = sprintf('tail: %s (%s)', $obj->args['pinstance'], $obj->args['type']); $obj->rrd_format = '%5.1lf%s'; +# backwards compatibility +if ($CONFIG['version'] < 5) { + if (strcmp($obj->args['type'], 'gauge') != 0) { + $obj->data_sources = array('count'); + if (count($obj->ds_names) == 1) { + $obj->ds_names['count'] = $obj->ds_names['value']; + unset($obj->ds_names['value']); + } + if (count($obj->colors) == 1) { + $obj->colors['count'] = $obj->colors['value']; + unset($obj->colors['value']); + } + } +} + collectd_flush($obj->identifiers); $obj->rrd_graph(); -- cgit v1.1