#!/bin/bash
# Check the Service Status of Server and send notification mail if anyone is DOWN.
Server=192.168.0.35 ## IP of the remote Server to be monitored
ADMIN=hareeshvv@gmail.com ## Mail ID of Admin
Subject=Server-Status
DATE=`date +%d.%m.%Y`
TIME=`date +%H.%M.%S`
mkdir /tmp/$DATE.$TIME
cd /tmp/$DATE.$TIME
services=(http https mysql smtp pop imap imaps ssh) ## List of services to be checked
Watch () {
#nmap $Server | grep ${services[$i]} > /dev/null 2> /dev/null ## Use this one for Remote Server which is not behind any firewall
netstat -ntpl | grep ${services[$i]} > /dev/null 2> /dev/null ## Use this locally
if [ $? != 0 ]
then
echo ${services[$i]} is DOWN >> result
fi
}
for (( i = 0 ; i < ${#services[@]} ; i++ ))
do
Watch ${services[$i]}
done
grep DOWN result > /dev/null 2> /dev/null
if [ $? = 0 ]
then
count=`grep DOWN result | wc -l`
if [ ${#services[@]} = $count ]
then
echo "All Services are down" >> result
echo "Even the Server may be down" >> result
fi
mail -s $Subject $ADMIN < result
fi
rm -rf result
cd - > /dev/null
exit
Saturday, November 3, 2007
Subscribe to:
Post Comments (Atom)
AT&T USA | Internet not working | Fix by custom APN
If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...
-
Hi there, You all know how to check TCP port connectivity from a Linux or UNIX machine to a remote machine using telnet as per th exampl...
-
Before you start Ensure that you have installed wvdial, usbmodeswitch and usbmodeswitch_data # dpkg -l | grep wvdial # dpkg -l | grep ...
-
#!/bin/sh # Shell script to monitor the disk space,Memory,SWAP Usage and send an email to $ADMIN, if the free avilable percentage of space i...
No comments:
Post a Comment