Windows Time OffsetMonitor Type

Microsoft.Windows.Server.10.0.TimeOffset.Monitortype (UnitMonitorType)

Element properties:

RunAsDefault
AccessibilityInternal
Support Monitor RecalculateFalse

Member Modules:

ID Module Type TypeId RunAs 
DS1 DataSource Microsoft.Windows.Server.10.0.TimeOffset.ModuleType Default
ProbeActionDS ProbeAction Microsoft.Windows.Server.10.0.PowerShellPropertyBagProbe Default
FilterNotOK ConditionDetection System.ExpressionFilter Default
FilterOK ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval secondsHow frequently (in seconds) the value should be sampled.
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds
Thresholdstring$Config/Threshold$Threshold in MilliSeconds
NumSamplesint$Config/NumSamples$Number of Samples

Source Code:

<UnitMonitorType ID="Microsoft.Windows.Server.10.0.TimeOffset.Monitortype" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="TimeOffsetNormal"/>
<MonitorTypeState ID="TimeOffsetHigh"/>
</MonitorTypeStates>
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Threshold" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="NumSamples" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="CounterName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ObjectName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InstanceName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AllInstances" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
<OverrideableParameter ID="Threshold" Selector="$Config/Threshold$" ParameterType="string"/>
<OverrideableParameter ID="NumSamples" Selector="$Config/NumSamples$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource TypeID="Microsoft.Windows.Server.10.0.TimeOffset.ModuleType" ID="DS1">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<TargetComputerName>$Config/TargetComputerName$</TargetComputerName>
<NumSamples>$Config/NumSamples$</NumSamples>
<CounterName>$Config/CounterName$</CounterName>
<ObjectName>$Config/ObjectName$</ObjectName>
<InstanceName>$Config/InstanceName$</InstanceName>
<AllInstances>$Config/AllInstances$</AllInstances>
</DataSource>
<ProbeAction ID="ProbeActionDS" TypeID="Microsoft.Windows.Server.10.0.PowerShellPropertyBagProbe">
<ScriptName>Microsoft.Windows.Server.TimeOffset.Monitortype.ps1</ScriptName>
<PSparam>param ($TimeOffSet_THRESHOLD, $TargetComputer, $Time_Offset)</PSparam>
<ScriptBody><Script>
#Copyright (c) Microsoft Corporation. All rights reserved.

# Parameters that should be passed to this script
# 0 TimeOffSet_THRESHOLD
# 1 Time_Offset
[Decimal]$thold
[Decimal]$toffset

$useCulture = New-Object System.Globalization.CultureInfo("en-US")

[Decimal]$toffset = [convert]::ToDecimal($Time_Offset,$useCulture)
# default threshold value in a form of MilliSeconds
# we can change threshold values to in form of Microseconds, Ex: threshold = 0.001 is a 1 Microsecond
# Converting threshold value in milliseconds to microseconds. Hence we need to convert to decimal.
[Decimal]$thold = [convert]::ToDecimal($TimeOffSet_THRESHOLD,$useCulture)

Function Main()
{

TraceLogMessage("Computed Time Offset " + $Time_Offset.ToString())

$thold = $thold * 1000
if ($toffset -le 0 )
{
ReturnResults "GOOD" $toffset
}
elseif($toffset - $thold -ge 0)
{
ReturnResults "BAD" $toffset
}
else
{
ReturnResults "GOOD" $toffset
}


}

Function ReturnResults
{
param ($State, [Decimal]$toffset)

[string]$message1 = $toffset.ToString() + " Micro Seconds"

$oBag = $momAPI.CreatePropertyBag()
$oBag.AddValue("State", $State)
#$oBag.AddValue("TimeOffset", $toffset)

$oBag.AddValue("TimeOffset", $message1)
if($State -eq "BAD")
{
$oBag.AddValue("Description", "Time Accuracy Out of Range")
}

$oBag
}

Main
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>TimeOffSet_THRESHOLD</Name>
<Value>$Config/Threshold$</Value>
</Parameter>
<Parameter>
<Name>TargetComputer</Name>
<Value>$Config/TargetComputerName$</Value>
</Parameter>
<Parameter>
<Name>Time_Offset</Name>
<Value>$Data/Value$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="FilterOK" TypeID="System!System.ExpressionFilter">
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery>Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>ContainsSubstring</Operator>
<Pattern>GOOD</Pattern>
</RegExExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="FilterNotOK" TypeID="System!System.ExpressionFilter">
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery>Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>ContainsSubstring</Operator>
<Pattern>BAD</Pattern>
</RegExExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="TimeOffsetNormal">
<Node ID="FilterOK">
<Node ID="ProbeActionDS">
<Node ID="DS1"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="TimeOffsetHigh">
<Node ID="FilterNotOK">
<Node ID="ProbeActionDS">
<Node ID="DS1"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>