MSSQL 2016: Server Windows Service

Microsoft.SQLServer.2016.CheckWinServiceStateMonitorType (UnitMonitorType)

Monitor type for detect state of SQL Server windows service.

Element properties:

RunAsMicrosoft.SQLServer.MonitoringAccount
AccessibilityInternal
Support Monitor RecalculateFalse

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.WmiProvider Default
CheckServiceState ProbeAction Microsoft.SQLServer.2016.VerifyWindowsServiceState Default
ServiceNotRunning ConditionDetection System.ExpressionFilter Default
ServiceRunning ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
Frequencyint$Config/Frequency$Interval (seconds)The recurring interval of time in seconds in which to run the workflow.
CheckStartupTypestring$Config/CheckStartupType$Alert only if service startup type is automaticThis may only be set to 'true' or 'false'. The workflow will not consider the current startup type setting of the service if this parameter is set to 'false'. Default is 'true'.
UnavailableTimeint$Config/UnavailableTime$Unavailable Time (seconds)The minimum duration of service unavailability before considering it unhealthy.

Source Code:

<UnitMonitorType ID="Microsoft.SQLServer.2016.CheckWinServiceStateMonitorType" Accessibility="Internal" RunAs="GPMP!Microsoft.SQLServer.MonitoringAccount">
<MonitorTypeStates>
<MonitorTypeState ID="Running" NoDetection="false"/>
<MonitorTypeState ID="NotRunning" NoDetection="false"/>
</MonitorTypeStates>
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Frequency" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ServiceName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CheckStartupType" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="UnavailableTime" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Frequency" Selector="$Config/Frequency$" ParameterType="int"/>
<OverrideableParameter ID="CheckStartupType" Selector="$Config/CheckStartupType$" ParameterType="string"/>
<OverrideableParameter ID="UnavailableTime" Selector="$Config/UnavailableTime$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.WmiProvider">
<NameSpace>\\.\Root\cimv2</NameSpace>
<Query>SELECT StartMode, State FROM Win32_Service WHERE Name = '$Config/ServiceName$'</Query>
<Frequency>$Config/Frequency$</Frequency>
</DataSource>
<ProbeAction ID="CheckServiceState" TypeID="Microsoft.SQLServer.2016.VerifyWindowsServiceState">
<ServiceName>$Config/ServiceName$</ServiceName>
<ServiceUnavailableTime>$Config/UnavailableTime$</ServiceUnavailableTime>
<CheckStartupType>$Config/CheckStartupType$</CheckStartupType>
<StartMode>$Data/Property[@Name='StartMode']$</StartMode>
<State>$Data/Property[@Name='State']$</State>
</ProbeAction>
<ConditionDetection ID="ServiceRunning" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ServiceState']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Running</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="ServiceNotRunning" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ServiceState']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">NotRunning</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="Running">
<Node ID="ServiceRunning">
<Node ID="CheckServiceState">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="NotRunning">
<Node ID="ServiceNotRunning">
<Node ID="CheckServiceState">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>