需要重新啟動 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,監視將不會啟動且此監視會維持狀況不良狀態。 只有以 .NET Framework 撰寫的服務可由應用程式效能監視 (APM) 進行監視。 請確保您要監視的服務是使用 .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>