Environment: Oracle database, HPUX
Description: This script polls key devices on network and emails when they can not be reached.
Code Listing:
# File: ping_advise [p_adv]
# Purpose: ping device and advise of failures
# Author/Date: Robert Lawson 09-NOV-1996
#
# Technique: ping IP address, write results to file, see if null (failed)
# Notes: this script will fail on not detecting an IP address, so you
# to restart you must?????
#
PROG_NAME=ping_advise # name of script
MAIL_USER=roblaw # whom to send email to
SLEEP_LIMIT=60 # pause number of seconds
# do ping, parameters are:
# 1 passed IP address to ping
# 2 passed common name for IP address
# 3 passed name to send mail to
# ? returned 0=OK, 1=failed
function ping_em
{
echo "Processing IP_ADDRESS = $1 for $2"
rm $PROG_NAME.tmp
/etc/ping $1 64 1grep '1 packets re'>$PROG_NAME.tmp
if [ -s $PROG_NAME.tmp ]
then
echo "passed"
return 0
else
echo "failed"
cat > $PROG_NAME.tmp
mail $3 <$PROG_NAME.tmp return 1 fi } # main loop while true do ping_em "192.1.1.254" "CA ROUTER" "$MAIL_USER" if [ $? -eq 1 ] then break fi ping_em "192.1.2.254" "FL ROUTER" "$MAIL_USER" if [ $? -eq 1 ] then break fi ping_em "192.1.2.253" "JUNK" "$MAIL_USER" if [ $? -eq 1 ] then break fi sleep $SLEEP_LIMIT done
No comments:
Post a Comment