Module: check_mk
Branch: master
Commit: cbd2271a1c76162f730c3eedf2c35942e22a975f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cbd2271a1c7616…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri Jul 13 08:07:57 2018 +0200
oracle_logswitches: use factory_settings
Change-Id: I260902cc2a8f060c4839c56da37ab17259196c88
---
checks/oracle_logswitches | 21 ++++++++--
cmk/gui/plugins/wato/check_parameters.py | 70 +++++++++++++++++++++++---------
2 files changed, 67 insertions(+), 24 deletions(-)
diff --git a/checks/oracle_logswitches b/checks/oracle_logswitches
index 45827f8..7020022 100644
--- a/checks/oracle_logswitches
+++ b/checks/oracle_logswitches
@@ -28,13 +28,24 @@
# pengt 15
# hirni 22
-oracle_logswitches_default_levels = (-1, -1, 50, 100)
+factory_settings["oracle_logswitches_default_levels"] = {
+ 'levels': (50, 100),
+ 'levels_lower': (-1, -1),
+}
+
def inventory_oracle_logswitches(info):
oracle_handle_ora_errors_discovery(info)
- return [ (line[0], "oracle_logswitches_default_levels") for line in info if
len(line) >= 2 ]
+ return [(line[0], {}) for line in info if len(line) >= 2]
+
def check_oracle_logswitches(item, params, info):
+
+ if isinstance(params, tuple):
+ params = {'levels': (params[2], params [3]),
+ 'levels_lower': (params[1], params[0]),
+ }
+
for line in info:
if line[0] == item:
err = oracle_handle_ora_errors(line)
@@ -43,11 +54,12 @@ def check_oracle_logswitches(item, params, info):
elif isinstance(err, tuple):
return err
- locrit, lowarn, warn, crit = params
+ lowarn, locrit = params['levels_lower']
+ warn, crit = params['levels']
logswitches = int(line[1])
infotext = "%d log switches in the last 60 minutes (warn/crit below
%d/%d) (warn/crit at %d/%d)" \
% (logswitches, locrit, lowarn, warn, crit)
- perfdata = [("logswitches", logswitches, warn, crit)]
+ perfdata = [("logswitches", logswitches, warn, crit, 0, None)]
if logswitches >= crit or logswitches <= locrit:
return (2, infotext, perfdata)
elif logswitches >= warn or logswitches <= lowarn:
@@ -67,5 +79,6 @@ check_info["oracle_logswitches"] = {
'service_description': 'ORA %s Logswitches',
'has_perfdata': True,
'group': 'oracle_logswitches',
+ 'default_levels_variable': 'oracle_logswitches_default_levels',
'includes': ['oracle.include'],
}
diff --git a/cmk/gui/plugins/wato/check_parameters.py
b/cmk/gui/plugins/wato/check_parameters.py
index 4b68afb..9fe5a49 100644
--- a/cmk/gui/plugins/wato/check_parameters.py
+++ b/cmk/gui/plugins/wato/check_parameters.py
@@ -4618,6 +4618,56 @@ register_check_parameters(
match_type = "dict",
)
+def transform_oracle_logswitches(params):
+ if isinstance(params, tuple):
+ return {'levels': (params[2], params[3]),
+ 'levels_lower': (params[1], params[0]),
+ }
+ return params
+
+register_check_parameters(
+ subgroup_applications,
+ "oracle_logswitches",
+ _("Oracle Logswitches"),
+ Transform(
+ Dictionary(
+ help = _("This check monitors the number of log switches of an ORACLE
"
+ "database instance in the last 60 minutes. You can set levels
"
+ "for upper and lower bounds."),
+ elements = [
+ ('levels', Tuple(
+ title = _("Set upper Levels"),
+ elements = [
+ Integer(title = _("Warning at or above"),
+ unit = _("log switches / hour"),
+ default_value = 50),
+ Integer(title = _("Critical at or above"),
+ unit = _("log switches / hour"),
+ default_value = 100),
+ ]),
+ ),
+ ('levels_lower', Tuple(
+ title = _("Set lower Levels"),
+ elements = [
+ Integer(title = _("Warning at or below"),
+ unit = _("log switches / hour"),
+ default_value = -1),
+ Integer(title = _("Critical at or below"),
+ unit = _("log switches / hour"),
+ default_value = -1),
+ ]),
+ ),
+ ],
+ ),
+ forth = transform_oracle_logswitches,
+ ),
+ TextAscii(
+ title = _("Database SID"),
+ size = 12,
+ allow_empty = False),
+ "first",
+)
+
#.
# .--Environment---------------------------------------------------------.
# | _____ _ _ |
@@ -10016,26 +10066,6 @@ register_check_parameters(
register_check_parameters(
subgroup_applications,
- "oracle_logswitches",
- _("Oracle Logswitches"),
- Tuple(
- help = _("This check monitors the number of log switches of an ORACLE
"
- "database instance in the last 60 minutes. You can set levels for
upper and lower bounds."),
- elements = [
- Integer(title = _("Critical at or below"), unit=_("log
switches / hour"), default_value = -1),
- Integer(title = _("Warning at or below"), unit=_("log
switches / hour"), default_value = -1),
- Integer(title = _("Warning at or above"), unit=_("log
switches / hour"), default_value = 50),
- Integer(title = _("Critical at or above"), unit=_("log
switches / hour"), default_value = 100),
- ]),
- TextAscii(
- title = _("Database SID"),
- size = 12,
- allow_empty = False),
- "first",
-)
-
-register_check_parameters(
- subgroup_applications,
"oracle_recovery_area",
_("Oracle Recovery Area"),
Dictionary(