How to pass TCP Probe result (JSON) into Function Probe in Dude?

Hello. I am configuring Dude to monitor a Shelly EM device.

I created:

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

  2. Function:

    Code

    regexp("\"a_act_power\": *([0-9.]+)", value)
    
    
  3. Function Probe that calls this function.

The problem:
Function Probe always shows “parse failed” because value is 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?

Thank you.

Hi,

There are some questions to you

  1. What version you use?
  2. What is the point #3 about? Missed lines?
  3. Why you created a function for a field that does not exist? What the decision was based on?
  4. What version of Dude you use?

Dude is an abandonware

What AI suggested you such a solution?

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.

[admindude@Dudetest] > :put ([/tool fetch url="http://192.168.131.200/rpc/EM.GetStatus?id=0" as-value output=user]->"data")
{"id":0,"a_current":3.480,"a_voltage":225.7,"a_act_power":696.2,"a_aprt_power":785.5,"a_pf":0.89,"a_freq":50.0,"b_current":0.513,"b
voltage":227.0,"b_act_power":111.5,"b_aprt_power":116.6,"b_pf":0.96,"b_freq":50.0,"c_current":9.651,"c_voltage":221.3,"c_act_power
":1788.2,"c_aprt_power":2135.5,"c_pf":0.83,"c_freq":50.0,"n_current":null,"total_current":13.644,"total_act_power":2595.895,"total

aprt_power":3037.590, "user_calibrated_phase":}

Dude version 7.22?

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 boolean result (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.

So, for example,

:put (\[:deserialize from=json (\[/tool fetch url="http://192.168.131.200/rpc/EM.GetStatus?id=0" as-value output=user\]->"data")\]->"a_act_power")

Side notes:

  • 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