Search code examples
xmlscom

How to monitor multiple services in SCOM 2016?


I am very new to SCOM. I have several servers with several services on each that I need to monitor. These services all have a common word ("Instance") in them. So far from the guides I have found (https://www.bictt.com/blogs/scom-monitoring-multiple-services-running/) I have created a management pack, and then a Windows Service Monitor within the pack. I exported the Management pack and edited to XML to run a WMI query to find the services.

WMI Query - select * from win32_Service where (name like '%Instance%') AND (startmode != 'Disabled')

However after importing the xml back into SCOM, I cannot find the services under Windows Service State.

Here is the XML I have edited:

<DataSource ID="DS" TypeID="MicrosoftWindowsLibrary7585010!Microsoft.Windows.WmiProviderWithClassSnapshotDataMapper">
      <NameSpace>root\cimv2</NameSpace>
      <Query>select * from win32_Service where (name like '%Instance%') AND (startmode != 'Disabled')</Query>
      <Frequency>60</Frequency>
      <ClassId>$MPElement[Name="ServiceStateProbePage_f7c1e73e9bca478baa4e4499b425a019"]$</ClassId>
      <InstanceSettings>
        <Settings>
          <Setting>
            <Name>$MPElement[Name="MicrosoftWindowsLibrary7585010!Microsoft.Windows.Computer"]/PrincipalName$</Name>
            <Value>$Target/Property[Type="MicrosoftWindowsLibrary7585010!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='PathName']$</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>$Data/Property[@Name=’Name’]$</Value>
          </Setting>
        </Settings>
      </InstanceSettings>

I specifically edited these lines

<DataSource ID="DS" TypeID="MicrosoftWindowsLibrary7585010!Microsoft.Windows.WmiProviderWithClassSnapshotDataMapper">
      <NameSpace>root\cimv2</NameSpace>
      <Query>select * from win32_Service where (name like '%Instance%') AND (startmode != 'Disabled')</Query>

And

<Value>$Data/Property[@Name='PathName']$</Value>

Does anyone know why the services wouldn't appear in SCOM? I ran the query on the WMI tester on one of the servers I want to monitor and found the correct services. I have also confirmed the servers are in the group I targeted in the Windows Service Monitor. Thanks for any help you can send my way!


Solution

  • I think your XPath query fails here:

    <Name>$MPElement[Name="System!System.Entity"]/DisplayName$</Name>
    <Value>$Data/Property[@Name=’Name’]$</Value>
    

    Put correct qiotes around the Name property name. I presume, that was discovery data source.