需要重启 Windows 服务

Microsoft.SystemCenter.Apm.NTServiceInstance.Restart.Monitor (UnitMonitor)

此监视器跟踪由于在服务器上运行的此 Windows 服务的监视设置发生了变化而导致的重启 Windows 服务需求。

Knowledge Base article:

摘要

此监视器跟踪由于应用程序性能监视(APM)设置发生变化而导致的重启 Windows 服务需求。 如果必须重启给定服务,则此监视器将转为不正常状态。 如果服务在用 Microsoft .NET Framework,则重启服务后,监视将开始,并且状态将重置为正常。

原因

在使用 .NET 应用程序性能监视模板为 Windows 服务修改应用程序监视设置时,可能需要重启作为监视目标的服务,以便让新的设置生效。 如果服务在用 Microsoft .NET Framework,则重启服务后,监视将开始,并且状态将重置为正常。 如果所选服务未使用 Microsoft .NET Framework,则监视将不会开始,并且此监视器将保持不正常状态。 应用程序性能监视(APM)只能监视采用 .NET Framework 编写的服务。 请确保你希望监视的服务是使用 .NET Framework 编写的。

解决方法

Element properties:

TargetMicrosoft.SystemCenter.Apm.NTServiceInstance
Parent MonitorSystem.Health.ConfigurationState
CategoryConfigurationHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Windows.2SingleEventLog2StateMonitorType
RemotableFalse
AccessibilityPublic
Alert Message
需要重启 Windows 服务
服务器 {0} 上的应用程序监视设置已修改。 要应用新设置,你必须在该服务器上重启 Windows 服务“{1}”。 在重启 Windows 服务之前,将不会应用新的监视设置。 但是,受监视的应用程序将继续正常工作。 如果服务在用 Microsoft .NET Framework,则重启服务后,监视将开始,状态将重置为正常,并且此警报将关闭。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SystemCenter.Apm.NTServiceInstance.Restart.Monitor" Accessibility="Public" Enabled="true" Target="Microsoft.SystemCenter.Apm.NTServiceInstance" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="false" Priority="Normal" TypeID="Windows!Microsoft.Windows.2SingleEventLog2StateMonitorType" ConfirmDelivery="false">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="Microsoft.SystemCenter.Apm.NTServiceInstance.Restart.Monitor.AlertMessageResourceID">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="AL!Microsoft.SystemCenter.Apm.ApplicationInstanceBase"]/ApplicationName$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="SecondEventRaised" HealthState="Success"/>
<OperationalState ID="Warning" MonitorTypeStateID="FirstEventRaised" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<FirstComputerName>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</FirstComputerName>
<FirstLogName>Operations Manager</FirstLogName>
<FirstExpression>
<And>
<Expression>
<Or>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">35001</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">35002</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Or>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">PublisherName</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">.NET app monitoring</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Params/Param[1]</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">$Target/Property[Type="AL!Microsoft.SystemCenter.Apm.ApplicationInstanceBase"]/ApplicationName$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</FirstExpression>
<SecondComputerName>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</SecondComputerName>
<SecondLogName>Operations Manager</SecondLogName>
<SecondExpression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">4003</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">PublisherName</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Apm Agent</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery Type="String">EventDescription</XPathQuery>
</ValueExpression>
<Operator>ContainsSubstring</Operator>
<Pattern>$Target/Property[Type="AL!Microsoft.SystemCenter.Apm.ApplicationInstanceBase"]/ApplicationName$</Pattern>
</RegExExpression>
</Expression>
</And>
</SecondExpression>
</Configuration>
</UnitMonitor>