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.