Fix broken intending (The whole file use spaces only except my last patch and 1-3...
[monitoring-plugins.git] / contrib / aix / check_queue
blob9f709c548252791c6b7358cb93cf94d9bc3999c6
1 #! /bin/sh
3 #===============================================================
4 # Print Queue Checker
6 # The print queue checker simply looks for an occurance of a
7 # DOWN queue. A note of warning, if you use remote queues in
8 # AIX to redirect print jobs from the AIX queue to an NT print
9 # server that print through DLC rather than IP, it will be very
10 # s - l - o - w. But it will work.
12 # Author: TheRocker
13 # Email: therocker@pawprints.2y.net
14 #===============================================================
16 TMPFILE=/tmp/qtmp.hndl
17 TMPTOO=/tmp/qtwo.hndl
19 #=======================================================================
21 # This script will also work on AIX 4.2.1 BUT you have to change
22 # the following line. AIX 4.2.1 does not support the -W option
23 # with lpstat. For AIX 4.2.1 just remove the -W option and it should
24 # work just fine.
26 #=======================================================================
28 `rsh $1 -l root lpstat -W | grep -e "DOWN" | tr -s ' ' | cut -d' ' -f1,3 > /tmp/qtmp.hndl 2> /tmp/q_err`
30 if [ -s $TMPFILE ]
31 then
33 #=======================================================
35 # If you've seen the other AIX scripts I wrote you may
36 # notice that I use this bit of code a lot. Well it
37 # works and appears to be all purpose.
39 #=======================================================
41 LINES=`wc -l /tmp/qtmp.hndl | cut -c8`
42 LINESCTL=`wc -l /tmp/qtmp.hndl | cut -c8`
44 echo "Print Queue DOWN --> \c"
46 while [ $LINESCTL != 0 ]
49 cat $TMPFILE | tail -$LINESCTL > $TMPTOO
50 cat $TMPTOO > $TMPFILE
51 LINESCTL=$(( $LINESCTL -1 ))
52 LINES=$(( $LINES -1 ))
53 DATA=`head -1 /tmp/qtmp.hndl`
54 echo "( $DATA ) \c"
57 done
59 echo "\n"
61 rm -f $TMPFILE
62 rm -f $TMPTOO
63 exit 2
66 echo "Print Queues Running... OK"
67 exit 0