資料庫總空間

Microsoft.SQLServer.2012.Database.DBSizePercentMonitor (UnitMonitor)

監視資料庫及主控此資料庫之媒體上的可用空間 (以百分比表示)。

Knowledge Base article:

摘要

監視資料庫及主控此資料庫的媒體上的可用空間。至少要對其中一個檔案啟用自動成長,才會將主控此資料庫的媒體上的可用空間納入可用空間的一部分。

原因

所有資料庫檔案之間的可用空間不足而導致健全狀況不佳的狀態。造成可用空間不足的可能原因為:

請使用下列連結檢視效能資料:資料庫效能資料

此監視器會依據每個檔案的組態彙總資料庫內每個檔案的可用空間:

無自動成長

如果是沒有自動成長的檔案,可用空間將會是檔案初始大小與已使用空間兩者之間的差異。

啟用自動成長

除了檔案大小與已使用空間兩者間的差之外,啟用自動成長的檔案,其可用空間將會大小上限與檔案大小的差及磁碟上剩餘的可用空間 (取兩者的最小值)。

具有自動成長的資料庫檔案可用空間不足,可能表示檔案已接近主控邏輯磁碟機的限制。對於啟用自動成長且有大小上限的檔案,可用空間不足可能表示檔案已接近為檔案指定的大小上限。

可用空間計算也會考慮:如果檔案成長幅度大於磁碟上剩餘的可用空間,或大小上限與目前檔案大小的差小於成長幅度,檔案在這些情況下也會無法成長。在上述這些情況中,磁碟上剩餘的可用空間將不會納入可用空間的一部分,因為已經沒有辦法繼續成長了。

解決方式

您可以使用以下任一方法來解決此問題:

請參閱《SQL Server 線上叢書》: 檔案與檔案群組架構

Element properties:

TargetMicrosoft.SQLServer.2012.Database
Parent MonitorMicrosoft.SQLServer.2012.Database.DBSpaceMonitor
CategoryPerformanceHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityHigh
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2012.DBAndLogSizeMonitorType
RemotableTrue
AccessibilityPublic
Alert Message
資料庫空間用盡
電腦 "{2}" 上 SQL 執行個體 "{1}" 中資料庫 "{0}" 的空間即將用盡。請參閱 [警示內容] 索引標籤,以取得詳細資料。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2012.Database.DBSizePercentMonitor" Accessibility="Public" Enabled="false" Target="SQL2012Core!Microsoft.SQLServer.2012.Database" ParentMonitorID="Microsoft.SQLServer.2012.Database.DBSpaceMonitor" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2012.DBAndLogSizeMonitorType" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2012.Database.DBSizePercentMonitor.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>High</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/DatabaseName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.ServerRole"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="UnderThreshold1" MonitorTypeStateID="UnderThreshold1" HealthState="Error"/>
<OperationalState ID="OverThreshold1UnderThreshold2" MonitorTypeStateID="OverThreshold1UnderThreshold2" HealthState="Warning"/>
<OperationalState ID="OverThreshold2" MonitorTypeStateID="OverThreshold2" HealthState="Success"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<ConnectionString>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString>
<ServerName>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ServerName>
<SqlInstanceName>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.ServerRole"]/InstanceName$</SqlInstanceName>
<ObjectName>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/PerformanceCounterObject$:Database</ObjectName>
<CounterName>DB Total Free Space (%)</CounterName>
<InstanceName/>
<DatabaseName>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/DatabaseName$</DatabaseName>
<Value>$Data/Property[@Name='DBFreeSpacePercent']$</Value>
<Threshold1>10</Threshold1>
<Threshold2>20</Threshold2>
<TimeoutSeconds>300</TimeoutSeconds>
</Configuration>
</UnitMonitor>