Re: Server monitoring script
From: Peter Boosten (niemand_at_nergens.loc)
Date: 04/07/04
- Next message: kb: "Please help with 'cut' command!"
- Previous message: Jess: "Server monitoring script"
- In reply to: Jess: "Server monitoring script"
- Next in thread: Jess: "Re: Server monitoring script"
- Reply:(deleted message) Jess: "Re: Server monitoring script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 7 Apr 2004 07:05:05 +0000 (UTC)
on Wed, 07 Apr 2004 at 06:48 GMT, Jess wrote:
> How can I use ping in a shell script to check if a server is responding or
> not?
>
> for example
>
> If get reply from ping -t 5 192.168.0.4 then
>
> do nothing
>
> else
> send email to webmaster@xxx.com
>
> fi
>
> One of my servers keeps crashing, it is a slackware linux server
>
> I want to use one of thre uix servers to check every 20 mionutes if it is up
> and if not, notify by email
>
> Thanks
> Jess
>
>
#!/bin/sh
#
# $Id: conchk,v 1.5 2003/02/02 19:02:04 peter Exp $
#
# Connectivitycheck for multiple hosts
#
# Author: Peter Boosten
#
HOSTS="host1 host2"
for host in ${HOSTS}; do
status=`ping -c 2 ${host} > /dev/null && echo 1`
if [ "${status}" = 1 ]; then
if [ -f /tmp/${host}.not ]; then
rm /tmp/${host}.not
echo "${host} online again `date '+%H:%M %d-%m-%y'`" \
| mail -s "connectivity update" peter
fi
else
if [ -f /tmp/${host}.not ]; then
echo "do nothing" > /dev/null
else
touch /tmp/${host}.not
echo "${host} offline on `date '+%H:%M %d-%m-%y'`" \
| mail -s "CONNECTIVITY ALERT" peter
fi
fi
done
Regards, Peter
-- Monday is an awful way to spend one seventh of your life. MSN/Mail: pboosten at hotmail dot com
- Next message: kb: "Please help with 'cut' command!"
- Previous message: Jess: "Server monitoring script"
- In reply to: Jess: "Server monitoring script"
- Next in thread: Jess: "Re: Server monitoring script"
- Reply:(deleted message) Jess: "Re: Server monitoring script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|