Windows Service

Microsoft.SystemCenter.NTService.OwnProcess.Template (Template)

This template allows you to monitor a Windows Service with a standalone process.

Source Code:

<Template ID="Microsoft.SystemCenter.NTService.OwnProcess.Template">
<Configuration>
<xsd:element name="TypeName" type="xsd:string"/>
<xsd:element name="ServiceName" type="xsd:string"/>
<xsd:element name="LocaleId" type="xsd:string"/>
<xsd:element name="TypeDisplayName" type="xsd:string"/>
<xsd:element name="TypeDescription" type="xsd:string"/>
<xsd:element name="TargetGroupGUID" type="xsd:string"/>
<xsd:element name="CheckStartupType" type="xsd:string"/>
<xsd:element name="IsProcessorTimeMonitored" type="xsd:boolean"/>
<xsd:element name="PercentProcessorTimeThreshold" type="xsd:unsignedInt"/>
<xsd:element name="IsPrivateBytesMonitored" type="xsd:boolean"/>
<xsd:element name="PrivateBytesThreshold" type="xsd:double"/>
<xsd:element name="ConsecutiveSampleCount" type="xsd:unsignedInt"/>
<xsd:element name="PollIntervalInSeconds" type="xsd:unsignedInt"/>
</Configuration>
<References>
<Reference ID="Health"/>
<Reference ID="SC"/>
<Reference ID="Self"/>
<Reference ID="System"/>
<Reference ID="Windows"/>
</References>
<Implementation>
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="$TemplateConfig/TypeName$" Abstract="false" Accessibility="Public" Hosted="true" Base="$Reference/Self$Microsoft.SystemCenter.OwnProcessNTService"/>
</ClassTypes>
<RelationshipTypes/>
</EntityTypes>
</TypeDefinitions>
<Monitoring>
<Discoveries>
<Discovery ID="$TemplateConfig/TypeName$.DiscoveryRule" Target="$Reference/Windows$Microsoft.Windows.Computer" Enabled="false">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="$TemplateConfig/TypeName$"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="$Reference/Windows$Microsoft.Windows.Win32ServiceInformationProviderWithClassSnapshotDataMapper">
<ComputerName>$Target/Property[Type="$Reference/Windows$Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<ServiceName>$TemplateConfig/ServiceName$</ServiceName>
<Frequency>60</Frequency>
<ClassId>$MPElement[Name="$TemplateConfig/TypeName$"]$</ClassId>
<InstanceSettings>
<Settings>
<Setting>
<Name>$MPElement[Name="$Reference/Windows$Microsoft.Windows.Computer"]/PrincipalName$</Name>
<Value>$Target/Property[Type="$Reference/Windows$Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name="$Reference/Self$Microsoft.SystemCenter.NTService"]/ServiceName$</Name>
<Value>$Data/Property[@Name='Name']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name="$Reference/Self$Microsoft.SystemCenter.NTService"]/ServiceProcessName$</Name>
<Value>$Data/Property[@Name='BinaryPathName']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name="$Reference/Self$Microsoft.SystemCenter.NTService"]/DisplayName$</Name>
<Value>$Data/Property[@Name='DisplayName']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name="$Reference/Self$Microsoft.SystemCenter.NTService"]/Description$</Name>
<Value>$Data/Property[@Name='Description']$</Value>
</Setting>
<Setting>
<Name>$MPElement[Name="$Reference/System$System.Entity"]/DisplayName$</Name>
<Value>$TemplateConfig/TypeDisplayName$</Value>
</Setting>
</Settings>
</InstanceSettings>
</DataSource>
</Discovery>
</Discoveries>
<Rules/>
<Monitors>
<UnitMonitor ID="$TemplateConfig/TypeName$.ServiceState.Monitor" Accessibility="Public" Target="$TemplateConfig/TypeName$" Enabled="true" TypeID="$Reference/Windows$Microsoft.Windows.CheckNTServiceStateMonitorType" ParentMonitorID="$Reference/Health$System.Health.AvailabilityState">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="$TemplateConfig/TypeName$.ServiceState.Monitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>High</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="$Reference/Self$Microsoft.SystemCenter.NTService"]/DisplayName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="$Reference/Windows$Microsoft.Windows.Computer"]/NetworkName$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState HealthState="Success" MonitorTypeStateID="Running" ID="Success"/>
<OperationalState HealthState="Error" MonitorTypeStateID="NotRunning" ID="Error"/>
</OperationalStates>
<Configuration>
<ComputerName>$Target/Host/Property[Type="$Reference/Windows$Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<ServiceName>$Target/Property[Type="$Reference/Self$Microsoft.SystemCenter.NTService"]/ServiceName$</ServiceName>
<CheckStartupType>$TemplateConfig/CheckStartupType$</CheckStartupType>
</Configuration>
</UnitMonitor>
<UnitMonitor ID="$TemplateConfig/TypeName$.CPUUsage.Monitor" Accessibility="Public" Target="$TemplateConfig/TypeName$" Enabled="$TemplateConfig/IsProcessorTimeMonitored$" TypeID="$Reference/Self$Microsoft.SystemCenter.NTService.ConsecutiveSamplesThreshold.ErrorOnTooHigh" ParentMonitorID="$Reference/Health$System.Health.PerformanceState">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="$TemplateConfig/TypeName$.CPUUsage.Monitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="$Reference/Self$Microsoft.SystemCenter.NTService"]/DisplayName$</AlertParameter1>
<AlertParameter2>$Data/Context/SampleValue$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="OK" MonitorTypeStateID="SampleCountNormal" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="SampleCountTooHigh" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ServiceName>$Target/Property[Type="$Reference/Self$Microsoft.SystemCenter.NTService"]/ServiceName$</ServiceName>
<ObjectName>Process</ObjectName>
<CounterName>Percent Processor Time</CounterName>
<InstanceProperty>Name</InstanceProperty>
<ValueProperty>PercentProcessorTime</ValueProperty>
<Frequency>$TemplateConfig/PollIntervalInSeconds$</Frequency>
<ScaleBy>$Target/Host/Property[Type="$Reference/Windows$Microsoft.Windows.Computer"]/LogicalProcessors$</ScaleBy>
<Threshold>$TemplateConfig/PercentProcessorTimeThreshold$</Threshold>
<NumSamples>$TemplateConfig/ConsecutiveSampleCount$</NumSamples>
</Configuration>
</UnitMonitor>
<UnitMonitor ID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor" Accessibility="Public" Target="$TemplateConfig/TypeName$" Enabled="$TemplateConfig/IsPrivateBytesMonitored$" TypeID="$Reference/Self$Microsoft.SystemCenter.NTService.ConsecutiveSamplesThreshold.ErrorOnTooHigh" ParentMonitorID="$Reference/Health$System.Health.PerformanceState">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="$Reference/Self$Microsoft.SystemCenter.NTService"]/DisplayName$</AlertParameter1>
<AlertParameter2>$Data/Context/SampleValue$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="OK" MonitorTypeStateID="SampleCountNormal" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="SampleCountTooHigh" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ServiceName>$Target/Property[Type="$Reference/Self$Microsoft.SystemCenter.NTService"]/ServiceName$</ServiceName>
<ObjectName>Process</ObjectName>
<CounterName>Private Bytes</CounterName>
<InstanceProperty>Name</InstanceProperty>
<ValueProperty>PrivateBytes</ValueProperty>
<Frequency>$TemplateConfig/PollIntervalInSeconds$</Frequency>
<Threshold>$TemplateConfig/PrivateBytesThreshold$</Threshold>
<NumSamples>$TemplateConfig/ConsecutiveSampleCount$</NumSamples>
</Configuration>
</UnitMonitor>
</Monitors>
<Overrides>
<RuleConfigurationOverride ID="$TemplateConfig/TypeName$.CollectPercentProcessorTime.Rule.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectPercentProcessorTime" Parameter="Frequency" Module="DS">
<Value>$TemplateConfig/PollIntervalInSeconds$</Value>
</RuleConfigurationOverride>
<RulePropertyOverride ID="$TemplateConfig/TypeName$.CollectPercentProcessorTime.Rule.Enabled.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectPercentProcessorTime" Property="Enabled">
<Value>$TemplateConfig/IsProcessorTimeMonitored$</Value>
</RulePropertyOverride>
<RuleConfigurationOverride ID="$TemplateConfig/TypeName$.CollectPrivateBytes.Rule.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectPrivateBytes" Parameter="Frequency" Module="DS">
<Value>$TemplateConfig/PollIntervalInSeconds$</Value>
</RuleConfigurationOverride>
<RulePropertyOverride ID="$TemplateConfig/TypeName$.CollectPrivateBytes.Rule.Enabled.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectPrivateBytes" Property="Enabled">
<Value>$TemplateConfig/IsPrivateBytesMonitored$</Value>
</RulePropertyOverride>
<RulePropertyOverride ID="$TemplateConfig/TypeName$.CollectThreadCount.Rule.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectThreadCount" Property="Enabled">
<Value>false</Value>
</RulePropertyOverride>
<RulePropertyOverride ID="$TemplateConfig/TypeName$.CollectWorkingSet.Rule.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectWorkingSet" Property="Enabled">
<Value>false</Value>
</RulePropertyOverride>
<RulePropertyOverride ID="$TemplateConfig/TypeName$.CollectHandleCount.Rule.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Rule="$Reference/Self$Microsoft.SystemCenter.NTService.CollectHandleCount" Property="Enabled">
<Value>false</Value>
</RulePropertyOverride>
<MonitorPropertyOverride ID="$TemplateConfig/TypeName$.ServiceState.Monitor.Override" Context="$TemplateConfig/TypeName$" Enforced="false" Monitor="$Reference/Self$Microsoft.SystemCenter.NTService.ServiceStateMonitor" Property="Enabled">
<Value>false</Value>
</MonitorPropertyOverride>
<DiscoveryPropertyOverride ID="$TemplateConfig/TypeName$.DiscoveryRule.Discovery.Override" Context="$Reference/System$System.Entity" ContextInstance="$TemplateConfig/TargetGroupGUID$" Enforced="false" Discovery="$TemplateConfig/TypeName$.DiscoveryRule" Property="Enabled">
<Value>true</Value>
</DiscoveryPropertyOverride>
</Overrides>
</Monitoring>
<Presentation>
<StringResources>
<StringResource ID="$TemplateConfig/TypeName$.ServiceState.Monitor.AlertMessage"/>
<StringResource ID="$TemplateConfig/TypeName$.CPUUsage.Monitor.AlertMessage"/>
<StringResource ID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor.AlertMessage"/>
</StringResources>
</Presentation>
<LanguagePacks>
<LanguagePack ID="$TemplateConfig/LocaleId$" IsDefault="true">
<DisplayStrings>
<!-- Type Strings -->
<DisplayString ElementID="$TemplateConfig/TypeName$">
<Name>$TemplateConfig/TypeDisplayName$</Name>
<Description>$TemplateConfig/TypeDescription$</Description>
</DisplayString>
<!-- Rule Strings -->
<DisplayString ElementID="$TemplateConfig/TypeName$.DiscoveryRule">
<Name>$TemplateConfig/TypeDisplayName$ Discovery</Name>
<Description>$TemplateConfig/TypeDisplayName$ Discovery</Description>
</DisplayString>
<!-- Service State Monitor Strings -->
<DisplayString ElementID="$TemplateConfig/TypeName$.ServiceState.Monitor">
<Name>Service Running State</Name>
<Description>Monitors the current status of the Windows service. An alert from this monitor indicates the Windows Service is not currently running</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.ServiceState.Monitor" SubElementID="Error">
<Name>Service is not running</Name>
<Description>Service is not running</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.ServiceState.Monitor" SubElementID="Success">
<Name>Service is running</Name>
<Description>Service is running</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.ServiceState.Monitor.AlertMessage">
<Name>Windows Service Stopped</Name>
<Description>The '{0}' service on computer {1} has stopped running</Description>
</DisplayString>
<!-- CPU Usage Monitor Strings -->
<DisplayString ElementID="$TemplateConfig/TypeName$.CPUUsage.Monitor">
<Name>Windows Service CPU Usage Monitor</Name>
<Description>Monitors the CPU Usage of the Windows service.</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CPUUsage.Monitor" SubElementID="Error">
<Name>CPU Usage exceeded threshold</Name>
<Description>CPUUsage exceeded threshold</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CPUUsage.Monitor" SubElementID="OK">
<Name>CPU Usage within threshold</Name>
<Description>CPUUsage within threshold</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CPUUsage.Monitor.AlertMessage">
<Name>CPU Usage threshold exceeded</Name>
<Description>The '{0}' service has exceeded the % Processor Time threshold with a value of {1}.</Description>
</DisplayString>
<!-- Private Bytes Usage Monitor Strings -->
<DisplayString ElementID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor">
<Name>Windows Service Memory Usage Monitor</Name>
<Description>Monitors the memory usage of the Windows service.</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor" SubElementID="Error">
<Name>Memory Usage exceeded threshold</Name>
<Description>Memory Usage exceeded threshold</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor" SubElementID="OK">
<Name>Memory Usage within threshold</Name>
<Description>Memory Usage within threshold</Description>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor.AlertMessage">
<Name>Memory usage threshold exceeded</Name>
<Description>The '{0}' service has exceeded the memory usage threshold with a value of {1}.</Description>
</DisplayString>
<!-- Override Strings -->
<DisplayString ElementID="$TemplateConfig/TypeName$.CollectPercentProcessorTime.Rule.Override">
<Name>Collect Percent Processor Time Override</Name>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CollectPrivateBytes.Rule.Override">
<Name>Collect Private Bytes Override</Name>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CollectThreadCount.Rule.Override">
<Name>Collect Thread Count Override</Name>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CollectWorkingSet.Rule.Override">
<Name>Collect Working Set Override</Name>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.CollectHandleCount.Rule.Override">
<Name>Collect Handle Count Override</Name>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.ServiceState.Monitor.Override">
<Name>Service State Monitor Override</Name>
</DisplayString>
<DisplayString ElementID="$TemplateConfig/TypeName$.DiscoveryRule.Discovery.Override">
<Name>Discovery Rule Override</Name>
</DisplayString>
</DisplayStrings>
<KnowledgeArticles>
<KnowledgeArticle ElementID="$TemplateConfig/TypeName$.DiscoveryRule">
<MamlContent>
<maml:section>
<maml:title>Summary</maml:title>
<maml:para>Discovery rule</maml:para>
</maml:section>
</MamlContent>
</KnowledgeArticle>
<KnowledgeArticle ElementID="$TemplateConfig/TypeName$.PrivateBytesUsage.Monitor">
<MamlContent>
<maml:section>
<maml:title>Summary</maml:title>
<maml:para>This monitor monitors the Memory usage of a Windows service by querying WMI for the performance counter on a timed interval. The monitor is a consecutive samples over threshold monitor. This means that the monitor will alert if the memory usage exceeds the given threshold for the given number of consecutive samples. The specific kind of memory usage being monitored is Private Bytes.</maml:para>
</maml:section>
</MamlContent>
</KnowledgeArticle>
<KnowledgeArticle ElementID="$TemplateConfig/TypeName$.CPUUsage.Monitor">
<MamlContent>
<maml:section>
<maml:title>Summary</maml:title>
<maml:para>This monitor monitors the CPU Usage of a Windows service by querying WMI for the performance counter on a timed interval. The monitor is a consecutive samples over threshold monitor. This means that the monitor will alert if the CPU usage exceeds the given threshold for the given number of consecutive samples.</maml:para>
</maml:section>
</MamlContent>
</KnowledgeArticle>
<KnowledgeArticle ElementID="$TemplateConfig/TypeName$.ServiceState.Monitor">
<MamlContent>
<maml:section>
<maml:title>Summary</maml:title>
<maml:para>This monitor checks the status of a Windows service by querying the service control manager on a timed interval. The monitor can be configured in two ways.</maml:para>
<maml:para>1) If the monitor is configured to monitor only automatic services. In this case, if the service is set to automatically start and the service is not currently running an alert will be raised. If the service is set to manually start or it is disabled, no alert will be raised when the service is stopped.</maml:para>
<maml:para>2) If the monitor is not configured to monitor only automatic services. In this case, no matter how the service is configured to start, if the service is not currently running an alert will be raised.</maml:para>
</maml:section>
<maml:section>
<maml:title>Causes</maml:title>
<maml:para>A service can stop for many reasons, including:</maml:para>
<maml:list>
<maml:listItem>
<maml:para>The service was stopped by an administrator.</maml:para>
</maml:listItem>
<maml:listItem>
<maml:para>The service was prevented from starting because the user account could not be authenticated.</maml:para>
</maml:listItem>
<maml:listItem>
<maml:para>The service encountered an exception that stopped the service.</maml:para>
</maml:listItem>
<maml:listItem>
<maml:para>The service was improperly configured, which prevented it from starting.</maml:para>
</maml:listItem>
<maml:listItem>
<maml:para>Another service that this service is dependent on was stopped</maml:para>
</maml:listItem>
</maml:list>
</maml:section>
<maml:section>
<maml:title>Resolutions</maml:title>
<maml:para>You can view all collected events for this service using the following link:</maml:para>
<maml:para>
<maml:navigationLink>
<maml:linkText>View all events</maml:linkText>
<maml:uri condition="View" href="Microsoft.SystemCenter.EventView&amp;viewtarget={$TARGET$}" uri="MOM.Console.Exe"/>
</maml:navigationLink>
</maml:para>
<maml:para>You can attempt to restart the Windows service by using the following link:</maml:para>
<maml:para>
<maml:navigationLink>
<maml:linkText>Start the Service</maml:linkText>
<maml:uri condition="Task" href="Microsoft.SystemCenter.NTService.StartService&amp;tasktarget={$TARGET$}" uri="MOM.Console.Exe"/>
</maml:navigationLink>
</maml:para>
</maml:section>
</MamlContent>
</KnowledgeArticle>
</KnowledgeArticles>
</LanguagePack>
</LanguagePacks>
</Implementation>
</Template>