Wikis - Page

Simple Watchdog for iPrint

0 Likes

This script uses curl to download the http://servername/ipp page, and then uses that to decide whether ipp is running as it should or not, with a simple if statement to see if the page contains any html code.



The reason we need to pick a particular printers page is that it's possible to get at the page in some instances, but not at any of the printers.



The restarts are logged to /var/log/messages with the time and date of the restart.



Save this script as /usr/bin/ipp-dog and edit /etc/crontab and add the line below. It's possible to have it run more often, but as this happens rarely for us it's not a matter of seconds if things clear up by itself. Just as long as it gets fixed in a timely manner. This line makes the watchdog look at the service each 5 minutes.



I know it's a very crude script but it works and is an order of magnitudes easier than fail over.



*/5 * * * *  root   /usr/bin/ipp-dog


/usr/bin/ipp-dog 
------>8-----------
#!/bin/bash
curl http://yourserverdnsnamehere/ipp/someprinter > /tmp/ipptest
COUNT=`grep PCLXL /tmp/ipptest | wc -l`
if [ $COUNT = 0 ]
then
echo "Iprint is restarting at `date`" >> /var/log/messages
/etc/init.d/novell-ipsmd restart
else
echo "Iprint is running." >> /var/log/messages
fi
------>8------------

Labels:

How To-Best Practice
Comment List
Related
Recommended