Hello. I am configuring Dude to monitor a Shelly EM device.
I created:
TCP Probe
Code
GET /rpc/EM.GetStatus?id=0 HTTP/1.1\r\nHost: 192.168.131.200\r\nConnection: close\r\n\r\n
It works and returns valid JSON.
Function:
Code
regexp("\"a_act_power\": *([0-9.]+)", value)
Function Probe that calls this function.
The problem: Function Probe always shows “parse failed” becausevalueis empty.
In my Dude version:
There is no Polling → Probe field
There is no “Depends On” in Function Probe
There is no “Expect” field in TCP Probe
Services do not pass TCP Probe result into Function Probe
Function Probe does not receive JSON from TCP Probe
Question: How can I pass the result of a TCP Probe (JSON) into a Function Probe in this version of Dude? Is this feature removed, or is there another way to link probes?
The question is, can I retrieve data into The Dude using a GET request? I am using version 7.22. I can read the data in RouterOS, but I need to display it on a device on the map.
If you can read the data in RouterOS, you can just put this data into a global variable via some script, and then display this variable using ros_command function in the Dude: ros_command(":put $YourVariable")
The Dude version matches the RouterOS version 7.22. The real question here is whether everything can be done via The Dude, since I plan to monitor a large number of these devices. If I were to use RouterOS, I would have to add a script and a custom variable for each device—in addition to adding the device to The Dude map.
The purpose of a probe is to get a state of some service, it's not suitable to display data on device, only on a graph. Also, the Dude doesn't support passing any arguments to custom functions, this is a big problem. So, I don't think there is any way to get the data as you want. But to avoid adding a script, you can put your /tool fetch... command and may be some other formatting code into the same ros_command function. But it will look messy, you'll need to escape quotes and some other characters with a backslash.
That's not right, since ros_command() could use a more complex RouterOS in the Dude Function. The ros_command() does not have use a script or variables, if the RouterOS command outputs is then parsed using more functions in Probe defination. e.g. ros_command() will just return whatever [complex] expression that you can use further in the Probe definition.
The same function can be used for map display expression (although it run it again). But there is no way (AFAIK) to access a probe data (like your TCP example) from a function. contra. a function can be used in either/both display and a Probe with type=function.
Side note, there is also type=logic on Probe to combine multiple probe booleanresult (e.g. pass/fail, but not data).
Just to clarify, you can use :deserialize as part of the operation, which get you a RouterOS array to re-reference before the Dude's ros_command() returns the data.
now this does not handle failure modes well... so more tweaks so the RouterOS expression, which can use a { } bock, does more checks and always return some "0" or "-1" even if the fetch failed.
probes only track ONE data element, so you needed to track multiple values, you'd need multiple probes... thus multiple fetch calls, one per variable you want to track