MySQL Server Connection Use Percent 監視器

Microsoft.MySQLServer.ManagedServer.Unix.ConnectionsUsePct.Monitor (UnitMonitor)

Knowledge Base article:

摘要

MySQL 伺服器目前的連線使用率。MySQL 伺服器允許使用全域變數 max_connections 設定連線數限制。此監視器會從狀態變數 'threads_connected' 擷取連線數,再將其除以 max_connections 變數。此監視器閾值會依據輪詢回傳給代理程式的平均值進行分析,其中 [樣本數] 參數控制平均值計算中所含的樣本數。

原因

狀況不良狀態表示 MySQL 伺服器目前的連線使用率高。這可能是對 MySQL 伺服器的連線數過量或不當關閉連線所致。

解決方法

全域變數 max_connections 可指定 MySQL 之同時連線數的上限。請考慮提高此值,然後重新啟動 MySQL 伺服器。另一方法是調整此數值,以確保用戶端連線不會不當地使用持續連線。此監視器閾值會依據輪詢回傳給代理程式的平均值進行分析,其中 [樣本數] 參數控制平均值計算中所含的樣本數。

設定

預設設定

參數

預設值

警告閾值

大於 80

錯誤閾值

大於 90

樣本數

3

您可以使用上列定義的覆寫,變更所有執行個體或特定執行個體或群組的參數值。

Element properties:

TargetMicrosoft.MySQLServer.ManagedServer.Unix
Parent MonitorMicrosoft.MySQLServer.ConnectionsPerformanceRollup
CategoryPerformanceHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Oss.WSManEnumeration.GreaterThanThreshold.ThreeState.MonitorType
RemotableTrue
AccessibilityPublic
Alert Message
MySQL 伺服器連線使用率
MySQL 伺服器目前的連線使用率 ({0}\%) 高
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.MySQLServer.ManagedServer.Unix.ConnectionsUsePct.Monitor" Accessibility="Public" Target="Microsoft.MySQLServer.ManagedServer.Unix" TypeID="Oss!Microsoft.Oss.WSManEnumeration.GreaterThanThreshold.ThreeState.MonitorType" Enabled="onStandardMonitoring" ParentMonitorID="Microsoft.MySQLServer.ConnectionsPerformanceRollup">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.MySQLServer.ManagedServer.Unix.ConnectionsUsePct.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Value$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState HealthState="Success" MonitorTypeStateID="StatusOK" ID="UnderThreshold"/>
<OperationalState HealthState="Warning" MonitorTypeStateID="StatusWarning" ID="OverWarningThreshold"/>
<OperationalState HealthState="Error" MonitorTypeStateID="StatusError" ID="OverErrorThreshold"/>
</OperationalStates>
<Configuration>
<Interval>300</Interval>
<TargetSystem>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
<Uri>http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/MySQL_ServerStatistics?__cimnamespace=root/mysql</Uri>
<WSManFilter/>
<ObjectName>MySQL Server</ObjectName>
<CounterName>Connection Use Pct</CounterName>
<InstanceXPath>/DataItem/WsManData/*[local-name(.)='MySQL_ServerStatistics']/*[local-name(.)='InstanceID']</InstanceXPath>
<InstanceName>$Target/Property[Type="Microsoft.MySQLServer.Installation"]/InstanceID$</InstanceName>
<Value>$Data/WsManData/*[local-name(.)='MySQL_ServerStatistics']/*[local-name(.)='ConnectionsUsePct']$</Value>
<WarningThreshold>80</WarningThreshold>
<ErrorThreshold>90</ErrorThreshold>
<NumSamples>3</NumSamples>
</Configuration>
</UnitMonitor>