Use Netwatch for multiple failures (not act at the first one)

Hi, this tool is fine, but I don’t understand how to moderate it, to don’t act a reboot at the first failure. My goal is to “revive” a remote user connected by an LTE USB modem, I would ping for example 8.8.8.8 once every 10 minutes, if it fails for 3 times (total down expected for 30 minutes) it will power off and power on the USB.
So I need to reset to 0 the 3 attempts limit as soon a reply came, and I would then wait another 30min if the reboot didn’t give the desidered result, so after exacuting the reboot the attempts will be also reset to zero. (without this I expect on thr 4th attempts it will reboot again, then on 5th and so on).
To reset for 5 seconds I can use: /system routerboard usb power-reset duration=5 right?
Thank you

There are differnet types of ping usable in netwatch.
The simple is "simple" :wink:.

There is ICMP that - properly configured [1] - has more features, and probably could do what you need.

Otherwise you could have as "down" script, a script that itself pings a few times and only if it fails resets the usb power, that can be also assembled in more "stages", loosely like : Advanced NetWatch

[1] much easier to saying that than actually doing it

thank you for your kind answer, and for the link.
There is a suggestion to use watchdog, that has sense and it is much less complicated. I can indicate to check one hour after start, and if there no answer coming after 60 seconds that means the lin is down. There can be a trouble if the packet get lost, then a reboot will appear as the first attempt while I would like to have multiple fails before decide to reboot everything.
I then have to ook for how watchdof works, if it makes different attempts or just one is enough to trigger the reboot.

Personally I am not a fan of watchdog, as watchdog will reboot system, while what you actually need is only power cycling the usb port.

Given your stated check times (tens of minutes) it won't make a difference to have a (say) 5 seconds pause due to USB reboot and (still say) the 20 seconds or so for fully rebooting the router, still why rebooting the router if not necessary?

I know what you mean, but if the router has the only task to connect to LTE there is no inpact on anything else, with watchdog. More, it reboots also the router, this may give more chances to recover for any problem, and where the host is remote.. that's fine.
I've read the watchdog triggers after 6 consecutive ping fails, that suites me.
I always prefer on keep the things simple and avoid loose time with debugs, this is another reason for me.

Yep, but the watchdog will reboot (again and again every 6 minutes) if the target is not reachable, while netwatch operates on the principle of changes in the connection status, i.e. when it goes from up to down, but not if it stays down.

No because there is the chance to start the ping after tme, I set 2 hours, in the worst case I'll have a reboot every 2 hours )

The no-ping-delay?
But I believe that applies also for the first run, so for two hours you won't have anything monitoring via ping.

yes, each time it reboots there is a new countdown.
I can wait 2 hours, it's not critical )

Whatever floats your boat , fine. :slightly_smiling_face: