Community discussions

MikroTik App
 
iRZ0mbie
just joined
Topic Author
Posts: 1
Joined: Sat Nov 07, 2020 3:39 am

Auto Add Static IP to Netwatch for Logging

Sat Nov 07, 2020 3:54 am

Hey there, Im new here and hope to contribute and get some help.

I've written a script which will seek out any static IP address and add it to Netwatch with an up and down comment for logging and a short interval. It works quite well and its very useful if you have several IP's you need to add to Netwatch.
:foreach leaseId in=[/ip dhcp-server lease find where !dynamic] do={/tool netwatch add host=[/ip dhcp-server lease get $leaseId address] interval=10 down-script=":log info DOWN" up-script="log info UP"}
This works great if you only need to use it once. I want to set up the script to run in system scheduler and automatically add any static IP to the Netwatch. Currently if you run the script in scheduler it will repeatedly add every static IP to Netwatch. I need the script to omit adding any IP that is already monitored by Netwatch. A bonus would be to have the static IP comment added to the corresponding Netwatch comment.

Thanks in advance and I hope this script is helpful to some..

Who is online

Users browsing this forum: No registered users and 28 guests