Module: check_mk
Branch: master
Commit: 74e85d40ca2402ecf48d3a37a6a79b7194f1db34
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=74e85d40ca2402…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Oct 18 13:23:22 2017 +0200
5345 FIX mssql_backup: fix GUI error and show warn/crit values
Fixes an error visible in the GUI when no parameters are present
for the check. The check now also shows warn and crit values for
a backup type if it is in a warning or critical state.
Change-Id: I251d6a9880943df55037d864d4ab199df29c6229
---
.werks/5345 | 12 ++++++++++++
checks/mssql_backup | 26 +++++++++++++++-----------
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/.werks/5345 b/.werks/5345
new file mode 100644
index 0000000..8c00bcd
--- /dev/null
+++ b/.werks/5345
@@ -0,0 +1,12 @@
+Title: mssql_backup: fix GUI error and show warn/crit values
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1508325570
+Class: fix
+
+Fixes an error visible in the GUI when no parameters are present
+for the check. The check now also shows warn and crit values for
+a backup type if it is in a warning or critical state.
diff --git a/checks/mssql_backup b/checks/mssql_backup
index 7331bb5..5a826db 100644
--- a/checks/mssql_backup
+++ b/checks/mssql_backup
@@ -48,16 +48,15 @@
# Might be None to have no thresholds or a tuple of two ints
# (<warn age in seconds>, <crit age in seconds>)
-### mssql_backup_default_levels = None
factory_settings["mssql_backup_default_levels"] = {
- "database": (None, None),
- "database_diff": (None, None),
- "log": (None, None),
- "file_or_filegroup": (None, None),
- "file_diff": (None, None),
- "partial": (None, None),
- "partial_diff": (None, None),
- "unspecific": (None, None)
+ "database": (0, 0),
+ "database_diff": (0, 0),
+ "log": (0, 0),
+ "file_or_filegroup": (0, 0),
+ "file_diff": (0, 0),
+ "partial": (0, 0),
+ "partial_diff": (0, 0),
+ "unspecific": (0, 0)
}
@@ -134,11 +133,11 @@ def check_mssql_backup(item, params, parsed):
age_warn, age_crit = params["database"]
else:
backup_type_var = backup_type_name.strip().replace(" ",
"_")
- age_warn, age_crit = params.get(backup_type_var, (None, None))
+ age_warn, age_crit = params[backup_type_var]
state = 0
sec_ago = time.time() - timestamp
- if age_warn is not None and age_crit is not None:
+ if age_warn > 0 and age_crit > 0:
if sec_ago >= age_crit:
state = 2
elif sec_ago >= age_warn:
@@ -151,6 +150,11 @@ def check_mssql_backup(item, params, parsed):
get_age_human_readable(sec_ago)
)
+ if state != 0:
+ infotext += " (warn/crit at %s/%s)" % (
+ get_age_human_readable(age_warn), get_age_human_readable(age_crit)
+ )
+
yield state, infotext, perfdata
if not found_instance: