Database status


Job details

Name: Database status
Platform: Sqlserver
Category: Availability
Description: Checks if all databases have status ONLINE
Long description: A database state specifies the current running mode of that database. The database can be running in one state at a given time and there are seven main states in which a database can exist. The current state of a database can be checked by selecting the state_desc column of the sys.databases catalog view and can have following values: ONLINE, OFFLINE, RESTORING, RECOVERING, RECOVERY PENDING, SUSPECT and EMERGENCY. This alert can be configured to return values (warnings and alarms) based on different states of the database.
Version: 1.7
Default schedule: * * * *
Requires engine install: Yes
Compatibility tag: .[type=‘instance’ & databasetype=‘sqlserver’]/instance[maj_version > ‘2000′ & hasengine=‘YES’ & (engine_edition = ‘Microsoft SQL Server’ engine_edition = ‘Azure SQL Managed Instance’)]

Parameters

Name Default value Description
ignore databases model List of databases (separated by comma) which will be ignored. You can use % (percent sign) to represent wild card characters.
return status when OFFLINE 2 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when a database is in state OFFLINE.
return status when RESTORING 2 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when a database is in state RESTORING.
return status when RECOVERING 2 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when a database is in state RECOVERING.
return status when RECOVERY PENDING 2 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when a database is in state RECOVERY PENDING.
return status when SUSPECT 2 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when a database is in state SUSPECT.
return status when EMERGENCY 2 Return status value (ALARM – 2, WARNING – 1, or OK – 0) when a database is in state EMERGENCY.
Ignore databases when AUTO CLOSE option is ON NO If set to YES all databases with AUTO CLOSE option turned ON will be ignored.
ignore standby databases YES Ignore databases with IsInStandBy = 1.
ignore OLD status NO Ignore databases if status (OFFLINE, EMERGENCY, RECOVERING, RESTORING or SUSPECT) have been registered for a period of time controlled by parameter “ignore status time threshold”.
ignore status time threshold 96 If the parameter “ignore OLD status” is set to “YES“ and the database has been in state OFFLINE, EMERGENCY, RECOVERING, RESTORING or SUSPECT for a period that exceeds the value of this parameter (in hours), then the database will be ignored.

Job Summary

Purpose

Why

Manual Checking

SELECT name, state_desc FROM sys.databases;

Implementation Details

Dependencies

Parameters Used

Tables and Reports

Function Description
Table Creation Creates ‘dbw_database_status_hist’ for storing historical data of database states.
Historical Data Reporting Reports last 50 state changes where state was other than ‘ONLINE’. Includes information like database, state, the duration of the state, and timestamps.

Upgrades and Maintenance

Monitoring Job Outputs

Operational Handling