Tasty.Printer.Monitoring.Windows2008.PrintServer.Role.Discovery

Tasty.Printer.Monitoring.Windows2008.PrintServer.Role.Discovery (Discovery)

Description for the new discovery.

Element properties:

TargetMicrosoft.Windows.Server.2008.Computer
EnabledTrue
Frequency43200
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Tasty.Printer.Monitoring.Windows2008.PrintServer.Role.Discovery" Target="MWS2008D!Microsoft.Windows.Server.2008.Computer" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Tasty.Printer.Monitoring.Windows2008.PrintServer.Role">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<!--Set to something aggressive for testing, or normally 3600-->
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
<ScriptName>Windows20XX.PrintServer.Role.Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$ 2008</Arguments>
<ScriptBody><Script><![CDATA[Dim objWMINS, colItems, oPrinter, ErrorStateToString, oAPI, oExec, LOgEVentCOmmand, oArgs, SourceID
Dim ManagedEntityID, TargetComputer, oInst, oDiscoveryData, NetbiosName, oService, SpoolerStarted
Dim PrintServer, OSVersion

Set oArgs = wscript.arguments
SourceId = oArgs(0)
ManagedEntityID = oArgs(1)
TargetComputer = oArgs(2)
NetbiosName = oArgs(3)
OSVersion = oArgs(4)

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Set objWMINS = GetObject("winmgmts://./root/cimv2")
Set colItems = objWMINS.ExecQuery("Select * from Win32_Service")

SpoolerStarted = 0
PrintServer = 0

For each oService in colItems
If oService.Name = "Spooler" and oService.Started = "True" Then
SpoolerStarted = 1
End If
Next

If SpoolerStarted = 1 Then
Set colItems = objWMINS.ExecQuery("Select * from Win32_Printer")
For Each oPrinter in colItems
'SET TO False and 0 FOR TESTING, True and 1 FOR PRODUCTION
If oPrinter.Shared = "True" or oPrinter.Shared = 1 Then
PrintServer = 1
End If
Next
End If

If SpoolerStarted = 1 and PrintServer = 1 Then

Select Case OSVersion
CASE "2003"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2003.PrintServer.Role']$")
CASE "2008"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2008.PrintServer.Role']$")
CASE "2012"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2012.PrintServer.Role']$")
CASE "2016"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Tasty.Printer.Monitoring.Windows2016.PrintServer.Role']$")
End Select

Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$",TargetComputer)
Call oDiscoveryData.AddInstance(oInst)
End If

Call oAPI.Return(oDiscoveryData)]]></Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>