Activate Script

I have the following script and I want it to be activated when I don’t have internet and deactivate when I have internet. Thanks for your help.

:global script false;
:do {
/if condition=([/ping 1.1.1.1 count=6] =0) else={:put “if there is internet”}
do={:put “there is no Internet”}
:delay 6;
} while=(!$script)



EL DONCITO.

No need to use ping in script.

What you do is to use netwatch.
There you can have a script for up/down information.

Script name: Netwatch

####################################
# Netwatch script
#
# Used as both up and down script
# Created Jotne 2021 v1.5
#
####################################
:local Host $host
/tool netwatch
:local Status [get [find where host="$Host"] status]
:local Comment [get [find where host="$Host"] comment]
:local Interval [get [find where host="$Host"] interval]
:local Since [get [find where host="$Host"] since]
:log info "script=netwatch watch_host=$Host comment=\"$Comment\" status=$Status interval=$Interval since=\"$Since\""

Then add an IP to monitor like this:

/tool netwatch
add down-script=Netwatch host=8.8.8.8 up-script=Netwatch

See more information here: http://forum.mikrotik.com/t/tool-using-splunk-to-analyse-mikrotik-logs-4-0-graphing-everything/153043/3

Thanks for your answer friend, and how do I store it in a file?

Ehm.. what file for what? :open_mouth:

Uh… nice catch @Jotne
The possibility to use $host inside netwatch is not documented…
Where you find it?

Not sure where I get it from. May have seen it some place and start using it.