KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Active Script: Print Server job status

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Library
View previous topic :: View next topic  
Author Message
SplanK



Joined: 21 Nov 2007
Posts: 38

PostPosted: Fri Oct 24, 2014 5:49 am    Post subject: Active Script: Print Server job status Reply with quote

Active Script that reports back the number of current print jobs and total pages.

This script reports bad if:
* There are more than 5 jobs waiting
* There is a print job that's over 15 minutes old.

All other times it reports good.

Code:

Option Explicit
const statusAlive       = "Host is alive:"
const statusDead        = "No answer:"
const statusUnknown     = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk          = "Ok:"
const statusBad         = "Bad:"
const statusBadContents = "Bad contents:"
Const USE_LOCAL_TIME = True

FUNCTION PerformTest()
   
   dim intTotalJobs, intTotalPages, objPrintJob, oResponse
   dim objWMIService, colPrintJobs
   dim int15minCount, DateTime, dtmActualTime, TimeinQueue
   
   intTotalJobs = 0
   intTotalPages = 0
   int15minCount = 0

   Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
   Set colPrintJobs =  objWMIService.ExecQuery ("Select * from Win32_PrintJob")
   Set DateTime = CreateObject("WbemScripting.SWbemDateTime")
   
   For Each objPrintJob in colPrintJobs
      intTotalJobs = intTotalJobs + 1
      intTotalPages = intTotalPages + objPrintJob.TotalPages
      
      'Check age of job
      DateTime.Value = objPrintJob.TimeSubmitted
      dtmActualTime = DateTime.GetVarDate(USE_LOCAL_TIME)
      TimeinQueue = DateDiff("n", dtmActualTime, Now)
      
      If TimeinQueue > 15 Then
         int15minCount = int15minCount + 1
         ''strPrinterName = Split(objPrintJob.Name,",",-1,1)
         'strPrinterName(0) = Printer Name
         'objPrintJob.JobID = Print Job ID

      End If
   Next
   
   oResponse = "Total jobs: " & intTotalJobs & " (Pages: " & intTotalPages & ")"
   
   If int15minCount > 0 Then
      oResponse = "Waiting >15mins: " & int15minCount & " / " & oResponse
   End if
   
   If int15minCount > 0 or intTotalJobs > 5 Then 'If a print job has been waiting >15mins, OR there are 5 jobs waiting then alert
      PerformTest = statusBad+oResponse
   Else
      PerformTest = statusOk+oResponse
   End If
End Function
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index