From 821e416360e7f2ebbab8bbc598ab7234a9c70fa4 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Wed, 15 Jun 2011 22:43:42 +0200 Subject: plugin/apache: collectd 5 compatibility --- plugin/apache.php | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'plugin/apache.php') diff --git a/plugin/apache.php b/plugin/apache.php index 73fe70e..99fc689 100644 --- a/plugin/apache.php +++ b/plugin/apache.php @@ -17,48 +17,48 @@ $obj = new Type_Default($CONFIG); switch ($obj->args['type']) { case 'apache_bytes': - $obj->data_sources = array('count'); + $obj->data_sources = array('value'); $obj->ds_names = array( - 'count' => 'Bytes/s', + $obj->args['type'] => 'Bytes/s', ); $obj->colors = array( - 'count' => '0000ff', + $obj->args['type'] => '0000ff', ); $obj->rrd_title = sprintf('Webserver Traffic%s', !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); $obj->rrd_vertical = 'Bytes/s'; break; case 'apache_connections': - $obj->data_sources = array('count'); + $obj->data_sources = array('value'); $obj->ds_names = array( - 'count' => 'Conns/s', + $obj->args['type'] => 'Conns/s', ); $obj->colors = array( - 'count' => '00b000', + $obj->args['type'] => '00b000', ); $obj->rrd_title = sprintf('Webserver Connections%s', !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); $obj->rrd_vertical = 'Conns/s'; break; case 'apache_idle_workers': - $obj->data_sources = array('count'); + $obj->data_sources = array('value'); $obj->ds_names = array( - 'count' => 'Workers', + $obj->args['type'] => 'Workers', ); $obj->colors = array( - 'count' => '0000ff', + $obj->args['type'] => '0000ff', ); $obj->rrd_title = sprintf('Webserver Idle Workers%s', !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); $obj->rrd_vertical = 'Workers'; break; case 'apache_requests': - $obj->data_sources = array('count'); + $obj->data_sources = array('value'); $obj->ds_names = array( - 'count' => 'Requests/s', + $obj->args['type'] => 'Requests/s', ); $obj->colors = array( - 'count' => '00b000', + $obj->args['type'] => '00b000', ); $obj->rrd_title = sprintf('Webserver Requests%s', !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); @@ -67,7 +67,7 @@ switch ($obj->args['type']) { case 'apache_scoreboard': require_once 'type/GenericStacked.class.php'; $obj = new Type_GenericStacked($CONFIG); - $obj->data_sources = array('count'); + $obj->data_sources = array('value'); $obj->order = array( 'open', 'idle_cleanup', @@ -153,5 +153,18 @@ $obj->width = $width; $obj->heigth = $heigth; $obj->rrd_format = '%5.1lf'; +# backwards compatibility +if ($CONFIG['version'] < 5) { + $obj->data_sources = array('count'); + if (count($obj->ds_names) == 1) { + $obj->ds_names['count'] = $obj->ds_names[$obj->args['type']]; + unset($obj->ds_names[$obj->args['type']]); + } + if (count($obj->colors) == 1) { + $obj->colors['count'] = $obj->colors[$obj->args['type']]; + unset($obj->colors[$obj->args['type']]); + } +} + collectd_flush($obj->identifiers); $obj->rrd_graph(); -- cgit v1.1