You can do
/ip firewall connection print count-only
To get only a count. With the new “run script via snmp” feature it should be possible to read that over snmp.
When you succeed in doing that, please show us how. (there is little documentation about this)
If you want to read variable from the script, make it global and read it’s value from /system script environment. I haven’t tried it in your scenario, but it might work since that way variable is always accessible and there is a chance it will have functional OID.
Indeed! I also found those OID in the MIB and tried similar things as you did but never was able to
run a script from SNMP to receive the output value. It would be a useful feature but I would have
preferred a separate table for OID->script mapping and enabling execution of the script instead of
the vague “write permission” that is apparently used now.
Run the script with the read-only community is not entirely correct from a security standpoint. Who knows what scripts do you have on the equipment, run some risk to the network.
Therefore, I agree with the use of the Write rights.
That is why I would have preferred to have an explicit OID->script table so you explicitly open the execution of scripts on reading certain OIDs (that you define yourself)
and you can control which scripts are accessible this way.
When a rights bit is used it should have been an explicit one (SNMP). That still leaves the nasty problem that you cannot predict the OID and keep it the same on a number of routers.
Ok that is reasonably simple.
I still would have preferred when the OID (at least the last number) is settable in some screen and
the scripts would only be runnable when in that table.
Now you have given the script all access and probably people often do that, and it means that now
their scripts can be run by anyone knowing the read-only SNMP community. (usually public)
Ah that is why it failed to work here… I experimented but never got the above result.
Well, that is not good either! It should be possible to read from the read-only community and
still execute a (trusted) script to provide the value. E.g. to graph some values using standard
monitoring software that reads all variables using the same community.