[svlug] here is: how to ping a dead system

HvR hvrietsc at yahoo.com
Tue May 2 16:42:14 PDT 2000


i just wanted to share this with the list since you
folks helped me find the solution to my problem (ie
ping does not terminate on dead systems)

so assuming you install fping my script now reads:

#!/bin/sh
# alive
export PATH
PATH=$HOME/bin:/usr/bin:$PATH

HOSTS=$HOME/.alive.hosts	# format=<ip or name>
<whitespace> <description>
HOSTSUP=$HOME/.alive.up
MAILTO="root"	# who to email it to feel free to change
this ;-)

# make copy of last times results
UPTMP=/tmp/up$$
rm -fr $UPTMP
cp $HOSTSUP $UPTMP 2>/dev/null
> $HOSTSUP	# make new one

while read LINE
do
	set -- $LINE
	IP="$1"
	shift
	case "$IP" in
	\#*)	:	# ignore lines starting with #
	;;
	*)
		# get current status and record it (only ones that
are up)
		case `fping "$IP" 2>/dev/null` in
		*alive*)
			NEWSTATUS=UP
		;;
		*)	NEWSTATUS=DOWN
		;;
		esac;
		[ "$NEWSTATUS" = "UP" ] && echo "$IP UP on `date`"
>> $HOSTSUP
		
		#get old status
		OLDSTATUS=DOWN
		grep "$IP UP" $UPTMP >/dev/null 2>/dev/null &&
OLDSTATUS=UP

		if [  "$OLDSTATUS" != "$NEWSTATUS" ]
		then
			echo "$IP $NEWSTATUS `date +%H:%M` $@"  | mail
$MAILTO
		fi
	;;
	esac
done < $HOSTS

rm -fr $UPTMP
-----
the $HOME/.alive.hosts file looks like this (not
really):
yahoo.com    YAHOO to send email
svlug.org    SVLUG silicon valley linux user group
198.186.203.43 COOLSITE
-----
so i just stick the alive in a crontab job and now i
get emails when a system changes status, wooopie....

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/





More information about the svlug mailing list