From d06c3047d77c0c08108dd19bbbbf2a62e1f0a3bf Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Wed, 15 Jun 2011 22:45:39 +0200 Subject: plugin/conntrack: collectd 5 compatibility --- plugin/conntrack.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/conntrack.php b/plugin/conntrack.php index 949d88e..2034a57 100644 --- a/plugin/conntrack.php +++ b/plugin/conntrack.php @@ -10,13 +10,12 @@ require_once 'inc/collectd.inc.php'; # conntrack/conntrack.rrd $obj = new Type_Default($CONFIG); -# the data source is named 'entropy' in collectd's types.db -$obj->data_sources = array('entropy'); +$obj->data_sources = array('value'); $obj->ds_names = array( - 'entropy' => 'Conntrack entries', + 'value' => 'Conntrack entries', ); $obj->colors = array( - 'entropy' => '0000f0', + 'value' => '0000f0', ); $obj->width = $width; $obj->heigth = $heigth; @@ -24,5 +23,19 @@ $obj->rrd_title = 'Conntrack entries'; $obj->rrd_vertical = '#'; $obj->rrd_format = '%.1lf'; +# backwards compatibility +# the data source is named 'entropy' in collectd's types.db +if ($CONFIG['version'] < 5) { + $obj->data_sources = array('entropy'); + if (count($obj->ds_names) == 1) { + $obj->ds_names['entropy'] = $obj->ds_names['value']; + unset($obj->ds_names['value']); + } + if (count($obj->colors) == 1) { + $obj->colors['entropy'] = $obj->colors['value']; + unset($obj->colors['value']); + } +} + collectd_flush($obj->identifiers); $obj->rrd_graph(); -- cgit v1.1