Reading SNMP values from Mikrotik RouterOS into Mango Automation

If you use Mikrotik routerboard devices in your networking environment or for remote telemetry applications, you may be interested in retrieving some datapoints from the Routerboard using Mango’s SNMP datasource module.

In this example, I am going to monitor the up/down state of an interface, as well as the DC supply voltage to the routerboard – but of course you can monitor many more things using SNMP, such as interface traffic, temperature, even the number of wireless clients.

Pulling data points like these into Mango makes it possible to do a variety of interesting things. For example, I’m currently hacking together a Mango-based project that will alert me if the front door of my house is left open (via magnetic reed switch), which is a recurring problem. To figure out if anyone’s actually home, Mango will also retrieve the number of connected wireless clients from my home’s wireless access point. When the door is open, but no clients are active (with a bit of additional logic to prevent false alarms) Mango generates an email alert.

..Hey! If you liked this post, you might be interested in these posts too:

First, lets monitor the interface up/down state (running or not running, in RouterOS terminology).

To obtain the relevant SNMP OIDs, you will need to log into your device’s console to access the CLI, and then run the command that to show you the interface table:

The output will look something like this:

Make a note of the interface number that you wish to monitor (interface number 0 in my case, for the interface ether1), and now here’s the trick: Run the command again, specifying the additional option oid:

By quickly comparing this data to the previous, we know that that the SNMP value for interface up/down is called ‘admin-status’, and the SNMP OID for admin-status of interface 0 is ., so now lets create the data source in Mango.

Create a data source of type ‘SNMP’, with the IP address/hostname of your Routerboard device (by the way, all my SNMP traffic here is over a VPN, so for simplicity’s sake I usually leave community set to public – you may not want to):

Screen Shot 2014-12-12 at 10.54.19 am

Now, use the module’s test mode to test the SNMP OID that we found:

Screen Recording 2014-12-12 at 10.56 am

Now we can see that a value of ‘1’ corresponds to ‘running‘. If we test an interface that we know is down/disabled, we can see that the value for down/disabled is ‘2’, so now we have everything we need to create the point.
Here’s how I set mine up:

Screen Shot 2014-12-12 at 10.58.26 am

I used the text renderer options to render it as coloured text:

Screen Shot 2014-12-12 at 10.58.42 am

And here’s how that will look in a Watch List:

Screen Shot 2014-12-12 at 11.00.44 am

That was a convoluted example. Here’s a simpler demonstration:

. is therefore the OID for supply voltage. Test the OID as before and you’ll see it returns an integer.
Here’s how I set my point up, but you can choose different logging/alarming settings:

Screen Shot 2014-12-12 at 11.06.22 am

There are a lot more possibilities using SNMP and RouterOS, especially when you consider Mango Automation’s ability to perform actions based on the conditions of multiple data sources. You could change an HVAC air conditioner’s setpoint based on the temperature of your router, for example (not that you would – but you could). You can even reboot the router and run predefined scripts on it.

Having those extra data-point can be handy in a lot of troubleshooting scenarios, as since it requires no additional hardware, it’s “free”.

Here’s a chart showing CPU temperatures from a router and a protection relay, both in the same enclosure. Even though we’re recording CPU temperatures, I can now get a good idea of the baseline and the average internal ambient temperature for that enclosure (when the relay’s CPU goes hot but the Routerboard’s does not, I know the internal ambient temperature did not increase, and the temperature rise was localised to that relay).


For more information on SNMP in RouterOS, see here:

I hope someone has found this useful. If you did, please post a reply!

Previous Post

ISP congestion monitoring with Raspberry Pi

The ISP I use at home is suffering from pretty bad congestion and the service has become barely usable during peak times. Despite multiple reports from other customers, they won't admit that ... Read more

Next Post

Prius Panel Repairs

Oops. Prius v. concrete pole.

Leave a Comment