4IceG / luci-app-lite-watchdog

Simple internet connection monitor. Connection tester based on the method of testing pings to a given address. (LuCI JS) | OpenWrt >= 21.02
MIT License
14 stars 2 forks source link

Add option to set delay in seconds #3

Open 1alessandro1 opened 8 months ago

1alessandro1 commented 8 months ago

Hello, currently this script supports only 1 minute as the lowest time to check if a certain host is reachable

image

I would like to implement some check every 3-4 seconds, can you please add the option to set time interval in seconds?

4IceG commented 8 months ago

Hi @1alessandro1 , Package uses cron in the settings, so it is not possible to reduce time to a value in seconds.

Activity log is saved in flash memory, to limit write operations it is not advisable to set a high test frequency.

1alessandro1 commented 8 months ago

The problem is that our provider "resets" the connection every 4 hours (exactly) and I would achieve minimal downtime... 1 minute of downtime is already a lot

1alessandro1 commented 8 months ago

While RouterOS achieves to reconnect almost instantaneously, openwrt needs help because after this reset everything goes down until I issue a reboot of the modem or AT+CFUN=1,1

image As you can see, from 23.10 to 3.10 it was everything fine, then went down

4IceG commented 8 months ago

Ok I see. I don't know how connection control works in RouterOS, but I know that OpenWrt has problem with it (for a long time). Currently, all detection and reconnect methods incur latency. From what I remember, method based on modemenager scripts worked the fastest.

1alessandro1 commented 8 months ago

Ok I see. I don't know how connection control works in RouterOS, but I know that OpenWrt has problem with it (for a long time). Currently, all detection and reconnect methods incur latency. From what I remember, method based on modemenager scripts worked the fastest.

Your script uses modemmanager under the hood?

4IceG commented 8 months ago

My package does not use modemanager. Modemanager is all in one, it's responsible for the connection, reads connection parameters from modem, sends USSD codes and supports SMS messages.

By doing all this, mm makes it difficult for other packages/scripts to communicate with modem, so I bypass the modemmanager. Every user has a choice and uses what he wants.

Manu99it commented 3 months ago

@4IceG I think you can use sub-minute in cron by issuing the same command with a wait time like every 30 seconds for example:

* * * * * command * * * * * sleep 30 && command

Or every 20 seconds:

* * * * * command * * * * * wait 20 && command * * * * * wait 40 && command

Etc. I know, it's a bit ugly. Alternatively is possible to write a script with a while loop that manages the time sub-minute and start that in cron every minute

4IceG commented 3 months ago

Hi, @Manu99it I know that Cron allows to add an option with a period in seconds, but I am not sure about using such a solution.

For me, the setting to check every minute is already on the edge. There must be time for a response, for writing the log file. I don't know how much the checking period can be reduced for everything to work properly... 20, 30, 45 seconds? I have period set to 7 minutes (and 2 failed checks) and it is acceptable to me.

If you are interested, you can manually modify the checking period in LuCI.

If someone tests a reasonable period in seconds, I can change it in the package to be able to set such values.

Manu99it commented 3 months ago

@4IceG yeah I could test it maybe even if I don't really need it because my IP changes every 24h, so I simply restart the wan interface at 5am.

I've a related problem however, even if a little different. I hope it's not too off topic to talk it about it here. My ISP (Wind3) on the business apn (myinternet.wind) changes the ip every 24h but doesn't support IPv6. On the other hand, on its consumer APN (internet.it) it supports IPv6, but ip changes every 4h (yes even the IPv6). So on the wan interface I set up the two apns and all is working correctly for exactly 4h. But after 4h, while IPv4 connectivity continues to work, IPv6 one doesn't, until I restart the wan interface. I would like that IPv6 would continue to work even after 4h, with this watchdog is possible to ping a IPv6 link I think and restart the wan accordingly (does it restart the wan completely right?). However I wouldn't like to restart the wan, because this would mean lose connection every 4h even if for a little time. Is possible to get the new IPv6 routing without restarting the wan, and then repropagate the IPv6s through DHCPv6?

Maybe I should create two wan interfaces? One for IPv4 and one for IPv6, and if I restart the IPv6 one it shouldn't touch the IPv4 one right? Would that work?

4IceG commented 3 months ago

Maybe I should create two wan interfaces? One for IPv4 and one for IPv6, and if I restart the IPv6 one it shouldn't touch the IPv4 one right? Would that work?

I would make a copy of settings and try this solution, it seems the most logical and sensible to manage (assigned one interface to one IP).

Manu99it commented 3 months ago

Maybe I should create two wan interfaces? One for IPv4 and one for IPv6, and if I restart the IPv6 one it shouldn't touch the IPv4 one right? Would that work?

I would make a copy of settings and try this solution, it seems the most logical and sensible to manage (assigned one interface to one IP).

I tried and unfortunately it doesn't work. No matter what, QMI protocol seems to be injective, one2one with a modem, you can't really duplicate it: if you do, only the last restarted interface would work. Making a wan with a DHCPv6 protocol doesn't work either, because when the DHCPv6 client request the ip to the wan interface the IPv6 isn't changed because the "real" wan (wwan0) is not restarted - and so the new IPv6 is not requested to the modem. I think in some way should be possible to request the new IPv6 routing to the modem without restarting completely the interface, because theoretically one should be able to divide the IPv4 to one interface and the IPv6 to the other (unless IPv6 and IPv4 are requested with the same command on a modem, I think?)