#!/bin/sh

# The variables are self explanatory
# Touch /tmp/BOOM if you are working on the problem and you don't want the PO 
# to keep paging you
#
# But!  Remember to rm it when you are done
#
# ...and while you are at it, remember to chown pop the poboxes

PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin:/bin/athena:/usr/athena/bin:/afs/net/tools/@sys; export PATH
KRBTKFILE=/tmp/pomon; export KRBTKFILE 
hostname=`hostname`
monitor=/usr/spool/pop
interval=3600
full=85

if test `df $monitor | tail -1 | awk '{print $5}' | sed -e 's/%$//'` -gt $full
then
	logger -p auth.error "$monitor is greater than $full% full" 
	if test  ! -f /tmp/PULL -a   ! -f /tmp/BOOM 
        then
		(touch /tmp/PULL ; sleep $interval ; rm /tmp/PULL) & 
		kill `ps gax | grep 'accepting connections' | awk '{print $1}'`
		krbtgp -s rcmd.$hostname
		df $monitor | zwrite -c network -i pomonitor
		beep network mrat -m "$hostname is greater than $full%" > /tmp/page.out 2>&1
		logger -p auth.error `tail -1 /tmp/page.out`
 		rm /tmp/page.out
		kdestroy
	fi
fi

