tgharold / CGP

Collectd Graph Panel
http://pommi.nethuis.nl/category/cgp/
2 stars 0 forks source link

snmp plugin fails on complex RRD filenames #3

Open tgharold opened 11 years ago

tgharold commented 11 years ago

CGP cannot graph RRD files for the snmp plugin which have complex filenames (spaces and other characters).

Sample filenames (from different devices, parent directory is always snmp):

if_octets-traffic-PORT-ID#8.rrd if_packets-packets-discards-PORT-ID#1.rrd

if_packets-packets-errors-3Com Baseline Switch 2948 Plus, Port #9.rrd if_packets-packets-errors-3Com Baseline Switch 2948 Plus, TRUNK ID 1.rrd if_packets-packets-errors-3Com Baseline Switch 2948 Plus, Trunk Member Por.rrd if_packets-packets-errors-3Com Baseline Switch 2948 Plus, VLAN ID 1.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, Port #6.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, Port #7.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, Port #8.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, Port #9.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, TRUNK ID 1.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, Trunk Member Port on Tr.rrd if_octets-traffic-3Com Baseline Switch 2948 Plus, VLAN ID 1.rrd

if_packets-packets-errors-RMON Port 19 on unit 1.rrd if_packets-packets-errors-RMON Port 20 on unit 1.rrd if_packets-packets-errors-Stack Aggregated Link 01.rrd if_packets-packets-errors-VLAN 00001.rrd if_packets-packets-multicast-Console Port.rrd if_packets-packets-multicast-RMON Port 00 on unit 1.rrd if_packets-packets-multicast-RMON Port 01 on unit 1.rrd

if_octets-traffic-GigabitEthernet1_0_8.rrd if_octets-traffic-GigabitEthernet1_0_9.rrd if_octets-traffic-NULL0.rrd if_octets-traffic-Vlan-interface1.rrd

if_packets-packets-discards-GigabitEthernet1_0_10.rrd if_packets-packets-discards-GigabitEthernet1_0_11.rrd if_packets-packets-discards-GigabitEthernet1_0_12.rrd

if_octets-traffic-br0.rrd if_octets-traffic-eth0.rrd if_octets-traffic-lo.rrd if_octets-traffic-ra0.rrd if_octets-traffic-ra1.rrd if_octets-traffic-ra2.rrd if_octets-traffic-ra3.rrd if_octets-traffic-ra4.rrd if_packets-packets-discards-br0.rrd if_packets-packets-discards-eth0.rrd if_packets-packets-discards-lo.rrd if_packets-packets-discards-ra0.rrd if_packets-packets-discards-ra1.rrd if_packets-packets-discards-ra2.rrd if_packets-packets-discards-ra3.rrd if_packets-packets-discards-ra4.rrd if_packets-packets-errors-br0.rrd if_packets-packets-errors-eth0.rrd if_packets-packets-errors-lo.rrd if_packets-packets-errors-ra0.rrd if_packets-packets-errors-ra1.rrd if_packets-packets-errors-ra2.rrd if_packets-packets-errors-ra3.rrd if_packets-packets-errors-ra4.rrd if_packets-packets-multicast-br0.rrd if_packets-packets-multicast-eth0.rrd if_packets-packets-multicast-lo.rrd if_packets-packets-multicast-ra0.rrd if_packets-packets-multicast-ra1.rrd if_packets-packets-multicast-ra2.rrd if_packets-packets-multicast-ra3.rrd if_packets-packets-multicast-ra4.rrd if_packets-packets-unicast-br0.rrd if_packets-packets-unicast-eth0.rrd if_packets-packets-unicast-lo.rrd if_packets-packets-unicast-ra0.rrd if_packets-packets-unicast-ra1.rrd if_packets-packets-unicast-ra2.rrd if_packets-packets-unicast-ra3.rrd if_packets-packets-unicast-ra4.rrd

Possibly confused by the configuration of the snmp plugin:

<Data "traffic">

The total number of octets received on the interface,

# including framing characters.
Type "if_octets"
Table true
InstancePrefix "traffic-"
Instance "IF-MIB::ifDescr"
Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"

Except that the following devices does at least graph the traffic correctly:

if_octets-traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.02,JETDIRECT,JD3.rrd if_packets-packets-discards-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.02,JETD.rrd if_packets-packets-errors-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.02,JETDIR.rrd if_packets-packets-multicast-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.02,JET.rrd if_packets-packets-unicast-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.02,JETDI.rrd

tgharold commented 11 years ago

Symptoms:

Contents of RRD directory:

if_octets-traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDIRECT,JD8.rrd if_packets-packets-discards-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETD.rrd if_packets-packets-errors-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDIR.rrd if_packets-packets-multicast-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JET.rrd if_packets-packets-unicast-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDI.rrd

The $files array in collectd_plugindata() is filled properly with the names of the 5 files. It then processes each:

$item=[snmp/if_octets-traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.19,JETDIRECT,JD3.rrd] $data=[a:1:{i:0;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:9:"if_octets";s:2:"ti";s:63:"traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.19,JETDIRECT,JD3";}}]

$item=[snmp/if_packets-packets-discards-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.19,JETD.rrd] $data=[a:2:{i:0;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:9:"if_octets";s:2:"ti";s:63:"traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.19,JETDIRECT,JD3";}i:1;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:10:"if_packets";s:2:"ti";s:63:"packets-discards-HP ETHERNET MULTI-ENVIRONMENT,ROM G.07.19,JETD";}}]

Output of the above example only displays the "traffic" graph instead of one for packets and one for traffic.

tgharold commented 11 years ago

After rewriting things to push file searches into a separate function (used by both places where we were glob()'ing for files), I'm down to figuring out that it's apparent that the snmp filenames are not being parsed correctly. Instead of seeing the sources as "rx" and "tx" for the if_octets graph, it's seeing them as:

$source=[traffic-br0-rx] $source=[traffic-br0-tx]

Where "traffic" is the SNMP plugin InstancePrefix, specifically "traffic-". The RRD filename is "if_octets-traffic-br0.rrd".

Yet in the case of a RRD file named "if_octets-traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDIRECT,JD8.rrd". It is correctly detecting the source names as rx/tx.

tgharold commented 11 years ago

Looking at the $data array returned from collectd_plugindata(), it looks correct.

$data=[a:5:{i:0;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:9:"if_octets";s:2:"ti";s:63:"traffic-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDIRECT,JD8";}i:1;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:10:"if_packets";s:2:"ti";s:63:"packets-discards-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETD";}i:2;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:10:"if_packets";s:2:"ti";s:63:"packets-errors-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDIR";}i:3;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:10:"if_packets";s:2:"ti";s:63:"packets-multicast-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JET";}i:4;a:5:{s:1:"p";s:4:"snmp";s:1:"c";s:0:"";s:2:"pi";s:0:"";s:1:"t";s:10:"if_packets";s:2:"ti";s:63:"packets-unicast-HP ETHERNET MULTI-ENVIRONMENT,ROM L.20.07,JETDI";}}]

That implies that the problem lies in rrd_get_sources().