Module: check_mk
Branch: master
Commit: 814898d914e0b32e30a0f8fb8507a6f3e15b4140
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=814898d914e0b3…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jun 26 10:54:26 2018 +0200
6143 FIX mssql_backup: Fixed crash if check gots old-style parameters
Change-Id: I3eddea73fa940f1bfb064f4a82856578ac88e85e
---
.werks/6143 | 10 ++++++++++
checks/mssql_backup | 27 ++++++---------------------
web/plugins/wato/check_parameters.py | 25 +------------------------
3 files changed, 17 insertions(+), 45 deletions(-)
diff --git a/.werks/6143 b/.werks/6143
new file mode 100644
index 0000000..f2e398b
--- /dev/null
+++ b/.werks/6143
@@ -0,0 +1,10 @@
+Title: mssql_backup: Fixed crash if check gots old-style parameters
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1530003130
+Class: fix
+
+
diff --git a/checks/mssql_backup b/checks/mssql_backup
index e20e094..f2ad4a4 100644
--- a/checks/mssql_backup
+++ b/checks/mssql_backup
@@ -46,19 +46,6 @@
# MSSQL_SQL0x msdb 2016-07-08 20:20:43 D
# MSSQL_SQL0x msdb 2016-07-11 20:20:07 I
-# Might be None to have no thresholds or a tuple of two ints
-# (<warn age in seconds>, <crit age in seconds>)
-factory_settings["mssql_backup_default_levels"] = {
- "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)
-}
-
def parse_mssql_backup(info):
@@ -126,22 +113,21 @@ def check_mssql_backup(item, params, parsed):
continue
found_instance = True
- if type(params) != dict:
+ if not isinstance(params, dict):
params = {"database": params}
if backup_type_name == "": # use "database" parameters as
default for old agent output
age_warn, age_crit = params["database"]
else:
backup_type_var = backup_type_name.strip().replace(" ",
"_")
- age_warn, age_crit = params[backup_type_var]
+ age_warn, age_crit = params.get(backup_type_var, (None, None))
state = 0
sec_ago = time.time() - timestamp
- if age_warn > 0 and age_crit > 0:
- if sec_ago >= age_crit:
- state = 2
- elif sec_ago >= age_warn:
- state = 1
+ if age_crit is not None and sec_ago >= age_crit:
+ state = 2
+ elif age_warn is not None and sec_ago >= age_warn:
+ state = 1
perfdata = [(perfkey, sec_ago, age_warn, age_crit)]
infotext = 'Last %sbackup was at %s (%s ago)' % (
@@ -167,7 +153,6 @@ check_info['mssql_backup'] = {
'parse_function': parse_mssql_backup,
'check_function': check_mssql_backup,
'inventory_function': inventory_mssql_backup,
- 'default_levels_variable': 'mssql_backup_default_levels',
'service_description': 'MSSQL %s Backup',
'has_perfdata': True,
'group': 'mssql_backup',
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index db4aaf7..4748f70 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -10290,29 +10290,6 @@ register_check_parameters(
"dict"
)
-#register_check_parameters(
-# subgroup_applications,
-# "mssql_backup",
-# _("MSSQL Time since last Backup"),
-# Optional(
-# Tuple(
-# elements = [
-# Age(title = _("Warning if older than")),
-# Age(title = _("Critical if older than"))
-# ]
-# ),
-# title = _("Specify time since last successful backup"),
-# ),
-# TextAscii(
-# title = _("Service descriptions"),
-# allow_empty = False),
-# match_type = "first",
-#)
-#Old rule:
-#checkgroup_parameters['mssql_backup'] = [
-# ( (8640000, 33696000), [], ALL_HOSTS, ALL_SERVICES, {} ),
-#] = checkgroup_parameters['mssql_backup']
-
register_check_parameters(
subgroup_applications,
"mssql_backup",
@@ -10376,7 +10353,7 @@ register_check_parameters(
]
),
- forth = lambda params: (params if type(params) == dict
+ forth = lambda params: (params if isinstance(params, dict)
else {'database': (params[0], params[1])})
),
TextAscii(