From b5f789c1cc37ee317164b3a629f1ee93199dd22a Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Wed, 5 Sep 2012 16:41:17 +0200 Subject: plugin/snmp: add support for if_octets The types used in the SNMP plugin aren't user defined, but defined in types.db. Because of the assumption that they were user defined, the patch supplied by Neptune Ning wasn't accepted. His patch has now been merged with this commit. A little fallback has been added to catch types that aren't defined in our code yet. Reference: https://github.com/pommi/CGP/pull/1 Contributed-by: Neptune Ning (Plan) --- plugin/snmp.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'plugin') diff --git a/plugin/snmp.php b/plugin/snmp.php index 8f3260d..476f4ed 100644 --- a/plugin/snmp.php +++ b/plugin/snmp.php @@ -7,12 +7,30 @@ require_once 'type/Default.class.php'; require_once 'inc/collectd.inc.php'; -$obj = new Type_Default($CONFIG); -$obj->width = $width; -$obj->heigth = $heigth; +switch(GET('t')) { + case 'if_octets': + $obj->data_sources = array('rx', 'tx'); + $obj->ds_names = array( + 'rx' => 'Receive', + 'tx' => 'Transmit', + ); + $obj->colors = array( + 'rx' => '0000ff', + 'tx' => '00b000', + ); + $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['network_datasize'])); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; + break; + default: + $obj = new Type_Default($CONFIG); + $obj->rrd_title = sprintf('SNMP: %s (%s)', $obj->args['type'], $obj->args['tinstance']); + return; +} -$obj->rrd_title = sprintf('SNMP: %s (%s)', $obj->args['type'], $obj->args['tinstance']); $obj->rrd_format = '%5.1lf%s'; +$obj->width = $width; +$obj->heigth = $heigth; collectd_flush($obj->identifiers); $obj->rrd_graph(); -- cgit v1.1