no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | monitors:printer_monitoring [2009/11/23 06:07] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Printer Monitoring ====== | ||
+ | |||
+ | ^ Author | [[ mikefisher2k@gmail.com | Michael Fisher ]] | | ||
+ | ^ Compatibility | Xymon 4.2+ | | ||
+ | ^ Requirements | Windows Print Services | | ||
+ | ^ Download | Printer.vbs | | ||
+ | ^ Last Update | 2009-04-09 | | ||
+ | |||
+ | ===== Description ===== | ||
+ | Script to Monitor and Report on Status of Windows Print Services | ||
+ | ===== Installation ===== | ||
+ | Run the VBS Script at any desired Interval | ||
+ | === Client side === | ||
+ | Place the VBS into the EXT folder and configure BBWin.cfg to load the external at any given interval | ||
+ | === Server side === | ||
+ | N/A | ||
+ | ===== Source ===== | ||
+ | |||
+ | ==== Printer.vbs ==== | ||
+ | <hidden onHidden=" | ||
+ | < | ||
+ | Option Explicit | ||
+ | On Error Resume Next | ||
+ | |||
+ | Dim colour, bbdelay, strDetail, strDetailAll | ||
+ | Dim WindowsShell, | ||
+ | |||
+ | Const BBTestName = " | ||
+ | |||
+ | strDetail = "" | ||
+ | strDetailAll = "" | ||
+ | colour = " | ||
+ | bbdelay = " | ||
+ | |||
+ | BBConfigExtPath = " | ||
+ | |||
+ | ' | ||
+ | |||
+ | |||
+ | Set objWMIService = GetObject(" | ||
+ | Set colInstalledPrinters = objWMIService.ExecQuery(" | ||
+ | |||
+ | For Each objPrinter in colInstalledPrinters | ||
+ | |||
+ | If objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetail = "& | ||
+ | strDetailAll = "< | ||
+ | colour = " | ||
+ | ElseIf objPrinter.DetectedErrorState = " | ||
+ | strDetailAll = "< | ||
+ | End If | ||
+ | |||
+ | Next | ||
+ | |||
+ | |||
+ | Set colInstalledPrinters = Nothing | ||
+ | Set objWMIService = Nothing | ||
+ | |||
+ | StartDetailBuild() | ||
+ | SetPrintFinalStatus() | ||
+ | GetBBPath() | ||
+ | WriteFile() | ||
+ | |||
+ | Sub StartDetailBuild() | ||
+ | IF colour = " | ||
+ | strDetail = "& | ||
+ | ElseIf colour = " | ||
+ | strDetail = "& | ||
+ | End If | ||
+ | End Sub | ||
+ | |||
+ | Sub SetPrintFinalStatus() | ||
+ | Select Case colour | ||
+ | Case " | ||
+ | strDetail = " | ||
+ | Case " | ||
+ | strDetail = " | ||
+ | Case " | ||
+ | strDetail = " | ||
+ | End Select | ||
+ | End Sub | ||
+ | |||
+ | Sub GetBBPath() | ||
+ | Set WindowsShell = WScript.CreateObject(" | ||
+ | If IsObject(WindowsShell) Then Set WindowsShell = Nothing | ||
+ | End Sub | ||
+ | |||
+ | Sub WriteFile() | ||
+ | Dim oFSO, oFile | ||
+ | Set oFSO = CreateObject(" | ||
+ | Set oFile = oFSO.OpenTextFile(BBConfigExtPath & " | ||
+ | oFile.Write strDetail | ||
+ | oFile.Write "< | ||
+ | oFile.Close | ||
+ | If IsObject(oFSO) Then Set oFSO = Nothing | ||
+ | End Sub | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Known Bugs and Issues ===== | ||
+ | None | ||
+ | ===== To Do ===== | ||
+ | Provided by "" | ||
+ | |||
+ | To create the output so that email alerts do not contain HTML code, incorporate the following into the above script: | ||
+ | |||
+ | < | ||
+ | ' Get max lengths | ||
+ | For Each objPrinter in colInstalledPrinters | ||
+ | If Len(objPrinter.Name) > iMaxNameLen Then iMaxNameLen = Len(objPrinter.Name) | ||
+ | If Len(objPrinter.PortName) > iMaxPortLen Then iMaxPortLen = Len(objPrinter.PortName) | ||
+ | If Len(objPrinter.Location) > iMaxLocnLen Then iMaxLocnLen = Len(objPrinter.Location) | ||
+ | Next | ||
+ | |||
+ | ' Use tabs and padding to format each line | ||
+ | strDetailAll = "& | ||
+ | |||
+ | ' Returns text padded to iLength | ||
+ | Function Pad(sText, iLength) | ||
+ | Dim iPadBy, sTemp | ||
+ | sTemp = sText | ||
+ | iPadding = iLength - Len(sText) | ||
+ | If iPadding > 0 Then sTemp = sTemp & Space(iPadding) | ||
+ | Pad = sTemp | ||
+ | End Function | ||
+ | </ | ||
+ | |||
+ | ===== Credits ===== | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | * **2009-04-09** | ||
+ | * Initial release | ||