Module: check_mk
Branch: master
Commit: eb7488a2c74d732964fbe61b3a778650dccd2203
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eb7488a2c74d73…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Aug 7 08:13:01 2017 +0200
5090 mssql_databases: Database status is now configurable
The following states are configurable:
ONLINE, OFFLINE, RESTORING, RECOVERING,
RECOVERY PENDING, SUSPECT, EMERGENCY
Change-Id: Ice0ffc28d3c458caf34c234056dfe7e7ac339d15
---
.werks/5090 | 12 ++++++++++++
checks/mssql_databases | 13 +++++++++++--
web/plugins/wato/check_parameters.py | 13 +++++++++++++
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/.werks/5090 b/.werks/5090
new file mode 100644
index 0000000..ac2cb15
--- /dev/null
+++ b/.werks/5090
@@ -0,0 +1,12 @@
+Title: mssql_databases: Database status is now configurable
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1502085314
+Class: feature
+
+The following states are configurable:
+ONLINE, OFFLINE, RESTORING, RECOVERING,
+RECOVERY PENDING, SUSPECT, EMERGENCY
diff --git a/checks/mssql_databases b/checks/mssql_databases
index 7fdd75d..363fa0d 100644
--- a/checks/mssql_databases
+++ b/checks/mssql_databases
@@ -36,6 +36,7 @@
# MSSQL_MSSQL46 NOC_CONFIG_T ONLINE FULL 0 0^M
# MSSQL_MSSQL46 tempdb ONLINE SIMPLE 0 0^M
# MSSQL_MSSQL46 test_autoclose ONLINE FULL 1 0^M
+# MSSQL_MSSQL46 test_autoclose RECOVERY PENDING FULL 1 0^M
def parse_mssql_databases(info):
@@ -44,9 +45,16 @@ def parse_mssql_databases(info):
'Recovery', 'auto_close', 'auto_shrink']
for line in info:
+ if line == headers:
+ continue
+
if len(line) == 6:
data = dict(zip(headers, line))
- parsed.setdefault("%s %s" % (data["Instance"],
data["DBname"]), data)
+ elif len(line) == 7:
+ data = dict(zip(headers, line[:2] + ["%s %s" % (line[2], line[3])]
+ line[-3:]))
+ else:
+ continue
+ parsed.setdefault("%s %s" % (data["Instance"],
data["DBname"]), data)
return parsed
@@ -61,7 +69,8 @@ def check_mssql_databases(item, params, parsed):
if item in parsed:
data = parsed[item]
- yield 0, 'Status: %s, Recovery: %s' % (data["Status"],
data["Recovery"])
+ db_state = params.get("map_db_states",
{}).get(data["Status"], 0)
+ yield db_state, 'Status: %s, Recovery: %s' % (data["Status"],
data["Recovery"])
for what in ["close", "shrink"]:
state, state_readable = map_states[data["auto_%s" % what]]
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index d4ece82..10855f1 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -2573,6 +2573,19 @@ register_check_parameters(
_("MSSQL Databases properties"),
Dictionary(
elements = [
+ ("map_db_states", Dictionary(
+ elements = [
+ ("ONLINE", MonitoringState(title=_("Database
Online"))),
+ ("OFFLINE", MonitoringState(title=_("Database
Offline"))),
+ ("RESTORING", MonitoringState(title=_("Database Files
are restored"))),
+ ("RECOVERING", MonitoringState(title=_("Database is
being recovered"))),
+ ("RECOVERY PENDING", MonitoringState(title=_("Database
must be recovered"))),
+ ("SUSPECT", MonitoringState(title=_("Database
Suspect"))),
+ ("EMERGENCY", MonitoringState(title=_("Database
changed to emergency"))),
+ ],
+ title = _('Map Database States'),
+ optional_keys = [],
+ )),
("map_auto_close_state", Dictionary(
elements = [
( "on", MonitoringState(title=_("Auto close
on"), default_value=1) ),