On 2004.08.17 14:59 David wrote:
I'm using a cron script every minute to ping outside my network. The
address I'm using is one given to me for this purpose by my new
provider (Activ/Powertel).

#!/bin/sh
# first ping occassionally gives false reading. Second one confirms.
ping -c 1 xxx.xxx.xxx.xxx > /tmp/pingtest 2> /dev/null
if [ $? != 0 ] ; then
    date >> /tmp/pingtest
    mail -s "NETWORK TEST: failed first test" david < /tmp/pingtest
    ping -c 1 xxx.xxx.xxx.xxx >> /tmp/pingtest 2> /dev/null
    if [ $? != 0 ] ; then
        date >> /tmp/pingtest
        mail -s "URGENT: CHECK NETWORK STATUS" david  < /tmp/pingtest
    fi
fi

A few observations:

1. If you are getting many "false readings" then you should check your network.

2. Why not run the script as an endless loop rather than a cron job every minute.

3. You don't need the temp file -- use variables instead, and use pipes.

4. If your test fails twice you get two emails -- unnecessary. Try one message for failure on second attempt and a different message for success on second attempt.

HTH,
Robert
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to