0

I am trying to use a Raspberry Pi to poll the interface MIB (IF:MIB) of a TP-LINK router and then send the metrics to Librato. Setting up collectd and integrating it with Librato is no problem at all - I am successfully tracking other metrics (cpu, memory, etc.). The challenge I have is with the collectd-snmp plugin configuration.

I installed net-snmp and can "see" the router:

pi@raspberrypi ~ $ snmpwalk -v 1 -c public 192.168.0.1 IF-MIB::ifInOctets
IF-MIB::ifInOctets.2 = Counter32: 1206812646
IF-MIB::ifInOctets.3 = Counter32: 1548296842
IF-MIB::ifInOctets.5 = Counter32: 19701783
IF-MIB::ifInOctets.10 = Counter32: 0
IF-MIB::ifInOctets.11 = Counter32: 0
IF-MIB::ifInOctets.15 = Counter32: 0
IF-MIB::ifInOctets.16 = Counter32: 0
IF-MIB::ifInOctets.22 = Counter32: 0
IF-MIB::ifInOctets.23 = Counter32: 0

The Pi is on 192.168.0.20, the router on 192.168.0.1. My collectd.conf is as follows:

<Plugin snmp>
  <Data "ifmib_if_octets32">
    Type "if_octets"
    Table true
    Instance "IF-MIB::ifDescr"
    Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
  </Data>
  <Host "localhost">
    Address "192.168.0.1"
    Version 1
    Community "public"
    Collect "ifmib_if_octets32"
    Interval 60
  </Host>
</Plugin>

When I restart collectd I get the following error:

pi@raspberrypi ~ $ sudo service collectd restart
[....] Restarting statistics collection and monitoring daemon: collectdNo log handling enabled - turning on stderr logging
MIB search path: $HOME/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (IF-MIB): At line 0 in (none)
[2015-01-24 23:01:31] snmp plugin: read_objid (IF-MIB::ifDescr) failed.
[2015-01-24 23:01:31] snmp plugin: No such data configured: `ifmib_if_octets32'
No log handling enabled - turning on stderr logging
MIB search path: $HOME/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (IF-MIB): At line 0 in (none)
[2015-01-24 23:01:33] snmp plugin: read_objid (IF-MIB::ifDescr) failed.
[2015-01-24 23:01:33] snmp plugin: No such data configured: `ifmib_if_octets32'
. ok

It obviously can't find the MIB, it doesn't even seem to be looking at the router's IP. Any suggestions on how to configure this correctly?

Nik
  • 39
  • 1
  • 6

1 Answers1

0

I figured it out:

<Plugin snmp>
  <Data "if_Octets">
    Type "if_octets"
    Table true
    Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets"
  </Data>
  <Host "tp-link">
    Address "192.168.0.1"
    Version 1
    Community "public"
    Collect "if_Octets"
    Interval 60
  </Host>
</Plugin>
Nik
  • 39
  • 1
  • 6
  • @Bruno9779 care to elaborate? I have no idea what I'm doing here - what's the correct way? – Nik Sep 01 '15 at 18:45
  • OID numbers are not human readable; that is what SNMP MIB files are for. This is a workaround, because instead of solving the MIB file loading issue, you avoid using MIBs altogether. I think collectd depends on the mibs included in snmpd.conf. I'll try it out and write an answer – Bruno9779 Sep 04 '15 at 20:00
  • The solution is actually quite simple - I followed the Manpage example to the letter and used the OID prefix of all the values to query, so IF-MIB::ifInOctets and IF-MIB::ifOutOctets. – Nik Oct 02 '15 at 05:00
  • 1
    What is the difference between this and the original? Save me scrolling up and down, scrolling up and down, trying to work it out... – Lightness Races in Orbit Jan 04 '20 at 22:04