simple script to alert if internet not working?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting simple script to alert if internet not working?
# 1  
Old 06-13-2010
simple script to alert if internet not working?

Hi,

I am constantly automaticaly downloading a few things on the internet but since my internet connection is unstable, it sometimes wont work. Thing is the internet will appear to be connected, but no website can be accessed and no program can successfully connect to any location. I can fix this issue once detected by turning adsl modem off and on.

So I want to write a program that detects this. So say, every 5 minutes, checks to see if internet works. I was thinking it would prob just run something like "ping www.google.com" every 5mins and if it doesnt work (ie if it cant get any information from google), it will run some file (like a mp3, to alert me).

Problem is ping keeps gettin data requests nonstop from looks of it. so how would i go about doing this? i have never done shell scripting so i dont really know how? if anyone could help me with a solution that would be great. I am using cygwin under win xp.
# 2  
Old 06-14-2010
How about just doing a wget on a web page. Alert only when wget fails.
# 3  
Old 06-14-2010
Quote:
Originally Posted by fuzzylogic25
Problem is ping keeps gettin data requests nonstop from looks of it.
Not necessarily - a snippet I'm using here and there:

Code:
ping -c 1 $server > /dev/null 2>&1
if [ $? -ne 0 ] # "ping to nirvana"
then
  $alert
  exit 1
fi

($server = your provider's DNS; $alert = your mp3 player)
# 4  
Old 06-14-2010
i dont seem to have the -c feature for my ping.

It says:

Usage: ping [-dfqrv] host [packetsize [count [preload]]]
# 5  
Old 06-15-2010
whats your OS? and version??

I did a script just like this a few years back.

my design was to ping three high profile sites that had good uptime. (google, yahoo and cnn.com)
as long as two of the pings worked then we called the internet good.


if the internet was "bad" and two or more ping failed, then it called a script that did a telnet to the ADSL modem and issueing a reboot command.
then re-testing internet 2 minutes later.



this whole script was then in cron for every 15 minutes.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filesystem alert shell script not working!!

Hi All, My below shell script is not capturing %used value in the filesystem alert in the subject of the mail alert: Code: #!/bin/bash export DBALIST="abc@xyz.com" df -k /oradata/xyz/archive > dfk.result archive_capacity=`awk -F" " '{ print $5 }' dfk.result|grep -i %| cut -c 1-4` if... (6 Replies)
Discussion started by: harveyclayton
6 Replies

2. Shell Programming and Scripting

Simple sftp script not working - Please help

I have the below sftp script to transfer a file from a linux host(source) to another linux host(target). Public key is already set up in target host and I am able to transfer file using sftp from source to target. But not sure why the below script(ftp_script) is not working. Any help in this... (3 Replies)
Discussion started by: Armaan
3 Replies

3. Shell Programming and Scripting

[Solved] Simple script not working- for loop

Hi all, Please guide me writing this script Follwing is the file which I have created, which contains the files to be copied. cat system1-dr.txt /etc/passwd /etc/shadow /etc/group /etc/vfstab /etc/profile /etc/default/init /etc/shells /etc/dfs/dfstab /etc/dfs/sharetab... (11 Replies)
Discussion started by: manalisharmabe
11 Replies

4. Solaris

Internet not working on Solaris 10

hi , i have install solaris 11 on my server and using vm virtual box i have install solaris 10 on it. But on solaris 10 my internet is not working. From my base OS solaris 11 internet is working fine but not on solaris 10. for testing purpose i have also install another os centos on Virtual... (2 Replies)
Discussion started by: zeeshan047
2 Replies

5. Shell Programming and Scripting

Filesystem alert shell script not working!!

Hi All, My below shell script is not capturing %used value in the filesystem alert in the subject of the mail alert: #!/bin/bash export DBALIST="abc@xyz.com" df -k /oradata/xyz/archive > dfk.result archive_capacity=`awk -F" " '{ print $5 }' dfk.result|grep -i %| cut -c 1-4` if ] then... (5 Replies)
Discussion started by: a1_win
5 Replies

6. Shell Programming and Scripting

simple cgi script not working

hi all, i have installed simple cgi-script under apache/cgi-bin directory hello.cgi #!/usr/bin/perl print "Content-type: text/html\n\n"; print <<END_HTML; <html> <head></head> <body>Hello, World!</body> </html> END_HTML when i hit the url... (6 Replies)
Discussion started by: raghur77
6 Replies

7. Shell Programming and Scripting

Simple BASH script not working?

So I need a script that does the following: If a certain user is logged in Run `command` Else Echo “incorrect user” This is my first stab...which doesn't work: #!/bin/bash X="user=`ls -l /dev/console | cut -d " " -f 4`" Y="foobar" echo $X echo $Y (4 Replies)
Discussion started by: doubleminus
4 Replies

8. Shell Programming and Scripting

simple script to alert of archive logs filling

Hi all. I am not a DBA. But I do have responsibility for making sure the archive logs dont fill up and cause the database. This happend the other day while I was absent (sick) and I got a good ticking off for it. Needless to say I dont want this happen! Could anyone lend a hand to a... (8 Replies)
Discussion started by: Incremental
8 Replies

9. Shell Programming and Scripting

simple perl script not working

why won't below work? I am trying to see a)sipfile has username of the system. b)it will read the sipfile and do a grep function against the /etc/passwd c)it will save that output to /tmp/result.. but my script is just hanging... #!/usr/bin/perl -w open(SIPFILE, "</tmp/sipfile") ... (4 Replies)
Discussion started by: hankooknara
4 Replies

10. Shell Programming and Scripting

Why this simple script, is not working ?

Hi everybody I want to create 20 file using simple script - listed bellow-. But the script doesn't work. I hope anyone guide me to correct this script ---------------- The script integer number=01 until (($number==21)) do >TELE-LOG-$number number=$number+01 echo $number done exit... (4 Replies)
Discussion started by: so_friendly
4 Replies
Login or Register to Ask a Question