Here's a simple Z Shell script to check for network connectivity. If you have several dozen workstations, manually pinging each one can be a laborious task. This script pings (w/2 second timeout) and mails the results to a group alias. You can automate by scheduling it with a cron job.
# vi pinger.zsh
#!/bin/zsh
log=/tmp/log.`date '+%d%h%Y%H%M'`
echo >> $log
date >> $log
echo >> $log
for i in {1..30}
do
ping wkstn$i 2
if [ $? = 0 ]
then
echo wkstn$i up >> $log
else
echo wkstn$i down >> $log
fi
done
cat $log | mailx -s "Workstation Status: `basename $log`" groupalias@esofthub.com
#rm $log
:wq!
This blog covers Unix system administration HOWTO tips for using inline for loops, find command, Unix scripting, configuration, SQL, various Unix-based tools, and command line interface syntax. The Unix OS supports tasks such as running hardware, device drivers, peripherals and third party applications. Share tips/comments. Read the comments. But most importantly: Read Disclaimer - Read Disclaimer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment