Mikrotik SNMP via Telegraf

As I moved most of my home to Grafana/InfluxDB monitoring, I got two challenges to deal with. One was monitoring my XigmaNAS servers and the other was properly handling Mikrotik routers. I’ll come back to XigmaNAS in one of later posts but today let’s see what can be done for Miktorik.

Well, Miktorik is a router and essentially all routers are meant to be monitored over SNMP. So, the first step is going to be turning it on from within System/SNMP. You want it read-only and you want to customize community string. You might also want SHA1/AES authentication/encryption but that has to be configured on both sides and I generally skip it for my home network.

Once you’re done you can turn on SNMP input plugin and data will flow. But data that flows will not include Mikrotik-specific stuff. Most notably, I wanted simple queues. And, once you know the process, it’s actually reasonably easy.

At heart of SNMP we have OIDs. Mikrotik is really shitty with documenting them but they do provide MIB so one can take a look. However, there is an easier approach. Just run print oid for any section, e.g.:

Terminal
/queue simple print oid
0
name=.1.3.6.1.4.1.14988.1.1.2.1.1.2.1
bytes-in=.1.3.6.1.4.1.14988.1.1.2.1.1.8.1
bytes-out=.1.3.6.1.4.1.14988.1.1.2.1.1.9.1
packets-in=.1.3.6.1.4.1.14988.1.1.2.1.1.10.1
packets-out=.1.3.6.1.4.1.14988.1.1.2.1.1.11.1
queues-in=.1.3.6.1.4.1.14988.1.1.2.1.1.12.1
queues-out=.1.3.6.1.4.1.14988.1.1.2.1.1.13.1

This can than be converted into telegraf format looking something like this:

telegraf.conf
[[inputs.snmp.table.field]]
name = "mtxrQueueSimpleName"
oid = ".1.3.6.1.4.1.14988.1.1.2.1.1.2"
is_tag = true
[[inputs.snmp.table.field]]
name = "mtxrQueueSimpleBytesIn"
oid = ".1.3.6.1.4.1.14988.1.1.2.1.1.8"
[[inputs.snmp.table.field]]
name = "mtxrQueueSimpleBytesOut"
oid = ".1.3.6.1.4.1.14988.1.1.2.1.1.9"
[[inputs.snmp.table.field]]
name = "mtxrQueueSimplePacketsIn"
oid = ".1.3.6.1.4.1.14988.1.1.2.1.1.10"
[[inputs.snmp.table.field]]
name = "mtxrQueueSimplePacketsOut"
oid = ".1.3.6.1.4.1.14988.1.1.2.1.1.11"
[[inputs.snmp.table.field]]
name = "mtxrQueueSimplePCQQueuesIn"
oid = ".1.3.6.1.4.1.14988.1.1.2.1.1.12"
[[inputs.snmp.table.field]]
name= "mtxrQueueSimplePCQQueuesOut"
oid= ".1.3.6.1.4.1.14988.1.1.2.1.1.13"

Where did I get the name from? Technically, you can use whatever you want, but I usually look them up from oid-info.com. Once you restart telegraf daemon, data will flow into Grafana and you can chart it to your heart’s desire.

You can see my full SNMP input config for Mikrotik at GitHub.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.