Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

down queues

Status
Not open for further replies.

Aaron1940

MIS
Dec 14, 2000
27
0
0
US
How can I sort out only the LPD queues that are DOWN when I LPSTAT?

Thanks
 
This is not a good solution, but it might for what you're doing.

qchk -A | grep -i down
 
Here's a quick and dirty hack that will give you all the status info you'd normally get:

Code:
for prt in `lsallq`
do
stat=`lpstat -p$prt`
echo "$stat" | grep -i down > /dev/null 2>1 && echo "$stat"
done

I have a parallelized lpstat that uses expect around here somewhere, which runs faster because the down printers with lost connections (we have a lot on terminal servers) all get to timeout in parallel. I can post it if you're interested, but expect isn't in the base operating system, it has to be installed from bullfreeware, the Linux Toolbox, or the like.

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
We have a similar situation with lost connections on some of our printers. Normally I run a

lpstat | grep DOWN

but waiting for the printers to time-out takes forever. I am interested in your script please.

THX
 
wraheem,
I dont think the script will make a difference. When the queue is queried it will take time to return a value as well.
 
Try

qchk -A -W | grep DOWN |awk '{ print $1 }'


That is from a script I've got running from cron. It checks the queue and if it finds it DOWN, it will restart it. It the queue is DEV_WAIT, it will send an email to someone to check on it.

If you're intersted, I can post the code.
 
wraheem - sorry I took so long to check back in. I'll post the script, but it's uncommented (okay, I'll add a few) and requires expect

AlbertAquirre - this script makes a difference as soon as you have two remote queues in the DOWN state. Instead of waiting for them to timeout sequentially, which you must with "lpstat -a", they timeout in parallel.

Code:
#!/usr/local/bin/expect

# remove the leftmost element of a list and return it 
# this function should really be a part tcl
proc pop {lname} {
upvar $lname lst
set tmp [lindex $lst 0]
set lst [lreplace $lst 0 0]
return $tmp
}

# don't show the user the ugly workings
log_user 0


# build a list containing all queue names
set printers {}
spawn lsallq
while {1} {
        expect {
                -re "(\[^\r]*)\r\n" {lappend printers $expect_out(1,string)}
                eof {
                        wait
                        break
                        }
                }
        }

set printers [lsort $printers]

# launch up to 30 lpstat processes in parallel.
# Many more, and you start hitting the per user
# process limit (lpstat spawns several processes of
# its own).

set lpstatids {}
for {set count 0} {$count < 30} { incr count} {
spawn lpstat -p[pop printers]
lappend lpstatids $spawn_id
}


# run through the spawned processes, showing their 
# output. As each dies, spawn one of the remaining
# printers, if any.

while { [llength $lpstatids] > 0 } {
        set spawn_id [pop lpstatids]
        log_user 1
        expect eof
        log_user 0
        wait
        if { [llength $printers] > 0 } {
                spawn lpstat -p[pop printers]
                lappend lpstatids $spawn_id
                }
        }

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
WHy are they going down so frequently? Have you made your rembak with a timeout? rembak -T999 will keep the connection open for 999 minutes when there is a problem.
 
To set the rembak period - vi edit the /etc/qconfig file and append -T999 to the rembak line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top