PowerShell Script Three State Monitor (Community)

Community.PowerShellMonitoring.UnitMonitors.PowerShellThreeState (UnitMonitorType)

A three state monitor powered by a PowerShell script. Remember when setting the alert settings to raise an alert on critical or warning state, and to set the severity to "match monitor severity".

Element properties:

RunAsDefault
AccessibilityPublic
Support Monitor RecalculateFalse

Member Modules:

ID Module Type TypeId RunAs 
Timer DataSource System.SimpleScheduler Default
Probe ProbeAction Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe Default
HealthyFilter ConditionDetection System.ExpressionFilter Default
UnhealthyFilter ConditionDetection System.ExpressionFilter Default
WarningFilter ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval (Seconds)The number of seconds between monitor executions.
SyncTimestring$Config/SyncTime$Sync Time (hh:mm)The time at which this monitors executions should be sychronised around.
TimeoutSecondsint$Config/TimeoutSeconds$Timeout (Seconds)The length of time the script has to complete before it is terminated.
Argumentsstring$Config/Arguments$ArgumentsArguments passed to the script as a string.

Source Code:

<UnitMonitorType ID="Community.PowerShellMonitoring.UnitMonitors.PowerShellThreeState" Accessibility="Public">
<MonitorTypeStates>
<MonitorTypeState ID="Healthy"/>
<MonitorTypeState ID="Warning"/>
<MonitorTypeState ID="Unhealthy"/>
</MonitorTypeStates>
<Configuration>
<IncludeSchemaTypes>
<SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int" minOccurs="1" maxOccurs="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="SyncTime" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ScriptName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ScriptBody" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="Arguments" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="UnhealthyExpression" type="ExpressionType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="WarningExpression" type="ExpressionType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="HealthyExpression" type="ExpressionType"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="Arguments" Selector="$Config/Arguments$" ParameterType="string"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="Timer" TypeID="System!System.SimpleScheduler">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
<ScriptName>$Config/ScriptName$</ScriptName>
<ScriptBody><Script>$Config/ScriptBody$</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>Arguments</Name>
<Value>$Config/Arguments$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="HealthyFilter" TypeID="System!System.ExpressionFilter">
<Expression>$Config/HealthyExpression$</Expression>
</ConditionDetection>
<ConditionDetection ID="UnhealthyFilter" TypeID="System!System.ExpressionFilter">
<Expression>$Config/UnhealthyExpression$</Expression>
</ConditionDetection>
<ConditionDetection ID="WarningFilter" TypeID="System!System.ExpressionFilter">
<Expression>$Config/WarningExpression$</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="Healthy">
<Node ID="HealthyFilter">
<Node ID="Probe">
<Node ID="Timer"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="Warning">
<Node ID="WarningFilter">
<Node ID="Probe">
<Node ID="Timer"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="Unhealthy">
<Node ID="UnhealthyFilter">
<Node ID="Probe">
<Node ID="Timer"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>