• I'm working at some monitoringprocedures (some nagios-server has to monitor a sql server).

    I found already some databasestates, but now I have to classify them in OK/warning/critical.

    warning= states 4096 - 256 -  1024 - 32768 - 512 - 528??

    critical = states 64 - 128 - 2048 - 320 - 1???

    case @databasestate

    when (1) then  convert(char(10), @databasestate) + ': autoclose; set with sp_dboption.'

    when (4) then  convert(char(10), @databasestate) + ': select into/bulkcopy; set with sp_dboption.'

    when (8) then  convert(char(10), @databasestate) + ': trunc. log on chkpt; set with sp_dboption.'

    when (16) then  convert(char(10), @databasestate) + ': torn page detection, set with sp_dboption.'

    when (24) then  convert(char(10), @databasestate) + ': trunc. log on chkpt + torn page detection'

    when (28) then  convert(char(10), @databasestate) + ': select into/bulkcopy +  trunc. log on chkpt + torn page detection'

    when (32) then  convert(char(10), @databasestate) + ': loading.'

    when (64) then  convert(char(10), @databasestate) + ': pre recovery.'

    when (128) then  convert(char(10), @databasestate) + ': recovering.'

    when (256) then  convert(char(10), @databasestate) + ': not recovered.'

    when (320) then  convert(char(10), @databasestate) + ': not recovered. + pre recovery. Suspect'

    when (512) then  convert(char(10), @databasestate) + ': offline; set with sp_dboption.'

    when (528) then  convert(char(10), @databasestate) + ': offline + torn page detection'

    when (1024) then  convert(char(10), @databasestate) + ': read only; set with sp_dboption.'

    when (2048) then  convert(char(10), @databasestate) + ': dbo use only; set with sp_dboption.'

    when (4096) then  convert(char(10), @databasestate) + ': single user; set with sp_dboption.'

    when (32768) then  convert(char(10), @databasestate) + ': emergency mode.'

    when (4194304) then  convert(char(10), @databasestate) + ': autoshrink.'

    when (16777216) then  convert(char(10), @databasestate) + ': auto create statistics.'

    when (1073741824) then  convert(char(10), @databasestate) + ': cleanly shutdown.'

    when (1090519040) then  convert(char(10), @databasestate) + ': Auto Update Statistics + auto create statistics.'

    when (1073741840) then  convert(char(10), @databasestate) + ': cleanly shutdown. + torn page detection'