LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2022, 02:06 PM   #1
Ml9xLi6kvpVZ09r
LQ Newbie
 
Registered: Oct 2009
Posts: 9

Rep: Reputation: 1
ISO Simple, dependable way to monitor ISP's down time


With this winter weather my ISP service can go to crap some days. I'm a very amateur BASH script butcherer and I decided to put something together to record my connection down-time. Here's what I've got so far. It seems to work OK. So far today my WIFI has dropped for a brief second or so three times. I tossed the script onto my wife's PC and I'll check it later to see how it does on her's. I'm on an ASUS laptop with WIFI only and my wife is on an All-In_One on just ethernet.
Anyone see any problems with this or ways to do it better or to make this work better?

Code:
while [ 1 ]
do
wget -q --spider 'https://www.google.com/'
status=$?
# 0 is UP, 4 is DOWN
[ $status -eq 4 ] && TIME_NOW=`date -R` && echo "   DOWN    $TIME_NOW"  >> ""${HOME}"/Bash_Scripts/IP-Up-Down_Time.log"
sleep 5
done;
 
Old 02-04-2022, 07:03 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
I would just use fping or ping to check connectivity versus wget but the result is the same.
 
Old 02-04-2022, 10:14 PM   #3
Ml9xLi6kvpVZ09r
LQ Newbie
 
Registered: Oct 2009
Posts: 9

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by michaelk View Post
I would just use fping or ping to check connectivity versus wget but the result is the same.
Thank you, I'll take a look at ping.
 
Old 02-05-2022, 08:30 AM   #4
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,152
Blog Entries: 6

Rep: Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835Reputation: 1835
Code:
while :; do
    ping -c1 8.8.8.8
    if [ "$?" == 0 ]; then
        echo "Good"
    else echo -e "Down at:\n$(date -R)\n" >> file.log
    fi
    sleep 60
done
You could test that with 8.8.8.9

I would not ping google every 5 seconds.
 
Old 02-05-2022, 08:49 AM   #5
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,177

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
I used a tool to log outages and do a traceroute, but I forgot the name. Did some googling and found MTR which looks closes to what I was using. https://en.wikipedia.org/wiki/MTR_%28software%29

edit: looks like it is in Debian repos, so "apt install mtr"

Last edited by uteck; 02-05-2022 at 08:52 AM. Reason: edit
 
  


Reply

Tags
bash script, isp, monitor



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Embedded Linux as Dependable for Developers as RTOSes, says Embedded Market For LXer Syndicated Linux News 0 01-23-2008 11:40 AM
I'm looking for a dependable KVM switch JerryP Linux - Hardware 6 02-05-2007 05:52 PM
need dependable raid controller Rian8605 Linux - Hardware 6 08-15-2006 02:57 AM
LXer: Microsoft: Linux not 'reliable or dependable' LXer Syndicated Linux News 0 05-22-2006 10:33 PM
LXer: Microsoft: Open source 'not reliable or dependable' LXer Syndicated Linux News 0 05-21-2006 07:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration