Para la creacióon de un discovery basado en un servicio de Windows se debe de realizar de la siguiente manera.
- Añadir la referencia Microsoft.SystemCenter.NTService.Library
Para ello dentro del XML del Management Pack añadimos el siguiente nodo en el siguiente path "ManagementPack/Manifest/References"<Reference Alias="MicrosoftSystemCenterNTServiceLibrary"> <ID>Microsoft.SystemCenter.NTService.Library</ID> <Version>6.1.7043.0</Version> <PublicKeyToken>31bf3856ad364e35</PublicKeyToken> </Reference>
- Creamos la clase Base MP.Pruebas.Component.WindowsService.Base.Class
Esta clase es una clase abstracta que hereda de Microsoft.SystemCenter.OwnProcessNTService
Para ello dentro del XML del Management Pack añadimos el siguiente nodo en el siguiente path "ManagementPack/TypeDefinitions/EntityTypes/ClassTypes"<ClassType ID="MP.Pruebas.Component.WindowsService.Base.Class" Accessibility="Public" Abstract="true" Base="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.OwnProcessNTService" Hosted="true" Singleton="false" />
- Creamos la clase sobre la que crearan las instancias MP.Pruebas.Component.WindowsService.Servicio1.Class
Para ello dentro del XML del Management Pack añadimos el siguiente nodo en el siguiente path "ManagementPack/TypeDefinitions/EntityTypes/ClassTypes"<ClassType ID="MP.Pruebas.Component.WindowsService.Servicio1.Class" Accessibility="Public" Abstract="false" Base="MP.Pruebas.Component.WindowsService.Base.Class" Hosted="true" Singleton="false" />
- Creamos el Discovery MP.Pruebas.Component.WindowsService.Servicio1.Discovery
Para ello dentro del XML del Management Pack añadimos el siguiente nodo en el siguiente path "ManagementPack/Monitoring/Discoveries"
Deberemos modificar los valores de Target, ServiceName, Frecuency y ClassId según nuestra necesidad
-
<Discovery ID="MP.Pruebas.Component.WindowsService.Servicio1.Discovery" Enabled="true" Target="Windows!Microsoft.Windows.Server.Computer"ConfirmDelivery="true" Remotable="true" Priority="Normal"> <Category>Discovery</Category> <DiscoveryTypes> <DiscoveryClass TypeID="Windows!Microsoft.Windows.OperatingSystem" /> </DiscoveryTypes> <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.Win32ServiceInformationProviderWithClassSnapshotDataMapper"> <ComputerName>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName> <ServiceName>Servicio1</ServiceName> <Frequency>60</Frequency> <ClassId>$MPElement[Name="MP.Pruebas.Component.WindowsService.Servicio1.Class"]$</ClassId> <InstanceSettings> <Settings> <Setting> <Name>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Name> <Value>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value> </Setting> <Setting> <Name>$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/ServiceName$</Name> <Value>$Data/Property[@Name='Name']$</Value> </Setting> <Setting> <Name>$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/ServiceProcessName$</Name> <Value>$Data/Property[@Name='BinaryPathName']$</Value> </Setting> <Setting> <Name>$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/DisplayName$</Name> <Value>$Data/Property[@Name='DisplayName']$</Value> </Setting> <Setting> <Name>$MPElement[Name="MicrosoftSystemCenterNTServiceLibrary!Microsoft.SystemCenter.NTService"]/Description$</Name> <Value>$Data/Property[@Name='Description']$</Value> </Setting> <Setting> <Name>$MPElement[Name="System!System.Entity"]/DisplayName$</Name> <Value>Centros Telefonicos OpenSSH Server</Value> </Setting> </Settings> </InstanceSettings> </DataSource> </Discovery>
5. Crear las traducciones de los objetos en el LanguagePack
- Para ello dentro del XML del Management Pack añadimos el siguiente nodo en el siguiente path "ManagementPack/LanguagePacks/LanguagePack/DisplayStrings"
<DisplayString ElementID="MP.Pruebas.Component.WindowsService.Base.Class"> <Name>MP Pruebas Component WindowsService Base Class</Name> </DisplayString> <DisplayString ElementID="MP.Pruebas.Component.WindowsService.Servicio1.Class"> <Name>MP Pruebas Component WindowsService Servicio1 Class</Name> </DisplayString> <DisplayString ElementID="MP.Pruebas.Component.WindowsService.Servicio1.Discovery"> <Name>MP Pruebas Component WindowsService Servicio1 Discovery</Name> </DisplayString>
Espero que sea de ayuda,
un saludo a todos