剩余的数据库文件可用空间

Microsoft.SQLServer.2014.Monitoring.DBFileSpaceMonitor (UnitMonitor)

当可用空间(包括已分配的空间和介质上的可用空间)低于“警告阈值”设置(以占数据大小加磁盘可用空间之和的百分比表示)时,监视器将报告警告。当可用空间低于“严重阈值”时,监视器将报告严重警报。

Knowledge Base article:

摘要

监视器将监视文件和承载该文件的介质上的可用空间。仅当给定文件启用了自动增长时,才考虑介质上的可用空间。

原因

不正常状态是由此文件可用空间不足引起的。导致可用空间不足的原因有:

使用以下链接来查看性能数据: 数据库文件可用空间性能数据

不自动增长

对于不进行自动增长的文件,可用空间为文件的初始大小与已用空间的差值。

启用自动增长

启用了自动增长后,会将磁盘可用空间作为可用空间的一部分包括。除了文件大小与已用空间的差值之外,启用了自动增长的文件的可用空间将是最大大小与文件大小的差值和磁盘上剩余可用空间这两者的较小值。

启用了自动增长的数据库文件的可用空间不足可能表示该文件正在接近所在逻辑驱动器的限制值。对于具有最大大小的启用了自动增长的文件,可用空间不足还可能表示该文件正在接近为文件指定的最大大小。

可用空间计算还要考虑: 如果文件的增长量大于磁盘剩余的可用空间量,文件可能无法增长;如果最大大小与当前文件大小之间的差值小于增长量,文件也将无法增长。在这些情况下,磁盘上剩余的可用空间不作为可用空间的一部分包括,因为我们不能再增长了。

解决方法

可以通过以下任一方法解决此问题: :

请参阅 SQL Server 联机丛书: 文件和文件组体系结构

可替代参数

名称

说明

默认值

Azure 文件最大大小(MB)

存储在 Azure BLOB 存储中的数据文件的最大大小。工作流会将此值视为每个文件的最大存储容量。

1048576

已启用

 

生成警报

 

间隔(秒)

运行工作流的重复间隔时间(秒)。

900

同步时间

使用 24 小时格式指定的同步时间。可以忽略。

 

严重阈值

如果值低于此阈值,监视器会将状态更改为“严重”。值介于此阈值与警告阈值(包括警告阈值)之间会导致监视器处于警告状态。

10

警告阈值

如果值低于此阈值,监视器会将状态更改为“警告”。

20

超时(秒)

指定允许工作流在被关闭并标记为失败之前运行的时间。

300

Element properties:

TargetMicrosoft.SQLServer.2014.DBFile
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2014.DBFileSizeMonitorType
RemotableTrue
AccessibilityPublic
Alert Message
MSSQL 2014: 数据库文件空间用尽
计算机“{4}”上 SQL 实例“{3}”中的数据库“{2}”的文件组“{1}”的数据库文件“{0}”空间用尽。有关详细信息,请参阅知识部分。
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2014.Monitoring.DBFileSpaceMonitor" Accessibility="Public" Enabled="true" Target="SQL2014Core!Microsoft.SQLServer.2014.DBFile" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2014.DBFileSizeMonitorType" ConfirmDelivery="true">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2014.Monitoring.DBFileSpaceMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.File"]/FileName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.FileGroup"]/GroupName$</AlertParameter2>
<AlertParameter3>$Target/Host/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.Database"]/DatabaseName$</AlertParameter3>
<AlertParameter4>$Target/Host/Host/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.ServerRole"]/InstanceName$</AlertParameter4>
<AlertParameter5>$Target/Host/Host/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter5>
</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/Host/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.DBEngine"]/ConnectionString$</ConnectionString>
<ServerName>$Target/Host/Host/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ServerName>
<SqlInstanceName>$Target/Host/Host/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.ServerRole"]/InstanceName$</SqlInstanceName>
<ObjectName>SQL DB File</ObjectName>
<CounterName>DB File Free Space (%)</CounterName>
<InstanceName/>
<DatabaseName>$Target/Host/Host/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.Database"]/DatabaseName$</DatabaseName>
<DBFileId>$Target/Property[Type="SQL2014Core!Microsoft.SQLServer.2014.File"]/FileID$</DBFileId>
<Value>$Data/Property[@Name='FreeSpacePercent']$</Value>
<Threshold1>10</Threshold1>
<Threshold2>20</Threshold2>
<TimeoutSeconds>300</TimeoutSeconds>
<AzureMaxFileSizeMB>1048576</AzureMaxFileSizeMB>
</Configuration>
</UnitMonitor>