netwatch beep loop

i want to use this script in netwatch when a host is down to beep the mikrotik

{
:local count
:local freq


:for c from=1 to=50 step=1 \

do={
:set count 15
:set freq 1900

:do {
:beep length=400ms frequency=$freq; :delay 25ms
:set count ($count - 1);
:set freq ($freq +35)

}
while (($count <16) && ($count >0))
:beep length=0 frequency=0
}
}
}

but i want it in a loop to keep beeping, any ideas ??

P.S: i didn’t create this script, i just copied it from someone’s blog.

If you start a loop, the routerboard NEVER stop beeping, also if the problem are solved, until reboot…

This way is better:

on down:

:global setAlarm value=[:tobool true];
:while ($setAlarm) do={
 :beep frequency=2000 length=500ms;
 :delay delay-time=1000ms;
 :beep frequency=4000 length=500ms;
 :delay delay-time=1000ms;
}

on up:

:global setAlarm value=[:tobool false];

If you like this, please add Karma, Thanks.

Thanks rextended this is a usefull sound.
+1

i did what you gave me rextended but when up the beep wont stop !!.
how to make the beep stop when it’s up ?

have you added the event “on up” on the first post?

If you place more than one alarm with same variables, the alarm not stop sound if more than one events are down.

If you add more than one netwatch, must be used different variables name, like:

on the first, on down:
:global soundAlarm**1** value=[:tobool true];
:while ($soundAlarm1) do={
:beep frequency=2000 length=500ms;
:delay delay-time=1000ms;
:beep frequency=4000 length=500ms;
:delay delay-time=1000ms;
}
on up:
:global soundAlarm**1** value=[:tobool false];


on the second (also change the sound…:slight_smile: ), on down:
:global soundAlarm2 value=[:tobool true];
:while ($soundAlarm2) do={
:beep frequency=1000 length=1000ms;
:delay delay-time=500ms;
:beep frequency=5000 length=500ms;
:delay delay-time=1000ms;
}
on up:
:global soundAlarm**2** value=[:tobool false];

i just copied and pasted from your first post to up and down events.

but i noticed in your second post there is a number 1 in it which wasn’t in your first post.
i will test it later when i’m on the mikrotik.

IF you make test each 20 min, the beep stop after 20 min the problem is solved! :slight_smile:

For fast stop alarm, use little probe time, like 30 sec or 60 sec.

If you set Netwatch to control each 60 sec, if the alarm are triggered once, when the problem are solved, you must wait next netwatch test between 0 to 60 sec.

If you check every hour, the netwatch check every hour if are up and down, the alarm can play from 60 min before stop!

In the “second post” are a number, for explain: if you are more than one netwatch, use different variable name, or other probe can shut down alarm, also if the problem are not solved.

what do you mean by variable ?
can’t you give me something easy to copy and paste ?
i have only one netwatch trigger to test ping on 8.8.8.8

Simply use the example on my first post.

Remember:

IF you make test each 20 min, the beep stop after 20 min the problem is solved!

For fast stop alarm, use little probe time, like 30 sec or 60 sec.

If you set Netwatch to control each 60 sec, if the alarm are triggered once, when the problem are solved, you must wait next netwatch test between 0 to 60 sec.

If you check every hour, the netwatch check every hour if are up and down, the alarm can play from 60 min before stop!

In the “second post” are a number, for explain: if you are more than one netwatch, use different variable name, or other probe can shut down alarm, also if the problem are not solved.

i did exactly as your example, same issue, when it beeps it never stops, the test is set to 15 seconds, when down happens it starts beeping after 15 seconds then if it goes up it never stops beeping !!

something is missing in your script, maybe the up script.

put on the forum the result of “/tool netwatch export compact” without change anything.

this is the export

/tool netwatch add disabled=yes down-script=“:global soundAlarm1 value=[:tobool true];\r
\n:while ($soundAlarm1) do={\r
\n:beep frequency=2000 length=500ms;\r
\n:delay delay-time=1000ms;\r
\n:beep frequency=4000 length=500ms;\r
\n:delay delay-time=1000ms;\r
\n}” host=8.8.8.8 interval=10s up-script=
“:global soundAlarm1 value=[:tobool false];”

I paste it on my rb493g RouterOS 6.7 and all is working as expected, what version of routeros you have and what routerboard you use?
You cut the export.

routerboard x86
router os 5.26

One little thing: you routerboard can ping 8.8.8.8?



When I’m at work, I try. This script is for 6.7+, I do not know if are some problem on 5.26.

yes it can ping 8.8.8.8
i take off the wan cable so netwatch will go down and run the down script (beep)
but when i put it back, netwatch change status to up and the beep wont stop, even though netwatch says up

i went with this option on my cloudcore, create a new script called siren

{
:beep frequency=2000 length=500ms;
:delay delay-time=1000ms;
:beep frequency=4000 length=500ms;
:delay delay-time=1000ms;
}
{
:beep frequency=2000 length=500ms;
:delay delay-time=1000ms;
:beep frequency=4000 length=500ms;
:delay delay-time=1000ms;
}

i then created a new schedule task called siren which calls the script siren (just type in siren in the ‘on event’ box), setting the interval to 00:00:12

from there in netwatch down action alongside my email script i added the following

/system scheduler enable [find name=siren]

this will make the siren script run indefinitely

then add a netwatch up action with the following

/system scheduler disable [find name=siren]


simple and works for me :slight_smile: