BrianTX
(Korg Regular)
2002-10-04 04:01 PM
detecting "Printer Busy or Error"

We have multiple LPR queues on multiple NT 4 servers. Occasionally, I get requests to purge the print jobs from the queue. It would be nice to have a script running that checks for stuck print queues via ADSI about once every 15 minutes. Unfortunately, I am unsure how to pull the data "Printer busy or error" that is on the print job when it is "stuck" in the queue. I tried checking the status of the print job with ADSI, but I get back "16" which translates to "Printing". I have been unable to retreive the information "Printing - Printer Busy or Error"..

I suppose I have lazy admin-itis. I would just like to have "stuck" queues automatically cleared, and be emailed if the ip for the LPR printer cannot be pinged. Any ideas?

Brian


Radimus
(KiX Supporter)
2002-10-04 04:13 PM
Re: detecting "Printer Busy or Error"

get kixomatic, and check out win32_printJob

you will probably have to write a script that checks all your connected printers (you will have to connect to all printers you want to monitor)

then use AT or Soon to schedule the script to run and then reschedule itself

[ 04. October 2002, 16:13: Message edited by: Radimus ]


BrianTX
(Korg Regular)
2002-10-04 04:38 PM
Re: detecting "Printer Busy or Error"

Hmm. Well, the JobStatus works on my local PC... the only problem is that I don't have WMI installed on my Windows NT 4.0 print servers at this point.

Brian


Sealeopard
(KiX Master)
2002-10-04 04:40 PM
Re: detecting "Printer Busy or Error"

Then it's about time. WMI makes remote management/monitoring a lot easier and there are already a couple of scripts posted that deploy WMI on Windows 9x/NT.

BrianTX
(Korg Regular)
2002-10-04 04:44 PM
Re: detecting "Printer Busy or Error"

I don't need a script to deploy WMI... I just need to install without reboot.. can't have servers down with 60 print queues on each.

Brian


Radimus
(KiX Supporter)
2002-10-04 04:47 PM
Re: detecting "Printer Busy or Error"

I don't think you really need it on the servers, if you can see the status on your machine, and you have permissions to do so, your PC can kill the job.

BrianTX
(Korg Regular)
2002-10-04 04:54 PM
Re: detecting "Printer Busy or Error"

I can't see it on my PC unless I map to every printer (over 300) which I'm not going to do.
Also, Microsoft sure makes it hard to find WMI for NT on their site.. I suppose I could use the version intended to be installed with SMS on their ftp site.

Brian


BrianTX
(Korg Regular)
2002-10-04 04:59 PM
Re: detecting "Printer Busy or Error"

Ok.. i found it.. had to dig, though... Microsoft is trying hard not to support NT 4 anymore..

http://www.microsoft.com/downloads/release.asp?ReleaseID=18490

Brian


Les
(KiX Master)
2002-10-04 05:02 PM
Re: detecting "Printer Busy or Error"

Well... if it's NT4 you need to reboot once a week anyway so just schedule the WMI install to coincide.

BrianTX
(Korg Regular)
2002-10-04 05:05 PM
Re: detecting "Printer Busy or Error"

We do fine with once a month reboots... print servers almost never have issues.

Brian


Les
(KiX Master)
2002-10-04 05:24 PM
Re: detecting "Printer Busy or Error"

Talk about lazy admin-itis...

I just bring up the detail view of the "Printers" share on my Win2K print server and the status, # of docs, etc. is right there with my choice of sort order.

Then there's the users... they call the HelpDesk after they tried ten times to print...


BrianTX
(Korg Regular)
2002-10-04 06:07 PM
Re: detecting "Printer Busy or Error"

Yep.. that's what I've been doing.. I'd rather just automagically catch these jobs that won't print.

Brian


BrianTX
(Korg Regular)
2002-10-04 06:42 PM
Re: detecting "Printer Busy or Error"

Okay.. I came up with a convoluted script that seems to work.. lol.. I may have to redo this to make it simpler.

code:
break on
$cpname="servername"
$objcomp=GetObject("winmgmts:{impersonationLevel=impersonate}!\\$cpname")
$objjob=$objcomp.EXecQuery("Select * From Win32_PrintJob Where JobStatus='Printer Busy or Error'")

For each $job in $objjob
$printername=SPLIT($job.name,",",1)[0]
$sharename=$objcomp.Get("Win32_Printer='$printername'").sharename
$sharename ?

$objpq=GetObject("WinNT://$cpname/$sharename")
$objpq.Purge
@error
If @error = 0
? "All jobs cancelled for " + $printername + "."
Else
? "Purge failed for " + $printername + "."
Endif
Next

Brian


Les
(KiX Master)
2002-10-04 07:19 PM
Re: detecting "Printer Busy or Error"

Wonder if I'm adding complexity where none is needed...

Wouldn't you need to have some sort of timing loop to allow for "Normal" occurrences of these conditions?

I haven't tested the code but would not want to be too quick to delete all jobs from the Q.


Radimus
(KiX Supporter)
2002-10-04 07:49 PM
Re: detecting "Printer Busy or Error"

well, I'd use SOON.EXE from the reskit and have it schedule itself to run every 15 or 20 minutes.

BrianTX
(Korg Regular)
2002-10-04 07:49 PM
Re: detecting "Printer Busy or Error"

I'm only deleting jobs that are filtered with:

"Printing - Printer Busy or Error"

But, yes.. I have thought of that.. I'm actually thinking of listing the particular job, when it was created, etc, then asking the user whether or not to purge the queue. ADSI is much better for this, but WMI is more feature rich, so after I find out which job gets the error from WMI, I can pass everything to ADSI for simplicity. (I haven't gotten that far, yet, though)

Brian


Chris S.
(MM club member)
2002-10-04 08:11 PM
Re: detecting "Printer Busy or Error"

What about using WIN32_Printer instead of WIN32_PrintJob?

"Select * from Win32_Printer Where PrinterStatus = '1' or PrinterStatus = '2'"


BrianTX
(Korg Regular)
2002-10-04 08:47 PM
Re: detecting "Printer Busy or Error"

Hmm.. yeah.. I've thought of doing something like that.. but the JobStatus gives me the information I want.. the other data is not always applicable.

Essentially, my end goal is to be able to monitor multiple print servers from a single console. This should be doable with WMI and/or ADSI.

Brian


Wizard
(Hey THIS is FUN)
2002-10-10 09:29 AM
Re: detecting "Printer Busy or Error"

OT:

LLigetfa and BrianTX,

We have over 20 NT4 servers here and the last reboot was a power failure with the UPS about 6 months ago.!

I can't belive that you need to reboot your servers so regularly.!

W


LonkeroAdministrator
(KiX Master Guru)
2002-10-10 09:48 AM
Re: detecting "Printer Busy or Error"

wiz, it depends a lot of hardware.
my nt-network pdc is compaq and it's uptime is also several months and normal boot reason is too long power outage or system hardware upgrade.

then, our old mailserver is also compaq and it reboots itself with crash 1-10 days from last crash. [Big Grin]

but, good old nt server is good slave and with good care it's uptime truly can be 6 months.