I setup the global variable.
> :global testvalue 100
Then I add a script to output the value of variable.
> /system script add dont-require-permissions=no name=test-result owner=madi policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
":put \$testvalue"
> /system script environment print
# NAME VALUE
2 testvalue 100
I want to get the value with monitor software by SNMP oid
snmpwalk -v 2c -c community 192.168.1.1 1.3.6.1.4.1.14988.1.1.8
SNMPv2-SMI::enterprises.14988.1.1.8.1.1.2.5 = STRING: "AliDnsploss"
SNMPv2-SMI::enterprises.14988.1.1.8.1.1.2.7 = STRING: "AliDnsavgRtt"
SNMPv2-SMI::enterprises.14988.1.1.8.1.1.3.5 = INTEGER: 0
SNMPv2-SMI::enterprises.14988.1.1.8.1.1.3.7 = INTEGER: 0
But there is no any value for variable .
From wiki , I found that
----------------------------------------------------------------------------
https://wiki.mikrotik.com/wiki/Manual:SNMP
Runing scripts with GET
It is possible to run /system scripts via SNMP GET request of the script OID (since 6.37). For this to work SNMP community with write permission is required. OIDs for scripts can be retrieved via SNMPWALK command as the table is dynamic.
Add script:
/system script
add name=script1 owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
"/sy reboot "
add name=script2 owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\
"[:put output]"
Get the script OID table
$ snmpwalk -v2c -cpublic 192.168.88.1 1.3.6.1.4.1.14988.1.1.8
iso.3.6.1.4.1.14988.1.1.8.1.1.2.1 = STRING: "script1"
iso.3.6.1.4.1.14988.1.1.8.1.1.2.2 = STRING: "script2"
iso.3.6.1.4.1.14988.1.1.8.1.1.3.1 = INTEGER: 0
iso.3.6.1.4.1.14988.1.1.8.1.1.3.2 = INTEGER: 0
To run script use table 18
$ snmpget -v2c -cpublic 192.168.88.1 1.3.6.1.4.1.14988.1.1.18.1.1.2.2
iso.3.6.1.4.1.14988.1.1.18.1.1.2.2 = STRING: "output"
--------------------------------------------------------------------------------------------------
When I snmpwalk the device , I can't find the SNMP oid 1.3.6.1.4.1.14988.1.1.18.1.1.2.2
snmpget -v 2c -c community 192.168.1.1 1.3.6.1.4.1.14988.1.1.18
SNMPv2-SMI::enterprises.14988.1.1.18 = No Such Object available on this agent at this OID
snmpget -v 2c -c community 192.168.1.1 1.3.6.1.4.1.14988.1.1.18.1.1.2.2
SNMPv2-SMI::enterprises.14988.1.1.18 = No Such Object available on this agent at this OID
Why I can't get the value of variable ?
The SNMP oid 1.3.6.1.4.1.14988.1.1.18 is correct ?