Implicit Ping

Hi All

I want some help in writing a script that will:

  1. Implicitly ping a server to see if it is up or not. (I have blocked all ICMP traffic on that box)
  2. if the server is down send an alert mail to users

I have looked and looked but I could not get any way to do this. What I have thought of doing is:

  1. Send an email to a particular user on the host box every 15 mins.
  2. Have a script on the host to check the mailbox every 15 mins and delete that message.
  3. If there is no mail in the mailbox... send the alert.

This will accomplish the implicit ping. But:
a. Is there a way to do this using shell/ perl scripts? - 2-3
b. Are there some security concerns in this kind of a solution?
c. Is there some other way I could accomplish implicit pinging of the server?

Any advise would be appreciated!

regards

KS

There are myriad ways to do this at the application level. Most are actually better (from an information management) than ping because they use information at a higher level in the protocol stack.

You can either using (1) polling or (2) sending a trap. Ping is an example of a polling technique. An SNMP trap is an example of a trap, obviously.

Both have advantages and disadvantages.

One of the best way is to do a rsh to the client.
Pinging -> Does not eliminate the possibility that the server id down at ok promp but network is alive.

If you have security concern regarding rsh, you can use ftp to do that.

You can check use .netrc to search google on how to automate ftp or look at my monitoring script below...

#!/bin/ksh
#
# Created: Steven Koh on Apr 1st 2004
# Last Amended: Steven Koh on Apr 1st 2004
# Last checked: Steven Koh on xxx
#
# Solaris Monitor Ftp Script
# Purpose: Monitors servers via use of the ftp command
# and notifies via email.
# Usage: Execute from crontab every 15 minutes.
# Dependencies: $HOME/.netrc
# Outputs: E-mail, SNMP
#***************************************************

CONF_FILE=/usr/local/scripts/monitor.conf

SCRIPTDIR=`grep "SCRIPTDIR" $CONF_FILE | awk -F= '{print $NF}'`

# The directory this script resides in
ADMINDIR=$SCRIPTDIR/monitorFTP

MAILADD=$LOGNAME@localhost
SMS_LIST=$HOME/sms.List

# Define the hostname of the server
SRVNM=`uname -n`

# Define the hostname of the SNMP server
SNMP_SRV=`grep "SNMP_SRV" $CONF_FILE | awk -F= '{print $NF}'`
SEND_TRAP=`grep "SEND_TRAP" $CONF_FILE | awk -F= '{print $NF}'`
SEND_SMS=`grep "SEND_SMS" $CONF_FILE | awk -F= '{print $NF}'`

touch ftp.test
grep machine $HOME/.netrc | awk '{print $2}' > $HOME/mon_ftp.dat

grep -v "#" $HOME/mon_ftp.dat |
while read -r SRVNM
do
echo "put ftp.test" | ftp $SRVNM

if test `echo "ls ftp.test" | ftp $SRVNM | grep -v "No such file or directory" | grep -c ftp.test` -ne
1; then

 echo "Unable to FTP to $SRVNM"

 \# Wait 1 min before checking again
 sleep 60

 if test \`echo "ls ftp.test" | ftp $SRVNM | grep -v "No such file or directory" | grep -c ftp.test\` \-

ne 1; then

 echo "Unable to FTP to $SRVNM"

  mail $MAILADD <<EOF

From: $0
To: $MAILADD
Subject: Unable to FTP to $SRVNM

Unable to FTP to $SRVNM

EOF

# Sending SMS
$SEND_SMS $SMS_LIST "FTP001_$SRVNM: Unable to FTP to $SRVNM. Check if network/ftp is down"

fi
fi

done
exit 0