Community discussions

MikroTik App
 
OlegkaOwl
just joined
Topic Author
Posts: 13
Joined: Wed Apr 29, 2015 10:05 pm

Email if host at netwatch list is down more then 1 day

Wed Nov 08, 2017 12:43 am

Hello!
I need to write a script which informs me by email about the inaccessibility of an every IP-address from the Netwatch list if more than a one day.
I started writing a script, but I do not know how get the parameter "SINCE"
For example;
:local monlist [ /tool netwatch print where status="down" since!="" ]
:foreach i in=$monlist do={
:put (get $i "SINCE");
}

The result
# HOST TIMEOUT INTERVAL STATUS SINCE
0 192.168.132.20 1s 1m down oct/05/2017 02:36:28

How can i get a date "SINCE" ?
 
stoser
Member Candidate
Member Candidate
Posts: 123
Joined: Sun Aug 21, 2016 12:04 am

Re: Email if host at netwatch list is down more then 1 day

Wed Nov 08, 2017 6:36 am

Three possible problems: 1) Instead of the print command, use the find command . 2) since should not be capitalized (SINCE != since). 3) the get command needs to be executed from the netwatch directory level. It does not exist at root level

The following works on a 3011 running 6.40.4. From Terminal, to put the "since" field to the screen, after declaring the local variable i:

foreach i in=[/tool netwatch find where status="up" since!=""] do={:put [/tool netwatch get $i since]}

Kind regards
 
OlegkaOwl
just joined
Topic Author
Posts: 13
Joined: Wed Apr 29, 2015 10:05 pm

Re: Email if host at netwatch list is down more then 1 day

Wed Nov 08, 2017 7:33 pm

Thank you, it works :)
 
y2000rtc
just joined
Posts: 4
Joined: Fri Aug 28, 2020 3:50 pm

Re: Email if host at netwatch list is down more then 1 day

Sun Feb 27, 2022 9:42 pm

OlegkaOwl, hi, please, can you put here all code of this fucntion?
I also need that functionality.

Many thanks for any help.
Zed

Who is online

Users browsing this forum: No registered users and 9 guests