Hi !
For a customer I did once a special check of print queues. My work is
unfortunate company property so I can't exactly tell how I did it, but I
can tell the following (and it dosn't matter in fact what monitoring
program you use as long as it supports external check):
Pre-requisites
1. You must have a AD structure where all objects are registered
2. Some knowledgde on how to write windows scripting files for AD (as JAVA
og as VBS)
3. Windows scriptiong host installed
4. User executing the script should have read rights to the informations in
the domain (to be sure everything is working a user with Domain Admin would
be ok)
What can be done:
With the following VBS command:
Set PrintQueue = GetObject("WinNT://" & ComputerDomain & "/" & PrintServer
& "/" & PrintQueueName)
you get information about a certain prinqueue - you should have a
printqueue for each printer.
With the following VBS code you can get information about each job in the
queue written to a file:
Set PrintQueue = GetObject("WinNT://" & ComputerDomain & "/" & PrintServer
& "/" & PrintQueueName)
Set FileObject = CreateObject("Scripting.FileSystemObject")
FileName = PrintQueueName & ".txt"
Set FileHandler = FileObject.OpenTextFile(FileName, 2, True)
For Each PrintJob in PrintQueue.PrintJobs
REM ---- Counting
JobCount = JobCount + 1
FileHandler.WriteLine CStr(PrintJob.HostPrintQueue)
FileHandler.WriteLine CStr(PrintJob.Name)
FileHandler.WriteLine CStr(PrintJob.Size)
FileHandler.WriteLine PrintJob.TotalPages
FileHandler.WriteLine CStr(PrintJob.PagesPrinted)
FileHandler.WriteLine CStr(PrintJob.Status)
FileHandler.WriteLine "---------"
Next
FileHandler.WriteLine JobCount
FileHandler.Close
Ok, but how can this help finding a stuck print queue?
You do two succesive checks (lets say with 5 min between each). In each
check you only record the information for the first job in the queue (you
can determine if it is the first job by checking PrintJob.Position = 1).
You now compare the two set of information:
If PrintJob.Name is different the queue is moving = OK
If PrintJob.Name not is different check if any one of the following
changed: PrintJob.Size, PrintJob.TotalPages and PrintJob.PagesPrinted
If the values changed the queue is still moving = OK
If they did not change the queue is stuck = ERROR
If you monitor a print job during execution (and if all is working) the
following should happen:
1. You submit a Job: The TotalPages and Size should increase until all
pages are submitted to the spooler.
2. After the spooler has recived all and starts sending it to the printer:
The PagesPrinted should increase and at some point be equal to the original
pages submitted AND (this is important to remember otherwise it can be
confusing) the TotalPages counter DECREASES and should reach 0 after all
pages are printed.
3. After all pages are submitted to the printer the job should be deleted
from the queue.
For modern printers with lots of RAM and on fast networks step 2 and 3
should take no more then some minutes even for large jobs.
How can this help in Servers Alive?
with:
Wscript.Quit(JobCount+Ok)
you can get a VBS script to set the errorlevel return value of eg. a batch
file (I called the VBS script from inside a batch file that again was
called from the SA external check function). If all is OK only the JobCount
in the queue is returned if i get an error i add eg. 10000 to the return
value and have SA to trigger on errorlevel above 10000 (I have yet to
encounter a print queue where there where more than 10000 jobs waiting to
be printed).
Doing it this way has several advantages over checking files in the spool
directory:
1. You do not care where the spool directory is
2. You can target each queue on a server seperatly even if all use the
default spool dir
3. You can even get information about how many jobs are currently in queue
(may be for statistical reasons - what printers are used a lot etc.)
This was just my little input to the print check debate - and I hope you
can use the idea. I have had no complains from the cutomer I developed this
for :-)
I can not and will not give more detailed information about how exactly my
program looks. You can of course always conract my company if you whant to
get my work in detail - we are not that expensive ;-)
One final thought: it is even possible as an automated action to delete the
first job in a queue if it appears to be stuck and see if the queue starts
moving again or the most drastical autmoated response would be to purge the
enture queue. Bot can be scripted.
Regards
Niels Putzer
Jack Lyons To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
<jack.lyons@mart cc:
inagency.com> Subject: RE: [SA-list] Check NT spool
queues
Sent by:
salive-owner@woo
dstone.nu
26-09-2002 16:41
Please respond
to salive
you can verify the spool directory by looking in the registry:
for all printers
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\DefaultSp
oolDirectory
for individual printers go to the correct printer key undereneath above and
look at
SpoolDirectory
> -----Original Message-----
> From: Peter Hoermann [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 8:38 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [SA-list] Check NT spool queues
>
>
> Since NT uses 2 files in the spool directory for each file
> printed, you need
> to use double the amount of files as a check in spool directory.
>
> 15 "jobs" is 30 files. (1 being a *.spl and one being a *.shd)
>
> Spool directories by "default" (some admins don't like their spool
> directories located on the same partition as their system
> drive) are kept in
> the following path
>
> \\server-name\winnt\system32\spool\printers
>
> do your count files on this dir
>
> Peter
>
> -----Original Message-----
> From: Dirk Bulinckx [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 26 September 2002 10:50
> To: [EMAIL PROTECTED]
> Subject: RE: [SA-list] Check NT spool queues
>
>
> Countfiles count's files. Not sure how the NT spool is
> working, if they
> would have files somewere it could help.
> I should be possible to check the spool length using a
> perfmon check or
> using SNMP.
>
>
>
> dirk.
>
>
> dirk.
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of [EMAIL PROTECTED]
> Sent: Thu Sep 26 10:47 AM
> To: [EMAIL PROTECTED]
> Subject: [SA-list] Check NT spool queues
>
>
> Anyone had any sucess using Servers Alive checking NT spool
> queue (prints)?
> I want to be alerted when a printer has more than X jobs in the queue
>
> Can the addon CountFiles be used, if so anyone knows how?
>
>
> Let's say you have a mailserver that uses a spool directory.
> If the mail
> server
> is running correctly, it should deliver the mail within 5
> minutes to the
> internet. But since sometimes the mail service runs, and
> still the mail
> server
> isn't running correctly, it's not enough to check the mail
> server service.
> It
> would be nice to be able to check the number of files in the
> mail server's
> spooldirectory and have Servers Alive warn you when more the
> 200 files are
> in
> that directory.
>
>
> By using a combination of the external check of Servers and
> COUNTFILES.EXE
> it's
> now possible.
>
>
>
>
>
>
> To unsubscribe from a list, send a mail message to
> [EMAIL PROTECTED]
> With the following in the body of the message:
> unsubscribe SAlive
>
>
>
> To unsubscribe from a list, send a mail message to
> [EMAIL PROTECTED]
> With the following in the body of the message:
> unsubscribe SAlive
> To unsubscribe from a list, send a mail message to
> [EMAIL PROTECTED]
> With the following in the body of the message:
> unsubscribe SAlive
>
This email and its contents may be confidential. If it is and you are not
the intended recipient, please do not disclose or use the information
within
this email or its attachments. If you have received this email in error,
please delete it immediately. Thank you.
To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
unsubscribe SAlive
To unsubscribe from a list, send a mail message to [EMAIL PROTECTED]
With the following in the body of the message:
unsubscribe SAlive