Currently /tool snmp-get does not allow you to store the output to variables i.e.
:global test [/tool snmp-get 127.0.0.1 oid=.1.3.6.1.4.1.14988.1.1.4.4.0]
:put $test
the ‘test’ variable is blank
I need to be able to store OID values for use in scripts
My primary use case at the moment is to poll radio links for EIRP/SNR/MCS and if values drop below a threshold I can force OSPF/BGP changes to reroute traffic
Links can still be up but perform very bad due to being knocked out of alignment, rain fade, new obstruction etc. If the link is very poor but still up it causes congestion, packet loss, poor performance etc. I want that link to be considered down entirely without relying on hold timers as they tell me nothing about the link performance
This seems like something very simple to implement and would be extremely useful, as many MikroTik customers use a lot of wireless gear
I discovered it a few years ago too but never complained, I should have.
I’ve worked around it like this:
:do {
:execute script={/tool snmp-get x oid=1.2.3.4.5 community=public} file=fetch1.txt
/delay 5
:local blah [/file get fetch1.txt contents]
:put $blah
}
It isn’t great because :execute is async so we need to have a delay/notify method and $blah requires parsing. It does work though and I’ve been doing it for years.
Thanks. That will help and i’ll give it a try later (mods can we get that put into the Wiki page for Tools/SNMP and scripts?)
I don’t like doing it by that method though because as you say it relies on delay. It’s also causing writes on the flash memory
For my purpose I need it to run very often, every second (and maybe even multiple times in the same script with delays so it runs every 100ms) to be ready to failover very rapidly
This wouldn’t work if commands aren’t run sequentially, and would kill the flash memory quickly
I hope a MikroTik rep sees this and puts it on the drawing board. Would help a lot with the ability to read data off other devices
Our primary use case is pre-emptive route failover but I can think of a lot of other use cases i.e. emailing to alert of high temperature of devices that don’t support their own alerting or email. Or just not having to enter email details in 100 devices…
"Small’ monitoring networks so we don’t have to occupy licences and set them up on our primary monitoring platform etc
But you can use the Dude to run scripts that use SNMP…might especially for the use case described above to switch network configuration based on some SNMP GET result. The needed Dude server is supported by even some lower cost routers like the hEX S. Not always ideal, but we use the Dude for these things, the added visualization of the SNMP-based data is worth the extra package required IMO.
Yes, indeed the Dude is a viable solution. But I would only need SNMP-GET for a few minor things and thus installing something as robust as the Dude would be overkill in my case. I’m still hoping the devs will give this function a fix up.
Because this feature doesn’t work, it doesn’t get used, people don’t even think of it
But if it was implemented, there’s A LOT of potential power that can be leveraged with a simple MikroTik router
I know i’d be writing monitoring templates then just chucking mAP Lite’s everywhere to handle a lot of the ‘per-site’ monitoring that doesn’t need to be in big monitoring platforms, where it just isn’t viable (especially when you pay per sensor/device) or its overkill. Have the mAP send email alerts about a lot of things that I don’t feel are important enough to deploy across all sites, and are too much work to implement on their own (i.e. setting up routing to all devices behind NAT on an overlapping IP segment) but are super handy to have.
Like setting up temperature or fan speed alerts for all the Camera’s/Switches that the security company manage and charge them a monthly fee for it. It emails them as well as us. This would be an example of a ‘per-site’ setup thats just too complicated, fiddly and messy to setup on a company-wide monitoring platform that shares all our devices. It’s complicated enough without having to add 100x small site monitoring setups. Yet would be easy enough to setup on a mAP and with some email scripts and simply plug it in somewhere in the network
Or a customer calls up and complains about slow internet performance from their server. Can easily monitor CPU, Memory, ping times, port throughput etc of all devices and do up a bit of a report to find where the problem is. I don’t want to involve ‘customer equipment’ in our main monitoring systems but happy to do this as a once off by deploying a little mikrotik built with templates, then just take it out again later. Don’t need to get server admin access or install anything on their PC’s. It’s more time and cost effective