help: (7.15+) ros_command function and Logs entries

hello everybody!

well… v7.15 have this changelog:
*) console - added log for script execution failures;

and I have this function on dude, that keep showing logs errors on rb that havent the temperature data.

if(ros_command(“:put [/system health get temperature]”)>0,“have”,“havent”)

The question is: There is any workaround to “test” without print error?
obs: the function is placed on setting/apperance of map, 20rb)

/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):

:do { :put [/system/health/get [find name=temperature] value] } on-error={:put "0"}

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)

very thanks!
final result:

concatenate(
   if(ros_command(":do { :put [/system health get [find name=board-temperature1] value] } on-error={:put \"0\"}")>0,
     concatenate("RB Temp: ",round(ros_command(":do { :put [/system health get [find name=board-temperature1] value] } on-error={:put \"\"}")),"°C
"),
     ""
   ),
   if(ros_command(":do { :put [/system health get value-name=temperature] } on-error={:put \"0\"}")>0,
     concatenate("RB Temp: ",round(ros_command(":do { :put [/system health get value-name=temperature] } on-error={:put \"0\"}")),"°C
"), 
     ""
   )
)

I accept adjustements, for now, working perfectly!

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.

I don’t remember where I read, but SNMP uses more resources (CPU, MEMORY, etc. ) than ros_command.
Sorry if I’m wrong.

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.

Great! very thanks!
Unhappily i really need monitor more items, so i’m going to use SNMP.
Well… one more thing learned! again… very thanks!

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).