Listing 4
#! /bin/sh -
#
# A simple sh script to "newping" a list of important hosts.
#
# Output goes to /dev/console
#
IMPHOSTS = polyslo phoenix blackbird zeus
TIMEOUT = 20
for HOST in $IMPHOSTS
do
newping $IMPHOSTS $TIMEOUT
CODE = $?
DATE = `date +"%m-%d-%y %H:%M"`
#
# Determine the appropriate English response.
#
case $CODE in
0) PHRASE=""
STATUS=""
1) PHRASE="No connection in $TIMEOUT secs."
STATUS="down";;
2) PHRASE="No response in $TIMEOUT secs."
STATUS="hung";;
3) PHRASE="Connection refused. "
STATUS="rebooting";;
4) PHRASE="Network unreachable from `hostname`."
STATUS="unknown";;
5) PHRASE="Host unreachable from `hostname`."
STATUS="unknown";;
*) PHRASE="Internal error."
STATUS="unknown";;
esac
if [ "$PHRASE" != "" ]
then
echo "$DATE:$SITE $PHRASE - ($STATUS)" > /dev/console
fi
done
|