Community discussions

MikroTik App
 
User avatar
prozak
newbie
Topic Author
Posts: 45
Joined: Sat Jan 16, 2010 4:01 am

Advanced NetWatch

Thu Jan 26, 2023 9:42 pm

Hello.
I came across an issue in our country where mobile internet access went down for a couple of hours and some of my Chateaus did not re-register on carrier and they needed LTE restart.

I wanted a method to check at least 3 hosts before issuing LTE restart, so i created and share this handy script. (Works on rOS 7.5<)
/tool netwatch
add comment=STAGE-1 disabled=no down-script=":log info \"Activating Stage-2\";\r\
    \n/tool/netwatch enable [find comment=STAGE-2];\r\
    \n" host=208.67.222.222 http-codes="" interval=30s packet-count=4 \
    packet-interval=5s test-script=":log info testing" thr-avg=500ms type=icmp \
    up-script=":log info \"DISABLING\";\r\
    \n/tool/netwatch disable [find comment=STAGE-2];\r\
    \n"
add comment=STAGE-2 disabled=yes down-script=":log info \"Activating FINAL Stage\
    -3\";\r\
    \n/tool/netwatch enable [find comment=STAGE-3];\r\
    \n" host=217.160.0.25 http-codes="" packet-count=5 packet-interval=5s \
    test-script=":log info \"STAGE-2 CHECK...\"" thr-avg=500ms type=icmp \
    up-script=":log info \"DISABLING\";\r\
    \n/tool/netwatch disable [find comment=STAGE-2];\r\
    \n/tool/netwatch disable [find comment=STAGE-3];\r\
    \n"
add comment=STAGE-3 disabled=yes down-script=":log info \"FINAL STAGE ACTIVATED\
    \"\r\
    \n/int lte disable 0;\r\
    \n:delay 2s;\r\
    \n/int lte enable 0;" host=62.103.129.253 http-codes="" packet-count=5 \
    packet-interval=5s test-script=":log info \"STAGE-3 CHECK...\"" thr-avg=\
    500ms type=icmp up-script=":log info \"DISABLING\";\r\
    \n/tool/netwatch disable [find comment=STAGE-2];\r\
    \n/tool/netwatch disable [find comment=STAGE-3];"
It ICMP checks 1st host and if down, activates STAGE-2 checking host2.
If host2 is up, then it disables itself(STAGE-2 and further STAGE-3).
If host2 is down, it activates STAGE-3, final host.
If host3 is down, then it issues the LTE disable/enable.
If host3 is up, then it disables itself and previous STAGE-2, reverting to STAGE-1.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Advanced NetWatch

Thu Jan 26, 2023 11:59 pm

I'd also recommend using /system/watchdog with a ping address too, https://help.mikrotik.com/docs/display/ROS/Watchdog. I'd still like to think Mikrotik will iron out the failed LTE re-connection bugs one day. But the watchdog catches all kinds of failures, and generates a supout to trace down potentially why later.

Who is online

Users browsing this forum: BillyVan, esj and 16 guests