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
SNMP. You want it read-only and you want to customize
community string. You might also want
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 = ".22.214.171.124.4.1.149126.96.36.199.1.1.2"
is_tag = true
name = "mtxrQueueSimpleBytesIn"
oid = ".188.8.131.52.4.1.149184.108.40.206.1.1.8"
name = "mtxrQueueSimpleBytesOut"
oid = ".220.127.116.11.4.1.14918.104.22.168.1.1.9"
name = "mtxrQueueSimplePacketsIn"
oid = ".22.214.171.124.4.1.149126.96.36.199.1.1.10"
name = "mtxrQueueSimplePacketsOut"
oid = ".188.8.131.52.4.1.149184.108.40.206.1.1.11"
name = "mtxrQueueSimplePCQQueuesIn"
oid = ".220.127.116.11.4.1.14918.104.22.168.1.1.12"
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.