Last week I received a question about the possibility to add the health state of services to a state view inside SCOM. This can be done if the service has its own class, if this is not the case the health state cannot be selected on a state view. So for each service a separate class, discovery and monitor need to be created. In this blog I will guide you through that process.
Let’s for example try to combine the health state of a CentOS computer and the state of the SSH service on this CentOS computer. If you look into the Linux/Computer state view you cannot select the health state of the SSH Service. See below the classes which you can select ouf-of-the box:
So basically we have to do the following to make it possible:
- Create Management Pack with a separate class,discovery and monitor.
- Select Columns on Stateview
Let’s start with creating a SCOM Management Pack. You could use your preferred XML editor or Visual Studio for creating the MP. For this example MP I use the UNIX/Linux Authoring Library MP which can be downloaded here. After you downloaded this MP you can use the following guidance to create the references which I also used in my MP. After creating the references we are going to create the class definitions:
<TypeDefinitions> <EntityTypes> <ClassTypes> <ClassType ID="SSH_TestPack.Class" Base="Unix!Microsoft.Unix.ComputerRole" Accessibility="Public" Abstract="false" Hosted="true" Singleton="false"> <Property ID="RoleName" Type="string" Key="true" /> </ClassType> <ClassType ID="SSH_TestPack.Group" Accessibility="Public" Abstract="false" Base="SC!Microsoft.SystemCenter.ComputerGroup" Hosted="false" Singleton="true" Extension="false" /> </ClassTypes> </EntityTypes> </TypeDefinitions>
In the above class definitions we define a class which has Microsoft.Unix.ComputerRole as a base class and a class for a Instance group which has Microsoft.SystemCenter.ComputerGroup as a base class. Next we define the discoveries for the SSH_TestPack.Class and the SSH_TestPack.Group class.
<Discoveries> <Discovery ID="SSH_TestPack.SSH_Testpack.Instance.Discovery" Target="Unix!Microsoft.Unix.Computer" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal"> <Category>Discovery</Category> <DiscoveryTypes> <DiscoveryClass TypeID="SSH_TestPack.Class"> <Property TypeID="SSH_TestPack.Class" PropertyID="RoleName" /> </DiscoveryClass> </DiscoveryTypes> <DataSource ID="DS" TypeID="UnixAuth!Unix.Authoring.TimedShellCommand.Discovery.DataSource"> <Interval>28800</Interval> <TargetSystem>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</TargetSystem> <ShellCommand>chkconfig --list | grep sshd | wc -l</ShellCommand> <Timeout>60</Timeout> <UserName>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/UserName$</UserName> <Password>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/Password$</Password> <FilterExpression> <RegExExpression> <ValueExpression> <XPathQuery>//*[local-name()="StdOut"]</XPathQuery> </ValueExpression> <Operator>MatchesRegularExpression</Operator> <Pattern>^1</Pattern> </RegExExpression> </FilterExpression> <ClassId>$MPElement[Name="SSH_TestPack.Class"]$</ClassId> <InstanceSettings> <Settings> <Setting> <Name>$MPElement[Name='SSH_TestPack.Class']/RoleName$</Name> <Value>SSH Instance</Value> </Setting> <Setting> <Name>$MPElement[Name='Unix!Microsoft.Unix.Computer']/PrincipalName$</Name> <Value>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</Value> </Setting> <Setting> <Name>$MPElement[Name='System!System.Entity']/DisplayName$</Name> <Value>SSH Instance</Value> </Setting> </Settings> </InstanceSettings> </DataSource> </Discovery> <Discovery ID="SSH_TestPack.SSH_Testpack.Group.Discovery" Target="SSH_TestPack.Group" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal"> <Category>Discovery</Category> <DiscoveryTypes> <DiscoveryClass TypeID="SSH_TestPack.Class"> <Property TypeID="SSH_TestPack.Class" PropertyID="RoleName" /> </DiscoveryClass> <DiscoveryRelationship TypeID="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer" /> </DiscoveryTypes> <DataSource ID="DS" TypeID="SC!Microsoft.SystemCenter.GroupPopulator"> <RuleId>$MPElement$</RuleId> <GroupInstanceId>$MPElement[Name="SSH_TestPack.Group"]$</GroupInstanceId> <MembershipRules> <MembershipRule> <MonitoringClass>$MPElement[Name="Unix!Microsoft.Unix.Computer"]$</MonitoringClass> <RelationshipClass>$MPElement[Name="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer"]$</RelationshipClass> <Expression> <Contains> <MonitoringClass>$MPElement[Name="SSH_TestPack.Class"]$</MonitoringClass> </Contains> </Expression> </MembershipRule> </MembershipRules> </DataSource> </Discovery> </Discoveries>
In the above script we define the discovery for the instances of the SSH_Testpack class based on the following shell command: chkconfig –list | grep sshd | wc –l. Based on the returned number an instance will be discovered. In the Group discovery all instances of the SSH_Testpack class will be added to the group. After these discoveries I defined one monitor which has a SSH_Testpack Class instance as a target. The following XML code define the monitor:
<UnitMonitor ID="SSH_TestPack.SSH_TestPack.Instance.ServiceMonitor" Accessibility="Internal" Enabled="true" Target="SSH_TestPack.Class" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="UnixAuth!Unix.Authoring.WSManEnumeration.ProcessCount.MonitorType" ConfirmDelivery="false"> <Category>AvailabilityHealth</Category> <AlertSettings AlertMessage="SSH_TestPack.SSH_TestPack.Instance.ServiceMonitor.AlertMessage"> <AlertOnState>Error</AlertOnState> <AutoResolve>true</AutoResolve> <AlertPriority>Normal</AlertPriority> <AlertSeverity>MatchMonitorHealth</AlertSeverity> <AlertParameters> <AlertParameter1>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</AlertParameter1> </AlertParameters> </AlertSettings> <OperationalStates> <OperationalState ID="ProcessCountOK" MonitorTypeStateID="ProcessCountOK" HealthState="Success" /> <OperationalState ID="ProcessCountError" MonitorTypeStateID="ProcessCountError" HealthState="Error" /> </OperationalStates> <Configuration> <Interval>300</Interval> <TargetSystem>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem> <ProcessName>sshd</ProcessName> <ArgumentsFilterExpression></ArgumentsFilterExpression> <MinProcessCount>1</MinProcessCount> <MaxProcessCount>1</MaxProcessCount> </Configuration> </UnitMonitor>
The above monitor will the availability of the sshd service(s). Based on the <MinProcessCount> and <MaxProcessCount> values the health state will be calculated.
My unsealed MP example can be downloaded here. Please note the disclaimer of my site before you import the MP!
If you have imported this MP you can select the SSH_TestPack class in the state view of the Unix/Linux Computer. When you have selected this the health states of the SSH service is showed in a State View
With defining a separate class for each service you can create a state view with the health states of your services. If you have any question regarding this topic please let me know
Hello! Can i use this method to display a monitor that located in another management pack?
Is this monitor targeted against a separate class? Can you give me more information?
Yes, it has a separate class in another management pack. it has a 2State monitor. i need to display the state of this monitor.
Can you send me a copy of that MP so I can check how you can do it?
Regards, Arjan
This is Veeam MP for VMware. The monitor is “Veeam VMware: vSphere Cluster Insufficient HA Failover Resources Alarm”.
http://helpcenter.veeam.com/mp/70/vmware_reference/index.html?objects_and_properties_library.html