Hi!
Guys I searching in this section some similar cases, but really can’t enough for construction my own script for netwatcher… 'Cuz I don’t have necessary skills for mikrotik scripting yet. 
I need next:
- ping host 10.0.0.1;
- if 10.0.0.1 not reachable, then disable ppp interface with the name TEST, wait for 15 seconds and enable it again.
I wrote some similar as I think scripts for up interfaces if they down, but I need ping before some action now.
Anyone can help with it? Thanks.
Hi, I haven’t tested it, try it.
The test is carried out every 10 minutes
system/script/add name=CheckIP source={
# variables
:local targetIP "10.0.0.1"
:local interfaceName "test"
:local disableTime 30s
# check ip
:if ([ping $targetIP count=1] = 0) do={
# Disable interface PPP
:log info "Disable interface PPP $interfaceName"
/interface ppp-client disable $interfaceName
# wait
:delay $disableTime
# Enable interface PPP
:log info "Enable interface PPP $interfaceName"
/interface ppp-client enable $interfaceName
} else={
:log info "IP address $targetIP is UP."
}
}
/system scheduler add interval=10m name=scheduleCheckIP on-event="CheckIP" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=2023-11-14 start-time=16:14:31
Ciao
Marcello
Dope! Thanks homie! 
It’s looks as expected, in routeros?

I thinking 'bout one thing, it possible to check in this script Internet connection also? For example ping 8.8.8.8 and run script only if Internet ping is ok but my 10.0.0.1 is not reacheble? Because if there is no Internet connection, then there is no point to re-up ppp interface, because my host will be unavailable anyway.
I tested it, and just disable l2tp client interface, and I see in log only “Disable l2tp-client interface $interfaceName by connection script check” part, after 15s is nothing change, interface is still disable and this action repeated. What am I doing wrong?
{
# variables
:local vpsIP "10.0.0.1"
:local internetIP "8.8.8.8"
:local interfaceName "my-vps"
:local waitTime 15s
# check ip
:if ([ping $vpsIP count=1] = 0 && [ping $internetIP count=1] = 1) do={
# Disable l2tp-client interface
:log info "Disable l2tp-client interface $interfaceName by connection script check"
/interface l2tp-client disable $interfaceName
# wait
:delay $waitTime
# Enable l2tp-client interface
:log info "Enable l2tp-client interface $interfaceName by connection script check"
/interface l2tp-client enable $interfaceName
} else={
:log info "Run $interfaceName connection check script"
}
}
Btw, change my vps ip to a non-existent address in my network, and as I see the interface is not disabled by my command in script, although it works in the console.
I’m sorry, my fail with the one letter in the interface name, in console it was correct, but in script is wrong. Issue is resolved. Thanks.
I post my script ova here, maybe someone it will be helpful in the future.
What script doing:
- checking one ip for availability
- checking internet connection
- disable/enable lt2p interface with 15s delay
- write info messages into log and send message to telegram also
{
# variables
:local vpsIP "your_ip_for_check_remote_node"
:local internetIP "your_ip_for_check_internet_connection"
:local interfaceName "your_interface_name"
:local waitTime 15s #delay
# check ip
:if ([ping $vpsIP count=1] = 0 && [ping $internetIP count=1] = 1) do={
# Disable l2tp-client interface
:log info "VPN: VPS internal IP is DOWN and Internet is UP. Disable l2tp-client interface $interfaceName for 15 seconds"
/interface l2tp-client disable $interfaceName;/tool fetch url="https://api.telegram.org/botYOUR_ID:YOUR_KEY/sendMessage?chat_id=YOUR_CHAT_ID&text=VPS internal IP is DOWN! DISABLING client interface..." dst-path=telegram-bot-log.txt
# wait
:delay $waitTime
# Enable l2tp-client interface
:log info "VPN: Enable l2tp-client interface $interfaceName"
/interface l2tp-client enable $interfaceName;/tool fetch url="https://api.telegram.org/botYOUR_ID:YOUR_KEY/sendMessage?chat_id=YOUR_CHAT_ID&text=VPS client interface is ENABLED" dst-path=telegram-bot-log.txt
} else={
:if ([ping $internetIP count=1] = 0) do={
:log info "VPN: Internet is DOWN"
} else={
:log info "VPN: VPS internal IP is UP"
}
}
}