Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New functionality to monitor services that no longer exist #53

Merged
merged 10 commits into from
Jan 31, 2023
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,5 @@ VisualStudioAuthoringConsole_x64.msi
_Scripts/VisualStudioAuthoringConsole_x64.msi
VisualStudio2022AuthoringConsole_x64.msi
/.vs/Atea.Windows/FileContentIndex
/.vs/VSWorkspaceState.json
/.vs/slnx.sqlite
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</ManagementPackReference>
<ManagementPackReference Include="Microsoft.Windows.Library">
<Alias>Windows</Alias>
<PackageToBundle>false</PackageToBundle>
<PackageToBundle>False</PackageToBundle>
</ManagementPackReference>
<ManagementPackReference Include="System.AdminItem.Library">
<HintPath>C:\Program Files (x86)\System Center 2012 Visual Studio Authoring Extensions\References\OM2012\System.AdminItem.Library.mp</HintPath>
Expand Down Expand Up @@ -154,6 +154,9 @@
<Compile Include="TypeLibrary\ModuleTypes\WriteActions\AvdServiceRecoveryTask.WA.mpx">
<SubType>Code</SubType>
</Compile>
<Compile Include="TypeLibrary\MonitorTypes\ServiceExistMonitorType.mpx">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="HealthModel" />
Expand All @@ -172,6 +175,7 @@
<Folder Include="TypeLibrary\ModuleTypes\DataSources" />
<Folder Include="TypeLibrary\ModuleTypes\WriteActions" />
<Folder Include="TypeLibrary\ModuleTypes\ProbeActions" />
<Folder Include="TypeLibrary\MonitorTypes" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\Add-MonitoredServiceKey.ps1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<TemplateGroup>
<Instances>
<Instance ID="Instance1cb8bbbf42bb4bd8ba0ce5a2d4aaa2da" Type="Microsoft.SystemCenter.Authoring.CodeGeneration.Monitoring.UnitMonitor" Version="1.0.0.0">
<UnitMonitorConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UnitMonitorConfig xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MonitorType>Windows!Microsoft.Windows.CheckNTServiceStateMonitorType</MonitorType>
<MonitorConfig>&lt;ComputerName&gt;$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$&lt;/ComputerName&gt;&lt;ServiceName&gt;$Target/Property[Type='MSNL!Microsoft.SystemCenter.NTService']/ServiceName$&lt;/ServiceName&gt;&lt;CheckStartupType&gt;true&lt;/CheckStartupType&gt;</MonitorConfig>
<MonitorOperationalStates>
Expand Down Expand Up @@ -35,5 +35,42 @@
<ConfirmDelivery>false</ConfirmDelivery>
</UnitMonitorConfig>
</Instance>
<Instance ID="Instance14cf63c543624180a314e5b97e189e98" Type="Microsoft.SystemCenter.Authoring.CodeGeneration.Monitoring.UnitMonitor" Version="1.0.0.0">
<UnitMonitorConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MonitorType>Atea.Windows.Service.Monitoring.ServiceExistMonitorType</MonitorType>
<MonitorConfig>&lt;ComputerName&gt;$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$&lt;/ComputerName&gt;&lt;ServiceName&gt;$Target/Property[Type='MSNL!Microsoft.SystemCenter.NTService']/ServiceName$&lt;/ServiceName&gt;&lt;Frequency&gt;3600&lt;/Frequency&gt;</MonitorConfig>
<MonitorOperationalStates>
<OperationalState>
<OperationalStateId>ServiceDoesNotExist</OperationalStateId>
<OperationalStateDisplayName>ServiceDoesNotExist</OperationalStateDisplayName>
<MonitorTypeStateId>ServiceDoesNotExist</MonitorTypeStateId>
<HealthState>Warning</HealthState>
</OperationalState>
<OperationalState>
<OperationalStateId>ServiceExist</OperationalStateId>
<OperationalStateDisplayName>ServiceExist</OperationalStateDisplayName>
<MonitorTypeStateId>ServiceExist</MonitorTypeStateId>
<HealthState>Success</HealthState>
</OperationalState>
</MonitorOperationalStates>
<ParentMonitor>Health!System.Health.ConfigurationState</ParentMonitor>
<Accessibility>Public</Accessibility>
<Id>ServiceExist</Id>
<DisplayName>Service Exist Monitor</DisplayName>
<Description>Check if service exist.</Description>
<Target>MSNL!Microsoft.SystemCenter.NTService</Target>
<Enabled>false</Enabled>
<Category>AvailabilityHealth</Category>
<Remotable>true</Remotable>
<Priority>Normal</Priority>
<AlertAutoResolve>true</AlertAutoResolve>
<AlertOnState>Warning</AlertOnState>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertName>Service does not exist</AlertName>
<AlertDescription>The service '$Target/Property[Type='MSNL!Microsoft.SystemCenter.NTService']/ServiceName$' does not exist.</AlertDescription>
<ConfirmDelivery>false</ConfirmDelivery>
</UnitMonitorConfig>
</Instance>
</Instances>
</TemplateGroup>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TypeDefinitions>
<MonitorTypes>
<UnitMonitorType ID="Atea.Windows.Service.Monitoring.ServiceExistMonitorType" Accessibility="Public">
<MonitorTypeStates>
<MonitorTypeState ID="ServiceDoesNotExist"/>
<MonitorTypeState ID="ServiceExist"/>
</MonitorTypeStates>
<Configuration>
<xsd:element name="ComputerName" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element name="ServiceName" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element name="Frequency" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Frequency" Selector="$Config/Frequency$" ParameterType ="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.Win32ServiceInformationProvider">
<ComputerName>$Config/ComputerName$</ComputerName>
<ServiceName>$Config/ServiceName$</ServiceName>
<Frequency>$Config/Frequency$</Frequency>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.Win32ServiceInformationProbe">
<ComputerName>$Config/ComputerName$</ComputerName>
<ServiceName>$Config/ServiceName$</ServiceName>
</ProbeAction>
<ConditionDetection ID="ServiceExistCondition" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value Type="Integer">8</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="ServiceDoesNotExistCondition" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">8</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="ServiceDoesNotExist">
<Node ID="ServiceDoesNotExistCondition">
<Node ID="DS" />
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="ServiceExist">
<Node ID="ServiceExistCondition">
<Node ID="DS" />
</Node>
</RegularDetection>
</RegularDetections>
<OnDemandDetections>
<OnDemandDetection MonitorTypeStateID="ServiceDoesNotExist">
<Node ID="ServiceDoesNotExistCondition">
<Node ID="Probe" />
</Node>
</OnDemandDetection>
<OnDemandDetection MonitorTypeStateID="ServiceExist">
<Node ID="ServiceExistCondition">
<Node ID="Probe" />
</Node>
</OnDemandDetection>
</OnDemandDetections>
</MonitorImplementation>
</UnitMonitorType>
</MonitorTypes>
</TypeDefinitions>
</ManagementPackFragment>
Binary file modified Released/Atea.Windows.Service.Monitoring.mp
Binary file not shown.
119 changes: 118 additions & 1 deletion Released/unsealed/Atea.Windows.Service.Monitoring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Manifest>
<Identity>
<ID>Atea.Windows.Service.Monitoring</ID>
<Version>1.0.3.324</Version>
<Version>1.0.3.329</Version>
</Identity>
<Name>Atea.Windows.Service.Monitoring</Name>
<References>
Expand Down Expand Up @@ -905,6 +905,85 @@ Main]]></ScriptBody>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>
</ModuleTypes>
<MonitorTypes>
<UnitMonitorType ID="Atea.Windows.Service.Monitoring.ServiceExistMonitorType" Accessibility="Public">
<MonitorTypeStates>
<MonitorTypeState ID="ServiceDoesNotExist" />
<MonitorTypeState ID="ServiceExist" />
</MonitorTypeStates>
<Configuration>
<xsd:element name="ComputerName" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element name="ServiceName" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:element name="Frequency" type="xsd:integer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Frequency" Selector="$Config/Frequency$" ParameterType="int" />
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.Win32ServiceInformationProvider">
<ComputerName>$Config/ComputerName$</ComputerName>
<ServiceName>$Config/ServiceName$</ServiceName>
<Frequency>$Config/Frequency$</Frequency>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.Win32ServiceInformationProbe">
<ComputerName>$Config/ComputerName$</ComputerName>
<ServiceName>$Config/ServiceName$</ServiceName>
</ProbeAction>
<ConditionDetection ID="ServiceExistCondition" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value Type="Integer">8</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="ServiceDoesNotExistCondition" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">8</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="ServiceDoesNotExist">
<Node ID="ServiceDoesNotExistCondition">
<Node ID="DS" />
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="ServiceExist">
<Node ID="ServiceExistCondition">
<Node ID="DS" />
</Node>
</RegularDetection>
</RegularDetections>
<OnDemandDetections>
<OnDemandDetection MonitorTypeStateID="ServiceDoesNotExist">
<Node ID="ServiceDoesNotExistCondition">
<Node ID="Probe" />
</Node>
</OnDemandDetection>
<OnDemandDetection MonitorTypeStateID="ServiceExist">
<Node ID="ServiceExistCondition">
<Node ID="Probe" />
</Node>
</OnDemandDetection>
</OnDemandDetections>
</MonitorImplementation>
</UnitMonitorType>
</MonitorTypes>
</TypeDefinitions>
<Monitoring>
<Discoveries>
Expand Down Expand Up @@ -1207,6 +1286,27 @@ Main]]></ScriptBody>
<CheckStartupType>true</CheckStartupType>
</Configuration>
</UnitMonitor>
<UnitMonitor ID="Atea.Windows.Service.ServiceExist" Accessibility="Public" Enabled="false" Target="MSNL!Microsoft.SystemCenter.NTService" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="Atea.Windows.Service.Monitoring.ServiceExistMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Atea.Windows.Service.ServiceExist.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type='MSNL!Microsoft.SystemCenter.NTService']/ServiceName$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="ServiceDoesNotExist" MonitorTypeStateID="ServiceDoesNotExist" HealthState="Warning" />
<OperationalState ID="ServiceExist" MonitorTypeStateID="ServiceExist" HealthState="Success" />
</OperationalStates>
<Configuration>
<ComputerName>$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$</ComputerName>
<ServiceName>$Target/Property[Type='MSNL!Microsoft.SystemCenter.NTService']/ServiceName$</ServiceName>
<Frequency>3600</Frequency>
</Configuration>
</UnitMonitor>
</Monitors>
<Recoveries>
<Recovery ID="Atea.Windows.Service.Service.AdvRecoveryTask" Accessibility="Public" Target="MSNL!Microsoft.SystemCenter.NTService" Enabled="false" ExecuteOnState="Error" Monitor="Atea.Windows.Service.RecoveryMonitor" ResetMonitor="true" Timeout="300" Remotable="false">
Expand All @@ -1233,6 +1333,7 @@ Main]]></ScriptBody>
</Monitoring>
<Presentation>
<StringResources>
<StringResource ID="Atea.Windows.Service.ServiceExist.AlertMessage" />
<StringResource ID="Atea.Windows.Service.AdvServiceRecoveryFailed.AlertMessage" />
</StringResources>
</Presentation>
Expand Down Expand Up @@ -1270,6 +1371,22 @@ Main]]></ScriptBody>
<Name>NotRunning</Name>
<Description>NotRunning</Description>
</DisplayString>
<DisplayString ElementID="Atea.Windows.Service.ServiceExist">
<Name>Service Exist Monitor</Name>
<Description>Check if service exist.</Description>
</DisplayString>
<DisplayString ElementID="Atea.Windows.Service.ServiceExist.AlertMessage">
<Name>Service does not exist</Name>
<Description>The service '{0}' does not exist.</Description>
</DisplayString>
<DisplayString ElementID="Atea.Windows.Service.ServiceExist" SubElementID="ServiceDoesNotExist">
<Name>ServiceDoesNotExist</Name>
<Description>ServiceDoesNotExist</Description>
</DisplayString>
<DisplayString ElementID="Atea.Windows.Service.ServiceExist" SubElementID="ServiceExist">
<Name>ServiceExist</Name>
<Description>ServiceExist</Description>
</DisplayString>
<DisplayString ElementID="Atea.Windows.Service.AdvServiceRecoveryFailed">
<Name>Windows Service Adv Recovery Failed</Name>
<Description>Alerts on events indicating a failure to recover a stopped Windows service</Description>
Expand Down