Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parameter UseServiceDisplayName for service discovery. #35

Merged
merged 3 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Atea.Windows.Service.Service">
<Property TypeID="System!System.Entity" PropertyID="DisplayName" />
<Property TypeID="MSNL!Microsoft.SystemCenter.NTService" PropertyID="ServiceName" />
<Property TypeID="MSNL!Microsoft.SystemCenter.NTService" PropertyID="ServiceProcessName" />
<Property TypeID="MSNL!Microsoft.SystemCenter.NTService" PropertyID="DisplayName" />
Expand All @@ -16,10 +17,15 @@
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<TimeoutSeconds>300</TimeoutSeconds>
<ScriptName>AteaWinSvcServiceDiscoveryDS.vbs</ScriptName>
<UseServiceDisplayName>false</UseServiceDisplayName>
<Debug>false</Debug>
<ClassId>$MPElement[Name="Atea.Windows.Service.Service"]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name='System!System.Entity']/DisplayName$</Name>
<Value>$Data/Property[@Name='EntityDisplayName']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name='MSNL!Microsoft.SystemCenter.NTService']/ServiceName$</Name>
<Value>$Data/Property[@Name='Name']$</Value>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Option Explicit

Dim computerName, keyPath, registryObject, registryValues, serviceName, debugEnabled, scriptParameters, serviceClass
Dim computerName, keyPath, registryObject, registryValues, serviceName, useServiceDisplayName, debugEnabled, scriptParameters, serviceClass
Dim scomApi, scomPropertyBag, serviceObject, returnValue

'''
Expand All @@ -22,9 +22,10 @@ CONST SCOM_SCRIPT_ERROR = 19202
CONST SCOM_DEBUG = 19999


CheckParameters 2
CheckParameters 3
computerName = CStr(scriptParameters(0))
debugEnabled = CBool(scriptParameters(1))
useServiceDisplayName = CBool(scriptParameters(1))
debugEnabled = CBool(scriptParameters(2))

Set registryObject = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & computerName & "\root\default:StdRegProv")
keyPath = "Software\Atea\WinSvc" ' ToDo: Make this a parameter
Expand Down Expand Up @@ -61,6 +62,12 @@ If NOT IsNull(registryValues) Then
Call scomPropertyBag.AddValue("TagID",.TagID)
Call scomPropertyBag.AddValue("keyPath",keyPath)

If useServiceDisplayName Then
Call scomPropertyBag.AddValue("EntityDisplayName",.DisplayName)
Else
Call scomPropertyBag.AddValue("EntityDisplayName",.Name)
End If

Call scomApi.AddItem(scomPropertyBag) ' Add the property bag to the collection
End With
Else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
<xsd:element minOccurs="1" name="ComputerName" type="xsd:string" />
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer" />
<xsd:element minOccurs="1" name="ScriptName" type="xsd:string" />
<xsd:element minOccurs="0" name="UseServiceDisplayName" type="xsd:boolean" />
<xsd:element minOccurs="1" name="Debug" type="xsd:boolean" />
<xsd:element minOccurs="1" name="ClassId" type="xsd:string" />
<xsd:element minOccurs="1" name="InstanceSettings" type="SettingsType" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int" />
<OverrideableParameter ID="UseServiceDisplayName" Selector="$Config/UseServiceDisplayName$" ParameterType="bool" />
<OverrideableParameter ID="Debug" Selector="$Config/Debug$" ParameterType="bool" />
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
</OverrideableParameters>
Expand All @@ -34,6 +36,7 @@
<ProbeAction ID="PropertyBag" TypeID="Atea.Windows.Service.Probe.VBSPropertyBag">
<ScriptName>$Config/ScriptName$</ScriptName>
<ComputerName>$Config/ComputerName$</ComputerName>
<UseServiceDisplayName>$Config/UseServiceDisplayName$</UseServiceDisplayName>
<Debug>$Config/Debug$</Debug>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
Expand Down Expand Up @@ -71,6 +74,10 @@
<DisplayString ElementID="Atea.Windows.Service.ServiceDiscoveryDS" SubElementID="TimeoutSeconds">
<Name>Timeout Seconds</Name>
</DisplayString>
<DisplayString ElementID="Atea.Windows.Service.ServiceDiscoveryDS" SubElementID="UseServiceDisplayName">
<Name>Use Service Display Name</Name>
<Description>Use service display name instead of service name as display name of discovered services.</Description>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Configuration>
<xsd:element minOccurs="1" name="ScriptName" type="xsd:string" />
<xsd:element minOccurs="1" name="ComputerName" type="xsd:string" />
<xsd:element minOccurs="0" name="UseServiceDisplayName" type="xsd:boolean" />
<xsd:element minOccurs="1" name="Debug" type="xsd:boolean" />
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer" />
</Configuration>
Expand All @@ -13,7 +14,7 @@
<MemberModules>
<ProbeAction ID="PropertyBag" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>$Config/ScriptName$</ScriptName>
<Arguments>$Config/ComputerName$ $Config/Debug$</Arguments>
<Arguments>$Config/ComputerName$ $Config/UseServiceDisplayName$ $Config/Debug$</Arguments>
<ScriptBody>$IncludeFileContent/Scripts/AteaWinSvcServiceDiscoveryDS.vbs$</ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
Expand Down