Auto Shrink Configuration

Microsoft.SQLServer.2008.Database.Configuration.AutoShrink (UnitMonitor)

Monitors the auto shrink setting for the database

Knowledge Base article:

Summary

This monitor checks the Auto Shrink setting for this database. Since this monitor is a part of an overall standards requirement, an alert would be generated if the setting does not meet the specified standard.

Configuration

When the Auto Shrink statistics setting is ON, the database files are candidates for periodic shrinking. Both data file and log files can be automatically shrunk. Auto Shrink reduces the size of the transaction log only if the database is set to SIMPLE recovery model or if the log is backed up. When set to OFF, the database files are not automatically shrunk during periodic checks for unused space. The AUTO_SHRINK option causes files to be shrunk when more than 25 percent of the file contains unused space. The file is shrunk to a size where 25 percent of the file is unused space or to the size of the file when it was created, whichever is larger. You cannot shrink a read-only database.

Auto shrink can lead to excessive index fragmentation, transaction log size, and I/O. Use auto shrink only if the database is unlikely to grow again and you can do an ALTER INDEX … REORGANIZE after the shrink operation.

AUTO_SHRINK {ON | OFF}

Causes

A warning alert will be raised if the option does not match the required setting. Out of the box, the monitor is configured to alert when this setting is set to “ON”.

Resolutions

This issue may be resolved by:

Alternatively, if this monitor is not of concern for this database:

External

See more detailed information about this setting: ALTER DATABASE SET Options (Transact-SQL)

Element properties:

TargetMicrosoft.SQLServer.2008.Database
Parent MonitorMicrosoft.SQLServer.2008.Database.AutomaticConfiguration
CategoryConfigurationHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2008.DBConfigurationStatus
RemotableTrue
AccessibilityPublic
Alert Message
Auto Shrink Configuration Error
The auto shrink setting for database "{0}" in SQL instance "{1}" on computer "{2}" is not set according to best practice.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2008.Database.Configuration.AutoShrink" Accessibility="Public" Enabled="false" Target="SQL2008Core!Microsoft.SQLServer.2008.Database" ParentMonitorID="Microsoft.SQLServer.2008.Database.AutomaticConfiguration" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2008.DBConfigurationStatus" ConfirmDelivery="false">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2008.Database.Configuration.AutoShrink.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</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="ConfigurationValueOK" MonitorTypeStateID="ConfigurationValueOK" HealthState="Success"/>
<OperationalState ID="ConfigurationValueNotOK" MonitorTypeStateID="ConfigurationValueNotOK" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<ConnectionString>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ConnectionString$</ConnectionString>
<DatabaseName>$Target/Property[Type="SQL!Microsoft.SQLServer.Database"]/DatabaseName$</DatabaseName>
<IntervalSeconds>43200</IntervalSeconds>
<SyncTime/>
<ConfigValue>AutoShrink</ConfigValue>
<ExpectedValue>OFF</ExpectedValue>
<ExcludeOnExpress>false</ExcludeOnExpress>
<SQLSKU>$Target/Host/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/Edition$</SQLSKU>
<TimeoutSeconds>300</TimeoutSeconds>
</Configuration>
</UnitMonitor>