SoloCDM wrote:
>
> I'm using the following to check for an unsuccessful ping, but if
> the line is open and bottlenecked enough to return a hundred percent
> loss, then the ping will return a false identity. Any suggestions?
>
> ping -c 4 -R mail.aculink.net > search-opening-data 2>&1;
^^
This will not work in every situation. For instance, using -R through my
LinkSys will give 100% loss.
BTW, here's a script which logs when my link, mail server or other target goes
down/up...
Pierre
#!/bin/bash --noprofile
#set -x
# This script watches for link outages between here and a remote host.
HOST="206.74.254.2"
COUNT=2 # increase counts to reduce log output from transient misses
SLEEP=10 # increase to reduce load on network
# --------------- end of user variables
check() {
PREV=$LINK
LINK=0
RC=`ping -c $COUNT $HOST | grep -c icmp_seq`
[ $RC -gt 0 ] && LINK=1
let SENT=$SENT+$COUNT
let MISSED=$MISSED+$COUNT-$RC
}
# override default if called with an arg
[ $1 ] && HOST=$1
LINK=0 # assume link initially down
PREV=0
STATE[0]="DOWN"
STATE[1]=" UP"
# first time through; check the link and log the starting state
check
echo "Starting: `date \"+%a %D %T\"`; Initial link state: ${STATE[LINK]}"
MISSED=0 # counters
SENT=0
# forever...
while [ 1 ]; do
check
[ $LINK -eq $PREV ] || {
echo "${STATE[LINK]}: `date \"+%a %D %T\"` ( $SENT sent; $MISSED missed )"
SENT=0
MISSED=0
}
sleep $SLEEP
done