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.:

/queue simple print oid

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

name = "mtxrQueueSimpleName"
oid = "."
is_tag = true
name = "mtxrQueueSimpleBytesIn"
oid = "."
name = "mtxrQueueSimpleBytesOut"
oid = "."
name = "mtxrQueueSimplePacketsIn"
oid = "."
name = "mtxrQueueSimplePacketsOut"
oid = "."
name = "mtxrQueueSimplePCQQueuesIn"
oid = "."
name= "mtxrQueueSimplePCQQueuesOut"
oid= "."

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.