Monitor and log internet connection up and down times
- Inicie sesión ou rexístrese para enviar comentarios
I am recently experiencing problems with my internet connection at home. It generally works but several times a day, it is interrupted for a few minutes, so I did not have an opportunity to do significant investigation and I am lacking understanding of what could be happenning. I am only using ethernet with computers so the problem is not wifi.
I am looking for some way to permanently monitor the connection and record down times, in order to get a better understanding of how long the problem lasts each time and how frequent it is. I'd also like a sound alert so that I can do some checking immediately while the connection is down.
Is there any kind of tool in Trisquel repository that could do that?
I am looking for some way to permanently monitor the connection and record down times, in order to get a better understanding of how long the problem lasts each time and how frequent it is.
The systemd journal certainly does that for you. You read it from the terminal with the journalctl command. See man journalctl for the many filtering options (such as -g) the command provides, the different formats for the timestamps (-o short-unix may be convenient if you want to compute the down times using for instance AWK), etc.
I'd also like a sound alert so that I can do some checking immediately while the connection is down.
Once you will have identified in the journal the line that is logged when the connection is down, you can write a small Shell script that calls journalctl every second (for instance) and plays a sound if the line has just been logged. Or, probably easier, instead of reading the journal, the script can regularly call nmcli (with the appropriate arguments; see man nmcli) to figure out if the connection is down.
The only network-related traces I see with journalctl are dhclient and NetworkManager for DHCP lease renewal (I use sudo, I have been using journalctl on my Freedombox and I know that without sudo I see almost nothing), I see no error besides that. The network interface is ok I think, it is just that my ISP's routeur is not responding. I don't know whether it is because it has a problem or whether it is a problem with the cables and switches between my computer and my routeur, or something else, but I'd like to know how frequently it happens and for how long.
Is there any service that constantly checks the gateway? If yes, it is either not started on my computer or it is not logging anything.
If there is not any such servive, my guess it that I could use a script that does some periodic pings, of the routeur and of something on internet (in case the problem is beyond my ISP's routeur). But I don't know whether this is the best idea and if some script exist already for that, it is problem much better than anything I could write by myself.
my ISP's routeur is not responding
Any way to access its logs?
I don't know whether this is the best idea and if some script exist already for that, it is problem much better than anything I could write by myself.
There are many systems made to monitor a whole local network: Cacti, collectd, Icinga, Ganglia, Munin, Nagios, Xymon, Zabbix, etc. Those systems look too complicated for what you want to achieve. I am actually bad at networking...
Thanks. No, I don't have access to the logs.
I looked at ping, the following options seem useful:
-O Report outstanding ICMP ECHO reply before sending next packet. This is useful together with the timestamp -D to log output to a diagnostic file and search for missing answers.
The time format is something like "[1636626048.470625]", I suppose there are standard ways to convert it to something human readable.
I guess logging the pings with the above options, plus a process checking the log and alerting would be fine. I would just need to add some kind of logrotation and complete purge if no error.
Since the problems stopped (and I am still struggling with my desktop general protection faults), I did not try to do that, but I'll look at it.
- Inicie sesión ou rexístrese para enviar comentarios