Community discussions

MikroTik App
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 110
Joined: Sat Sep 22, 2018 6:13 pm

help probe netwatch

Thu May 26, 2022 9:47 pm

Hello,
i want to monitor a mikrotik load balancer (pcc) with ip on wan natted.

so i can't monitor from outside mikrotik.

i can monitor mikrotik 4011 from a remote chr on datacenter with VPN.
works all fine, but i want to check if a wan is down

so, if a run on terminal in 4011
:put ([:pick [/tool netwatch print as-value where comment="MONITOR - WAN1"] 0]->"status");
result is up or down

i try to integrate this ros command in dude to monitor if a wan is down

so i create a function
name: mikrotik_netwatch_wan1
code:
ros_command(":put ([:pick [/tool netwatch print as-value where comment=\"MONITOR WAN1\"] 0]->\"status\");")
i used \ to escape double quotes

create probes
name: mikrotik_netwatch_wan1
type: function
agent: default

available : 1=1
error : if(mikrotik_netwatch_wan1()=up, "", "down")

value: mikrotik_netwatch_wan1()

unit: [empty]

but when i add this probe to device i have "parse failed"

some can help to improve this monitoring?

thank you in advance
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 110
Joined: Sat Sep 22, 2018 6:13 pm

Re: help probe netwatch

Fri May 27, 2022 9:35 pm

i think parse failed is a problem in functions.
so i try also
if (ros_command(":put ([:pick [/tool netwatch print as-value where comment=\"MONITOR WAN1\"] 0]->\"status\");")) = "up", "", "down")
but i have same problem "parse failed"
i try also with host
if (ros_command(":put ([:pick [/tool netwatch print as-value where host=8.8.8.8] 0]->\"status\");")) = "up", "", "down")
thank you
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: help probe netwatch

Sat May 28, 2022 10:50 am

Simply count parenthesys outside put string?
2 (
3 )
if ( ros_command(":put ([/tool netwatch print as-value where comment=\"MONITOR WAN1\"]->0->\"status\")") = "up", "", "down" )
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 110
Joined: Sat Sep 22, 2018 6:13 pm

Re: help probe netwatch

Sat May 28, 2022 10:25 pm

thank you for reply.
i check on mikrotik and yes , your code is more clean and works :)

but when i change on dude i receive always "parse failed"

maybe error is on probe???

name: mikrotik_netwatch_wan1
type: function
agent: default

available : 1=1
error : if(mikrotik_netwatch_wan1()=up, "", "down")
value: mikrotik_netwatch_wan1()
unit: [empty]

i tried also
error : if(mikrotik_netwatch_wan1()==up, "", "down")

thank you again
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 110
Joined: Sat Sep 22, 2018 6:13 pm

Re: help probe netwatch

Sun May 29, 2022 3:10 pm

i check another way , and change function like this
ros_command(":put ([/tool netwatch print as-value where comment=\"MONITOR WAN1\"]->0->\"status\")")
i add it in appearance and i show correct : up

so now i'm sure problem is on probe

i create probe
available: 1
error: if(mikrotik_function_netwatch_wan1()==up, "", "down")
value: mikrotik_function_netwatch_wan1()

also
error: if(mikrotik_function_netwatch_wan1()=up, "", "down")

parse error
 
aleab
Member Candidate
Member Candidate
Topic Author
Posts: 110
Joined: Sat Sep 22, 2018 6:13 pm

Re: help probe netwatch

Mon Jun 06, 2022 9:39 pm

nothing, i try many code but with the dude i have always same error...

to reader, i resolve with zabbix...
i monitor netwatch with zabbix and ssh agent (of course i need to enable and expose ssh port, but i open only from my zabbix ip)

thank you for reply.

ps. @rextended , can i contact you in private?
i need some help with a request of my customer and i'm searching a professional help (payment of course)

thank you

Who is online

Users browsing this forum: No registered users and 9 guests