OpenNetGuru

Thursday, Jul 29th

Last update:11:51:55 AM GMT

You are here: Developer Zone shell scripting Linux Script For Monitoring System network

Linux Script For Monitoring System network

E-mail Print PDF

The Unix shell is the main scripting environment of every Linux, Mac OS X and Unix system, whether a rescued laptop or a million-dollar mainframe.Among the more than 100 scripts included are an interactive calculator, a spell checker, a disk backup utility, a weather tracker, and a web logfile analysis tool. Here we can see UNIX / Linux Shell Script For Monitoring System network with ping command


# add ip / hostname separated by while space
HOSTS="http://opennetguru.com"

# no ping request
COUNT=1

# email report when
SUBJECT="Ping failed"
EMAILID=" This e-mail address is being protected from spambots. You need JavaScript enabled to view it This e-mail address is being protected from spambots. You need JavaScript enabled to view it "
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
# 100% failed
echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID
fi
done