#!/bin/sh # #File: /u/kscott/www/work/triage/check_rooms #Author: K. Scott Rowe #Time-stamp: <01/20/1998 08:41:20 kscott@prism> . /u/triage/conf/triage.conf USAGE="Usage: `basename $0`" echo "`date`" > /tmp/rooms.all echo "`date`" > /tmp/rooms_down.all CheckRoom() { UP=0 DOWN=0 echo "-------------------- ${x} --------------------" echo "-------------------- ${x} --------------------" >&2 # for down only for y in `netg ${1}` ; do ping ${y} > /dev/null 2>&1 if [ "$?" = "0" ] ; then echo "${y} is up" UP=`expr 1 + ${UP}` else echo "${y} is DOWN" echo "${y} is DOWN" >&2 # for the down only report DOWN=`expr 1 + ${DOWN}` fi done echo "" >&2 # for down only echo "" echo "Up: ${UP} Down: ${DOWN}" echo "" } for x in ${ROOMS} ; do CheckRoom ${x} > /tmp/${x} 2> /tmp/${x}_down if [ "${DOWNONLY}" != "1" ] ; then ypmatch ${x} hosts > /dev/null 2>&1 if [ "$?" = "0" -a "${PRINT}" = "1" ] ; then lpr -P${x} /tmp/${x} else lpr -Pspeare5 /tmp/${x} fi fi cat /tmp/${x} >> /tmp/rooms.all cat /tmp/${x}_down >> /tmp/rooms_down.all done /usr/ucb/mail -s "rooms.ascii" ${MAILTO} < /tmp/rooms.all /usr/ucb/mail -s "rooms_down.ascii" ${MAILTO} < /tmp/rooms_down.all