/system/health is kinda weird in how it works, since the values like temp are just plain list items… So the simple “get temperature” isn’t going to work…
You can just use a :do {} on-error={} to prevent errors (like temperature not being found):
The key part to understand is “/system/health get temperature” does not work, as all the health values are not indexed by name=… so the specific entry must be found using [find] to get the .id for temperature item (or a [print as-value] and iterating over the list-type array to locate the temperature item could also work, but that more code if it’s just temp)
Another approach is enabling SNMP on the router. Then you can use oid() to read the read the temperature (or voltage) since those are the Mikrotik SNMP MIB. The MIB changes way less than scripting commands. The Dude will also show more stats on each device if SNMP is enabled on router.
If you just need temp, the ros_command() is way to go.
I was just thinking if you’re repeating this for voltage, CPU, etc. etc., the built-in SNMP probes will track all that.
Enabling SNMP would use some resources, I don’t know if it significant in most cases. Certainly on low-memory/CPU devices, running less stuff is always better. While some cost to parsing RouterOS commands too, I do imagine that be more efficient.
Now enabling SNMP, with Dude default settings, will cause more probes to be created when adding devices (like CPU/memory/disk), that would use more “resources” - but those could be disabled if unused.
More food for thought, since all the SNMP is built-in.
You need to make sure the SNMP profile in Dude aligns with the settings (v2, community, etc) in RouterOS SNMP, and the right Dude SNMP profile is assigned to a Device… but that about only tricky part.
Once enable it, go to the router Device’s properties, and under Service tab, hit “Discover”. Dude will automatically add CPU and mem “probes” to track them. And…you’d could see if CPU usage was high if SNMP was enabled (or perhaps something else, why monitoring is helpful).