Community discussions

MikroTik App
 
lauretfrederic
just joined
Topic Author
Posts: 1
Joined: Thu Apr 03, 2025 3:56 pm

dude function

Thu Apr 03, 2025 4:04 pm

Hello,
Does anyone have a solution for writing a Dude function (RouterOS 7.18) that queries a web service returning a JSON value?
http://xxxxxxxx:xxxxxxx/get_get_temp_cpu?password=xxxxxxxx&username=xxxxxxxxx&ip=yyy.yyy.yyy.yyy

This function would be used to create a specific probe.
Thanks for your help and advice.
 
User avatar
BergDev
just joined
Posts: 15
Joined: Thu Mar 05, 2020 4:27 pm
Location: Russia
Contact:

Re: dude function

Wed Apr 23, 2025 11:04 am

Hi, I haven't encountered JSON, but I get certain parameters via SNMP query and display them separately in the device card.
oid(«oidnumber»)
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4862
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: dude function

Wed Apr 23, 2025 8:25 pm

If you can use SNMP that be better and align with Dude.

For JSON values, you MIGHT be able to use the ros_command("/tool/fetch url=... as-value output=user"). And if using 7.16+ there is a ":deserialize from=json ..." that get you an array to pick out a specific value. All this gets a bit complex in context of probe, but SHOULD work if you can align the various things (i.e. a probe logic needs to be considered when you write the function since there is both a success and failure modes etc etc).