Log of lost internet connections


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log of lost internet connections
# 1  
Old 01-12-2019
Log of lost internet connections

I am having a big problem with lost internet connections with my DSL.

I would like to create a log to be able to show the technician when he comes next week.

I would like for it to only log pings that generate 100% packet loss. Thanks..

This script generates all ping attempts including successful ones.

Code:
while true; do

date >> Internet_Connection_Log.txt
echo >> Internet_Connection_Log.txt
ping  47.182.239.232 -c 1 >> Internet_Connection_Log.txt
echo >> Internet_Connection_Log.txt
sleep 180
done

Moderator's Comments:
Mod Comment edit bybakunin: Please use CODE-tags when posting code, data or terminal output. It is not only in the rules, it is the sensible thing to do. Thank you.

Last edited by bakunin; 01-12-2019 at 06:03 PM..
# 2  
Old 01-12-2019
Quote:
Originally Posted by drew77
I would like for it to only log pings that generate 100% packet loss. Thanks..

Code:
while true; do

date >> Internet_Connection_Log.txt
echo >> Internet_Connection_Log.txt
ping  47.182.239.232 -c 1 >> Internet_Connection_Log.txt
echo >> Internet_Connection_Log.txt
sleep 180
done

Make the logging dependent on the RC of ping:

Code:
while : ; do
     if ! ping  -c 1 47.182.239.232 ; then
          printf "\n%s\n" "ping failed at $(date)" >> Internet_Connection_Log.txt
     fi
     sleep 180
done

But wouldn't a log with start- and end-times of failures be better? Note that this makes sense only if the blocks of good and failing internet connections are longer - if it works 10 minutes, then fails for 10 minutes this would make sense, if every second ping fails but every other packet gets through this would create a very large log:

Code:
lFail=0
while : ; do
     if (( lFail )) ; then
          if ping  -c 1 47.182.239.232 ; then
               printf "\n%s\n" "ping worked again at $(date)" >> Internet_Connection_Log.txt
               lFail=0
          fi
     else
          if ! ping  -c 1 47.182.239.232 ; then
               printf "\n%s\n" "ping stopped working at $(date)" >> Internet_Connection_Log.txt
               lFail=1
          fi
     fi
     sleep 1
done

I hope this helps.

bakunin
# 3  
Old 01-12-2019
Thanks.

I will try the first one you listed.

My lost connections only last about 30 seconds until the modem re-connects.

--- Post updated at 04:58 PM ---

It worked great.

Code:
ping failed at Sat Jan 12 16:56:28 CST 2019

I noticed I am getting dropped connections about every 20 minutes.
# 4  
Old 01-12-2019
So you want a log of the ups and downs of your DSL connection? Depending on your ping version (ping -V, mine is "ping utility, iputils-s20180629"), a single command might suffice:
Code:
ping -Di5 router
PING router.domain.De (192.168.0.1) 56(84) bytes of data.
[1547335266.088652] 64 bytes from router.domain.De (192.168.0.1): icmp_seq=1 ttl=64 time=1.67 ms
[1547335271.094225] 64 bytes from router.domain.De (192.168.0.1): icmp_seq=2 ttl=64 time=1.44 ms
[1547335276.099867] 64 bytes from router.domain.De (192.168.0.1): icmp_seq=3 ttl=64 time=1.48 ms

Adapt the interval (-i) value to the desired granularity.
# 5  
Old 01-12-2019
I just need the times when router is down.

Added this for an audio reminder.

Code:
cvlc --play-and-exit /usr/share/sounds/My_Sounds/Alarm-sound-buzzer.mp3


Last edited by drew77; 01-12-2019 at 08:39 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. IP Networking

All incoming connections ips LOG

How to make a log that will log all ips that connect to the server or send packets? And how to block an ip that make packets flood and try to DDoS? Thanks. (1 Reply)
Discussion started by: [xEF]Danger
1 Replies

2. Red Hat

How to Multiple internet connections manage into a single connection.

Dear all, Hope you are all fine & enjoying your good health. Look at this equation 1+1+1=3 So simple I just want to say that I have three internet connections of 1mb, 1mb & 1mb but I can use only 1mb connection at a time & other two connections are useless for me. But now I want to make all... (0 Replies)
Discussion started by: saqlain.bashir
0 Replies

3. IP Networking

Bonding Internet Connections

I’m familiar with load balancing.. but Is it possible to actually bond multiple DSL lines together? I hear of ways to bond using MLPPP but that requires support from an ISP. Is there a way to actually bond without support from my ISP, or use say a cable modem and a DSL line together for faster... (0 Replies)
Discussion started by: harley313
0 Replies

4. Windows & DOS: Issues & Discussions

42 UDP internet connections

First I had a problem: My internet was slow, now I know why, I have opened 42 connections to internet. What can I do? Thanks, YourDestinity (1 Reply)
Discussion started by: YourDestinity
1 Replies

5. Ubuntu

Lost the log off, power down, etc. icon!

I had a purge of applications on my Ubuntu 8.10 install and lost the above mentioned icon from the toolbar, yes I know I should have left it alone! I have managed to find and install a shutdown icon and a separate shutdown, restart,etc icon uing the synaptic package manager but they are not the... (0 Replies)
Discussion started by: TonyFullerMalv
0 Replies

6. IP Networking

Aggregate two internet connections

Hi I have a question related to load balancing.I have two separate internet connections with 2Mbps speed and i would like to aggregate this two connections intro one connection with 4Mbps.Is it possible to do that, to put a Linux or Unix machine as a gateway?I read some stuff to split the... (3 Replies)
Discussion started by: tafil
3 Replies

7. IP Networking

Lost Connectivity to the Internet

I'm running FreeBSD 6.2 and suddenly lost connectivity to the net. After unplugging the router and checking all the connections I could find nothing wrong. All the driver software seems to be intact. I thought I would remove the driver software and restore it. However, when I go to root and type ... (5 Replies)
Discussion started by: Aaron Van
5 Replies

8. UNIX for Advanced & Expert Users

combining two internet connections

hey guys Do you guys know of a good way that I can combine and load balance my 2 Internet connections using a Linux or Bsd box? Would LVS be able to do this? Thanks in advance (1 Reply)
Discussion started by: arya6000
1 Replies

9. UNIX for Dummies Questions & Answers

dsl connections lost when attempting to retrieve mail from my server.

suse linux 6.4 im running and i have port 110 for pop and smtp open, i have set up some email addresses for my friends, but they recieve errors saying that relaying is denied. i know this is to prevent spamming software from using my domain to send spam, but how do i let my users send their mail?... (6 Replies)
Discussion started by: norsk hedensk
6 Replies
Login or Register to Ask a Question