Community discussions

MikroTik App
 
john231
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Wed Aug 08, 2018 12:11 pm

Is there a script/functionality to ping domain like netwatch and send email if up/down?

Sun Mar 06, 2022 4:00 pm

What i need is to ping another remote mikrotik device by using the DDNS address that mikrotik provides. If the remote host goes down then an email is sent. So basically just netwatch but for an url rather than ip address cause the public ip address on the other remote is dynamic and changes from time to time.
 
john231
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Wed Aug 08, 2018 12:11 pm

Re: Is there a script/functionality to ping domain like netwatch and send email if up/down?

Sun Mar 06, 2022 4:31 pm

 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Is there a script/functionality to ping domain like netwatch and send email if up/down?

Mon Mar 07, 2022 3:45 pm

You simply can use netwatch for check and use the send mail function inside netwatch.

Just simply schedule the update of the watched IP from netwatch.

with working email section and netwatch already configured with actual IP,
schedule a script like:

step 1: try to use the resolve function with the DDNS name for obtain the IP

step 2a: if the resolve function fail, disable netwatch
done

or

step 2b1: if resolver resolve the DDNS, and only if IP is different (for prevent memory wearing), assign the IP to netwatch rule
step 2b2: enable netwatch, only if is disabled (for prevent memory wearing)
done
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Is there a script/functionality to ping domain like netwatch and send email if up/down?

Tue Mar 08, 2022 12:51 am

You could have a look at my script Notify on host up and down. It allows update from dns, and a lot more.
 
john231
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Wed Aug 08, 2018 12:11 pm

Re: Is there a script/functionality to ping domain like netwatch and send email if up/down?

Sun Mar 13, 2022 10:04 pm

You could have a look at my script Notify on host up and down. It allows update from dns, and a lot more.
Cool, but i don't understand the disclaimer:

But be warned: Dynamic updates will probably cause issues if the name has more than one record in dns - a high rate of configuration changes (and flash writes) at least.

But if i'm using the mikrotik cloud ddns address will i still see a lot of flash writes?
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Is there a script/functionality to ping domain like netwatch and send email if up/down?

Mon Mar 14, 2022 12:20 am

Think about a domain like "dns.google", that resolves to two addresses, 8.8.8.8 and 8.8.4.4.
[admin@MikroTik] > :put [ :resolve dns.google ]
8.8.8.8
[admin@MikroTik] > :put [ :resolve dns.google ]
8.8.4.4
These addresses are used in round-robin, so the script would update the netwatch configuration on most runs.

Records from Mikrotik cloud ddns have exactly one address that is updated when required. No issue there.

Who is online

Users browsing this forum: onnyloh and 8 guests