Community discussions

MikroTik App
 
Redmor
Member Candidate
Member Candidate
Topic Author
Posts: 256
Joined: Wed May 31, 2017 7:40 pm
Location: Italy

ros_command() output as string?

Thu Aug 24, 2023 6:01 pm

I'm facing a strange issue using ros_command() and /tool fetch in notification.

I'm making a probe using Detect Internet with this command below to get interface statuses that are different than "internet"

ros_command(":put [interface/detect-internet/state/get [find where state!=internet] name ]")

The probe works well, in the problem section I get "pppoe-out1" if pppoe-out1 is down, but when I use it with a notification with a /tool fetch to my Telegram and [Service.ProblemDescription] in it the notification doesn't show up.

If I pass every hand written string like "test" in the proble the notification works and [Service.ProblemDescription] is sent.

Can someone tell me how can I make ros_command() output an actual string? I'm not facing this problem with oid() for example.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3568
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: ros_command() output as string?

Thu Aug 24, 2023 6:14 pm

The output of /tool/fetch is an array, so you need do something like ([/tool/fetch ... as-value output=user]->"data") in the ros_command() with command escaped.

e.g. ros_command("([/tool/fetch ... as-value output=user]->\"data\")")

I didn't test it, but it's something like that I suspect.
 
Redmor
Member Candidate
Member Candidate
Topic Author
Posts: 256
Joined: Wed May 31, 2017 7:40 pm
Location: Italy

Re: ros_command() output as string?

Fri Aug 25, 2023 6:54 pm

I'm not using ros_command inside a /tool fetch, I'm using ros_command in a probe and using the problem result in a notification with a /tool fetch.
I am sending probe problem using [Service.ProblemDescription] which I can clearly read in Service -> General, but it isn't sent as [Service.ProblemDescription].
If instead of ros_command() returned value I write a string or get a parse failed error, the fetch sends the message error, so I assume it is ros_command() that doesn't return a string like oid() for example.

Who is online

Users browsing this forum: No registered users and 4 guests