Community discussions

MikroTik App
 
User avatar
lwaclawiak
just joined
Topic Author
Posts: 12
Joined: Fri Sep 13, 2019 8:26 pm

Have there a way to get the value of an global variable on remote RouterOS devices with snmp?

Tue Jun 29, 2021 3:03 pm

I have some remote mikrotiks with scripts that run are triggered by the schedule and load their values ​​into environment variables, which I later get with Dude using the "ros_command" function to generate graphics and display on the labels.

Everything worked perfectly until version 6.45.9 of dude, when I upgraded to version 6.47.10, I started to experience frequent crashes of the Dude client. Looking in this forum I found that the 6.46+ versions of the dude have problems with the remote connections of RouterOs and so the last version considered stable at this point is in fact the 6.45.9.

The problem is that Dude 6.45.9 can't make RouterOs connections with mikrotik devices running versions 6.46+ of RouterOs, and I also can't downgrade to 6.45.9 on devices that left the factory with versions 6.46+.

For this reason I would like to know if it is possible to get values ​​from global variables via SNMP.
And also if it is possible to trigger the execution of remote scripts via SNMP.
Or if there is how to force a downgrade of mikrotiks devices below the factory version.
Thanks!
 
User avatar
lwaclawiak
just joined
Topic Author
Posts: 12
Joined: Fri Sep 13, 2019 8:26 pm

Re: Have there a way to get the value of an global variable on remote RouterOS devices with snmp?  [SOLVED]

Mon May 13, 2024 6:38 am

I spent a few years with this dilemma of how to query via SNMP some global variables generated by custom scripts with indicators that I would like to display in The Dude and in other monitoring systems like Zabbix.

In fact, it is possible to do this using remote execution of scripts via snmp and returning their values, but this did not really please me, as the OID for the same script on different routers could be different, as the scripts are executed by their indexes and not by their names.

This makes configuration in the monitoring system very difficult, but worse than that, a wrong configuration could simply cause another script to be executed in place of the one that only had the function of returning information, which is really very bad.

Using a fake disabled bridge to look for its name that could be changed by the script to the content of the variable was one of the ways I saw other members suggested.

This approach solves the problem of executing an inappropriate script, but does not solve the issue of the OID being different between different routers.

The solution I found that solved my problem was to use the "system note" function, which is a space where you can create a complete text with several lines and you can consult it by OID ("1.3.6.1.4.1. 14988.1.1.7.5.0").

So just create a script that brings together all the variables you want to use and writes them to the "system note", putting this script to run through the scheduler from time to time as needed.
:global LinkAtivo
:global PercentLossPrincipal
:global MPLoss
:global PercentLossBackup
:global MBLoss

system note set note="Link: $LinkAtivo
Perda Prin: $PercentLossPrincipal
Media Prin: $MPLoss
Perda Back: $PercentLossBackup
Media Back: $MBLoss"
It is possible to consult it with the read-only public community, the OID will always be the same regardless of the router, we do not run the risk of executing a script by mistake and it is possible to store a lot of information in this field.
root@Syslog:~# snmpget -v1 -cpublic 10.100.203.1 1.3.6.1.4.1.14988.1.1.7.5.0
iso.3.6.1.4.1.14988.1.1.7.5.0 = STRING: "Link: PRINCIPAL
Perda Prin: 0
Media Prin: 0
Perda Back: 0
Media Back: 0"
On the monitoring side, simply create functions to filter with regular expressions and extract only the variable you want for that specific query.

And "Voilá" we have it resolved.

Who is online

Users browsing this forum: No registered users and 0 guests