09.12.2012 Views

Understanding the network.pdf - Back to Home

Understanding the network.pdf - Back to Home

Understanding the network.pdf - Back to Home

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

echo $size-Bit Loss Statistics > $temp/head.temp<br />

# Generate Report<br />

cat $temp/head.temp $logfile.rept > $logfile.$size<br />

rm $logfile.t $logfile.rept $temp/head.temp<br />

#<br />

# End of <strong>the</strong> Check Script Command Section<br />

# report mailer section<br />

cat $temp/load.data.* > $logfile<br />

cat $logfile | mail -s " Packet Loss Report from $target" $mailtarget<br />

# End Of Script<br />

For performing host moni<strong>to</strong>ring, ping can be used in a script <strong>to</strong> periodically send<br />

messages <strong>to</strong> a group of hosts. This example also runs as a UNIX Cron job. It sends<br />

a set of ICMP messages <strong>to</strong> a set of hosts. If <strong>the</strong> hosts fail <strong>to</strong> send an ICMP<br />

echo-request, <strong>the</strong> script sends an email notice. This script works well for off-site<br />

notification if you have <strong>the</strong> capability <strong>to</strong> receive email on your pager.<br />

#!/bin/sh<br />

# This is a simple ping check script that is run from a UNIX<br />

# cron job. Ideally, you want <strong>to</strong> run this script on two different<br />

# hosts that can send mail alerts in <strong>the</strong> event of a host failure.<br />

#<br />

# To have <strong>the</strong> script run every five minutes, use <strong>the</strong> following Cron<br />

# entry.<br />

#<br />

#0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/etc/ping.sh<br />

#<br />

#Enter <strong>the</strong> hosts you want <strong>to</strong> ping here. The host entry can be an<br />

# IP address or hostname. Entries should be separated by a space.<br />

hosts="testhost testhost2 192.168.33.1"<br />

# Enter <strong>the</strong> paths for ping and mail for your UNIX environment here.<br />

ping=/bin/ping<br />

mail=/usr/bin/Mail

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!