Manage Database Log Growth by Using the Troubleshoot-DatabaseSpace.ps1 Script in the Shell
Applies to: Exchange Server 2010 SP3, Exchange Server 2010 SP2
The Troubleshoot-DatabaseSpace.ps1 script is used by Microsoft System Center Operations Manager 2007 to detect and correct any excess log growth or Microsoft Exchange database (.edb) file growth that, if unchecked, may cause database downtime. By default, System Center Operations Manager 2007 runs the script every 15 minutes. However, you can use Task Scheduler to configure and run this script to monitor database log and file growth.
Note
A script must be run from the folder in which it resides. By default, scripts installed with Exchange 2010 are installed at C:\Program Files\Microsoft\Exchange Server\V14\Scripts. The Shell doesn't load scripts automatically. To run a script from the local file, you must precede all scripts with ".</STRONG>" For example, to run the SampleScript.ps1 script, type .\SampleScript.ps1
. To run a script and specify the default installation path, type "C:\Program Files\Microsoft\Exchange Server\V14\Scripts\SampleScript.ps1"
. For more information, see Scripting with the Exchange Management Shell.
The Troubleshoot-DatabaseSpace.ps1 script performs the following actions:
Keeps track of log generation rate for the highest log generators per database. This helps determine which users are logging too heavily and potentially causing space issues.
Keeps track of the available disk space for both the database and the log files. If either of these is within a configurable threshold of being full, further action must be taken.
Keeps track of the log generation rate. If it appears that the disk is going to run out of space within the value specified by the HourThreshold parameter (based on the log generation rate), further action must be taken.
Note
To avoid critical issues, make sure the value for the HourThreshold parameter is large enough to give you time to react during normal business hours while enough free space is available. If drives are filling up faster than the value specified, immediate action must be taken to protect the disk.
If all of the preceding conditions are fulfilled, the script determines the list of top 25 users who accessed the database during the last one-hour period. The script then quarantines the top high-usage mailboxes for which the sum of the log generation rate is greater than the difference between the current generation rate and the sustainable generation rate that would allow tiding over the configurable time threshold. These users are quarantined for six hours, during which they won't have access to e-mail.
If the troubleshooter is unsuccessful at dropping the log generation rate to below the threshold level, it will write out events that translate into health model alerts. At this point, the script removes the database from provisioning by running the Set-MailboxDatabase cmdlet with the ExcludeFromProvisioning parameter set to
$true
against the specified database. You may need to move mailboxes to a new server to rebalance space.If the troubleshooter quarantines more than 10 users, this indicates a systemic issue, which you need to follow up on. The health model will trigger an urgent alert from this condition.
The default settings used in the Troubleshoot-DatabaseSpace.ps1 script are defined in the StoreTSConstants.ps1 script.
Looking for other management tasks related to databases? Check out Managing Mailbox Databases.
Use the Troubleshoot-DatabaseSpace.ps1 script
You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Mailbox databases" entry in the Mailbox Permissions topic.
The following parameter syntax set and table lists the parameters that you can use to move specific mailboxes.
Troubleshoot-DatabaseSpace.ps1 -MailboxDatabaseName <DatabaseID> [-PercentEdbFreeSpaceThreshold <1-99>] [-PercentLogFreeSpaceThreshold <1-99>] [-HourThreshold <1- 1000000000>] [-Quarantine <switch>] [-MonitoringContext <switch>]
Troubleshoot-DatabaseSpace.ps1 -Server <ServerID> [-PercentEdbFreeSpaceThreshold <1-99>] [-PercentLogFreeSpaceThreshold <1-99>] [-HourThreshold <1- 1000000000>] [-Quarantine <switch>] [-MonitoringContext <switch>]
Parameter | Required | Description |
---|---|---|
MailboxDatabaseName |
Required |
The MailboxDatabaseName parameter specifies the mailbox database on which you're monitoring the log growth. This parameter accepts the following values:
Note You can't use this parameter in conjunction with the Server parameter. |
Server |
Required |
The Server parameter specifies the Mailbox server on which you're monitoring the log growth for all mailbox databases. Note You can't use this parameter in conjunction with the MailboxDatabaseName parameter. |
HourThreshold |
Optional |
The HourThreshold parameter specifies the number of hours you can wait until running out of space. The default value is 12 hours. |
MonitoringContext |
Optional |
The MonitoringContext parameter specifies whether the results of the command include monitoring events to be written in the regular Application logs in Event Viewer and in the Operations log. If you don't specify this value, the Operations logs will be written to the following location in Event Viewer: Event Viewer > Application and Services Logs > Microsoft-Exchange-Troubleshooters/Operational. You don't have to specify a value for this parameter. |
PercentEdbFreeSpaceThreshold |
Optional |
The PercentEdbFreeSpaceThreshold parameter specifies the percentage of disk space for the .edb file at which Exchange should begin quarantining users. For example, if you specify 10 percent, Exchange will begin quarantining the heaviest users when the command detects that the hard drive will run out of space due to growth of the .edb file within the time specified in the HourThreshold parameter. The default value for this parameter is 25 percent. |
PercentLogFreeSpaceThreshold |
Optional |
The PercentLogFreeSpaceThreshold parameter specifies the percentage of disk space for the log files at which Exchange should begin quarantining users. For example, if you specify 10 percent, Exchange will begin quarantining the heaviest users when the command detects that the hard drive will run out of space due to log growth within the time specified in the HourThreshold parameter. The default value for this parameter is 25 percent. |
Quarantine |
Optional |
The Quarantine parameter specifies that heavy users will be quarantined. If you don't specify this parameter, users won't be quarantined. You don't need to specify a value for this parameter. |
Example
This example shows how to run the Troubleshoot-DatabaseSpace.ps1 script with the following settings:
The warnings are set at 10 percent free space in the volume containing the database logs and 10 percent free space in the database file and the volume containing it.
The hour threshold is set at 5 hours.
With these settings, if the troubleshooter determines that the free space on the hard drive will be at 10 percent or less capacity within 5 hours, it will quarantine the heaviest users.
.\Troubleshoot-databasespace.ps1 -server MBX01 -PercentLogFreeSpace 10 -PercentEDBFreeSpace 10 -HourThreshold 5 -Quarantine
Note
This example shows how to run the command manually once. To produce the data that the troubleshooter needs to effectively monitor your server or database, you must run this command several times at regular intervals. We recommend that you use the Task Scheduler in the Microsoft Windows operating system to set up this task. For more information, see Task Scheduler Overview.
View the log growth troubleshooter output
In Event Viewer, the results of the Troubleshoot-DatabaseSpace.ps1 script will be available in the following location: Event Viewer > Application and Services Logs > Microsoft-Exchange-Troubleshooters/Operational.
For example, the following represents output from event ID 5101. This output would be returned if the script ran successfully without errors.
The database space troubleshooter finished on volume D:\ for database MBD01, no problems were detected. EDB drive free space: 151938752512 B Log drive free space: 151845265408 B EDB free space threshold: 10% Log free space threshold: 10% Hour threshold: 12 Hrs Current growth rate: 314572800 B/Hr |
The following table displays the event ID, the description of the event, and if necessary, the action to take.
Note
The descriptions in this table are examples of the information that may be included in these events.
Event ID | Description | Action |
---|---|---|
5100 |
The database space troubleshooter started on volume D:\ for database MBD01. |
Informational only. No action is required. |
5101 |
The database space troubleshooter finished on volume D:\ for database MBD01. No problems were detected. |
Informational only. No action is required. |
5400 |
The database space troubleshooter finished on volume D:\ for database MBD01. The database is over the free space threshold. Users were quarantined to avoid running out of space. |
Warning event: Continue monitoring. Users will be quarantined for six hours and won't be able to access their mailboxes. |
5401 |
The database space troubleshooter finished on volume D:\ for database MBD01. The database is under the free space threshold, but not growing at an unusual rate. No action was taken. |
Warning event: Continue monitoring. |
5410 |
The database space troubleshooter quarantined mailbox f3bb8007-b6d1-45f5-b748-211d66fa43f6 in database MBD01. |
Warning event: This event will be created when event 5400 is created. Continue monitoring. |
5700 |
The database space troubleshooter finished on volume D:\ for database MBD01. The database is over the free space threshold and continues to grow. Manual intervention is required. |
This error event indicates that the database space is over the free space threshold. Run the Microsoft Exchange Server User Monitor tool (Exmon) to track users or services that are creating excessive log growth. For details, see Microsoft Exchange Server User Monitor. |
5701 |
The database space troubleshooter detected a low space condition on volume D:\ for database MBD01. Provisioning for this database has been disabled. Free space for this database is less than 10 percent. |
This error event indicates that the database has been removed from provisioning. In this case, the script runs the Set-MailboxDatabase cmdlet with the ExcludeFromProvisioning parameter set to You may need to move mailboxes to a new server to rebalance space. |
5702 |
The database space troubleshooter has detected a critically low space condition on volume D:\ for database MBD01. Provisioning for this database has been disabled. Free space for this database is less than 10 percent. |
This error event indicates that the database has been removed from provisioning because resources are critically low. In this case, the script runs the Set-MailboxDatabase cmdlet with the ExcludeFromProvisioning parameter set to You may need to move users to a new database to rebalance space. |
© 2010 Microsoft Corporation. All rights reserved.