Including EdgeRouter interface throughput in netdata using snmp

Having recently set up netdata at home just to have some stats/performance dashboards for my home servers, I wanted to dig in a little and see if I could collect throughput for my EdgeRouter interfaces. It’s should be possible with the SNMP collector so let’s see!

Enable & Configure SNMP on the EdgeRouter

First we need to configure SNMP on the EdgeRouter, which is pretty easy, thanks to some first-rate instructions from Manito Networks. For the collector to read the data, it needs a "community" string, which is a password of sorts. We’ll also tell it to listen on a LAN address.

set service snmp location "Queens, USA" set service snmp description "Home EdgeRouter-4" set service snmp contact "support@73k.us" set service snmp community homelan set service snmp community homelan authorization ro set service snmp listen-address 10.47.42.1

Understanding SNMP OIDs (just a little)

Now, SNMP data is organized behind a dotted numeric address space sort of like IPs; the address of a piece of data is an OID. To set up the netdata config, we need to find the OIDs for what we want, so it knows what to poll.

The netdata docs have some information on "finding OIDs" that starts us with an snmpwalk command … but that’ll give you a giant list.

How do you know what you need? For the network info we want, there are standard OIDs. I found both the Net-SNMP finterfaces MIP page and this other OID reference helpful.

Identifying the interface SNMP OIDs we want

Interface information is under .1.3.6.1.2.1.2, and of interest is the interface table we get at .1.3.6.1.2.1.2.2.1, which we can snmpwalk like so:

snmpwalk -t 20 -v 1 -O fn -c homelan 10.47.42.1 .1.3.6.1.2.1.2.2.1

But we don’t want all its data. How to identify the data we want?

The next level down represents numbered columns of the table, to which we can append a row id to get the row we want: .1.3.6.1.2.1.2.2.1.col.row — here’s 3 examples:

.1.3.6.1.2.1.2.2.1.1.1: column 1, row 1
column 1 just contains the index numbers of the table rows, so it’s a little redundant (e.g., row 1 should be 1, row 2 should be 2, and so on)
.1.3.6.1.2.1.2.2.1.2.3: column 2, row 3
column 2 contains the interface name/description string (e.g. on mine, row 1 is "lo", row 2 is "eth3", etc.) I’m after eth0 which for me happens to be row 3, so: .1.3.6.1.2.1.2.2.1.2.3
.1.3.6.1.2.1.2.2.1.6.5: column 6, row 5
column 6 contains interface MAC address (e.g. for row 1, the lo interface, it’s empty, but for my row 5 in this example, it’s Hex-STRING: E0 63 DA 21 CA 7C)

You can see how varying the last two numbers identifies a cell in the table by column & row, so you just have to figure out what cells you want and their col/row nums, and you can build your addresses.

So I’m interested in the tx/rx for eth0, but we can’t get tx/rx raw from snmp. Luckily, netdata can do the math, but then, what do we need to connect everything up?

Of all the options, we want ifInOctents/ifOutOctets — or, columns 10 and 16 — so for my eth0 I want .1.3.6.1.2.1.2.2.1.10.3 and .1.3.6.1.2.1.2.2.1.16.3

Huzzah!

Example netdata snmp config for my EdgeRouter eth0

Now we can configure our netdata node.d/snmp.conf like so:

{ "enable_autodetect": false, "update_every": 2, "max_request_size": 100, "servers": [ { "hostname": "10.47.42.1", "community": "homelan", "update_every": 2, "max_request_size": 50, "options": { "timeout": 10000 }, "charts": { "snmp_router.bandwidth_eth0": { "title": "Router Bandwidth for eth0", "units": "kilobits/s", "type": "area", "priority": 1, "family": "ports", "dimensions": { "in": { "oid": "1.3.6.1.2.1.2.2.1.10.3", "algorithm": "incremental", "multiplier": 8, "divisor": 1024, "offset": 0 }, "out": { "oid": "1.3.6.1.2.1.2.2.1.16.3", "algorithm": "incremental", "multiplier": -8, "divisor": 1024, "offset": 0 } } } } } ] }

…and systemctl restart netdata