Try this. I put this on the crontab to run every hour and the results e-mailed. I need to set it up so it only e-mails me when queues were actully down but you could easily remove this step if you didn't want it to send you e-mail.
#!/bin/ksh
#
#
DATE=`date`
THISHOST=`uname -n`
lpstat|grep DOWN|awk '{print $1}' >> /tmp/lpstat.$$
for i in `cat /tmp/lpstat.$$`
do
enable $i
done
echo "The date/time is $DATE." >> /tmp/lpstat.$$
echo "\nThese queues were DOWN and have been enabled." >> /tmp/lpstat.$$
mail -s "$THISHOST Printer Status" your@email.com < /tmp/lpstat.$$
sleep 10
rm -f /tmp/lpstat.$$
if test -s /tmp/lpstatdown.log
then
for i in `cat /tmp/lpstatdown.log`
do
enable $i
done
echo "The date/time is `date` " >> /tmp/lpstatdown.log
echo "\nThese queues were DOWN and have been enabled." >> /tmp/lpstatdown.log
mail -s "$THISHOST Printer Status" root@localhost < /tmp/lpstatdown.log
sleep 10
rm -f /tmp/lpstatdown.log
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.