Operating System - HP-UX
1823081 Members
3356 Online
109645 Solutions
New Discussion юеВ

Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

 
Alzhy
Honored Contributor

Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

Because of an architectural brouhaha - our UNIX servers now hosts thousands of printers. The way we've set up our printers is we use the Windows NT/2K servers and their defined queues (Print Services for UNIX) -- so all queuing for Windows and UNIX is done on the Windows side of the equation.

Sometimes, the Windows NT server serving the printers would go down or its UNIX printing service (LPD) would go down or it's DNS domain changes, etc...

Does anyone have a script created to inventory and report on the status of all the Printers defined on UNIX?

Thanks...



Hakuna Matata.
7 REPLIES 7
Mark Grant
Honored Contributor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

Nelson,

I am missing something here obviously but "lpstat -t" does a reasonably good job!
Never preceed any demonstration with anything more predictive than "watch this"
Abdul Rahiman
Esteemed Contributor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

Nelson,
I was wondering the same too..
# lpstat -p does a good job for me.
If you want to know abt. only problem printers, you may grep the output like this.
# lpstat -p | grep -v -E "idle|fence|printing"

If you want to go further, you could also ping the remote lpd host's ip address to see if they respond via a script like this.

cd /etc/lp/interface/
ls ps* | while read lp
do
echo $lp
lpstat -p$lp | grep -v -E "idle|fence|printing" >> /var/adm/printer_stat.log
host=`grep "PERIPH=" $lp |grep -v MODEL| awk -F"=" '{print $2}'`
ping $host -n 2 >> /var/adm/printer_stat.log
done

HTH,
Abdul.
No unix, no fun
Bill Hassell
Honored Contributor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

lpstat -t is always a problem. It does a query to all remote printers and it takes about 30 seconds to timeout for each printer on a dead server. The lpstat -p approach is better way and won't hang. However, here is a script that might solve all your print server problems:

rm -rf WindowsNT
install Linux
configure remote-printers
retrain WindowsAdmins

(sorry, I couldn't resist)


Bill Hassell, sysadmin
Joseph Loo
Honored Contributor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

hi,

the status of the network printer needs only the lpstat command.

# lpstat -o
tells u the print currently in queue.
# lpstat -t
tells u if the printers are enable.

i frequently use the above 2 options for lpstat and this command should suffice if u need a script as well.

regards.
what you do not see does not mean you should not believe
Alzhy
Honored Contributor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

Thanks for your suggestions so far. As I've mentioned, each of our UNIX servers is configured to have thousands of printers that are defined on Windows Hosts (for centralized queue administration, etc..). I need a report each early AM to summarize what printers have problems. I have the following already but it takes about 7 hours to finish:

for i in /etc/lp/interface/*;do
echo Checking `basename $i`
echo =========================================================================

PRT=`basename $i`
lpstat -o${PRT} 2>&1 |egrep "unknown|waiting|down|bus">/dev/null

if [ $? -ne 0 ];then
echo $PRT is down|tee -a DOWN_PRINTERS
fi

done


Hakuna Matata.
Sherin T. George
Occasional Visitor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

Replacing
lpstat -o${PRT} 2>&1 |egrep "unknown|waiting|down|bus">/dev/null

with

rlpstat -d${PRT} -u 2>&1 |egrep "unknown|waiting|down|bus">/dev/null

might give a better performance.
Sherin T. George
Occasional Visitor

Re: Printer Monitoring Script - to report on Status - down, unresponsive Print Server, etc...

One more point,
if you are interested only in remote printers you can query the directory /var/spool/lp/sinterface instead of /var/spool/lp/interface.