Module: check_mk
Branch: master
Commit: fea2f26165365954d1686a2a27201f2645503114
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fea2f261653659…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Tue Oct 25 14:21:54 2016 +0200
3951 FIX oracle_sessions: fixed bug with default absolute levels
When relative levels are given in a rule but no absolute levels, the default levels from
the checkplugin are still used.
This change is compatible and will ignore absolute levels in a given rule, if not
explicitly set. Defaults for absolute levels are still used if no rule is given.
---
.werks/3951 | 10 ++++++++++
ChangeLog | 1 +
checks/oracle_sessions | 3 ++-
web/plugins/wato/check_parameters.py | 38 ++++++++++++++++++++++++------------
4 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/.werks/3951 b/.werks/3951
new file mode 100644
index 0000000..f971508
--- /dev/null
+++ b/.werks/3951
@@ -0,0 +1,10 @@
+Title: oracle_sessions: fixed bug with default absolute levels
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i2
+Date: 1477397596
+Class: fix
+
+When relative levels are given in a rule but no absolute levels, the default levels from
the checkplugin are still used.
+This change is compatible and will ignore absolute levels in a given rule, if not
explicitly set. Defaults for absolute levels are still used if no rule is given.
diff --git a/ChangeLog b/ChangeLog
index fd15f54..79ab9bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -54,6 +54,7 @@
* 3914 FIX: Roles: Aliases are now unique during cloning
* 3820 FIX: Network scan: no longer fails completely if hostname already exists in
configuration...
* 3821 FIX: WATO Network Scan: Fixed risk of loosing site tags when performing a
network scan...
+ * 3951 FIX: oracle_sessions: fixed bug with default absolute levels...
Notifications:
* 3957 mail: now allows extra HTML section between body and table
diff --git a/checks/oracle_sessions b/checks/oracle_sessions
index 048ab12..dfb4ebb 100644
--- a/checks/oracle_sessions
+++ b/checks/oracle_sessions
@@ -115,7 +115,7 @@ def check_oracle_sessions(item, params, parsed):
state = 0
warn, crit = None, None
- if "sessions_abs" in params:
+ if "sessions_abs" in params and not params["sessions_abs"] ==
None:
warn, crit = params["sessions_abs"]
if sessions >= crit:
state = 2
@@ -124,6 +124,7 @@ def check_oracle_sessions(item, params, parsed):
if state:
infotext += " (warn/crit at %d/%d)" % (warn, crit)
yield state, infotext, [ ("sessions", sessions, warn, crit, 0,
sessions_max) ]
+
return
# In case of missing information we assume that the login into
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index ca7c462..929d1ac 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -8720,6 +8720,13 @@ register_check_parameters(
match_type = "first",
)
+def convert_oracle_sessions(value):
+ if isinstance(value, tuple):
+ return {'sessions_abs' : value }
+ if 'sessions_abs' not in value:
+ value['sessions_abs'] = (100, 200)
+ return value
+
register_check_parameters(
subgroup_applications,
"oracle_sessions",
@@ -8728,28 +8735,35 @@ register_check_parameters(
Dictionary(
elements = [
("sessions_abs",
- Tuple(
- title = _("Number of active sessions"),
- help = _("This check monitors the current number of active
sessions on Oracle"),
- elements = [
- Integer(title = _("Warning at"), unit =
_("sessions"), default_value = 100),
- Integer(title = _("Critical at"), unit =
_("sessions"), default_value = 200),
- ],
- ),
- ),
+ Alternative(
+ title = _("Absolute levels of active sessions"),
+ style = "dropdown",
+ help = _("This check monitors the current number of active
sessions on Oracle"),
+ elements = [
+ FixedValue(None, title = _("Do not use absolute
levels"), totext = ""),
+ Tuple(
+ title = _("Number of active sessions"),
+ elements = [
+ Integer(title = _("Warning at"), unit =
_("sessions"), default_value = 100),
+ Integer(title = _("Critical at"), unit =
_("sessions"), default_value = 200),
+ ],
+ ),
+ ],
+ )),
("sessions_perc",
Tuple(
title = _("Relative levels of active sessions."),
- help = _("Set upper levels of active sessions relative to
max. number of sessions."),
+ help = _("Set upper levels of active sessions relative to
max. number of sessions. This is optional."),
elements = [
Percentage(title = _("Warning at")),
Percentage(title = _("Critical at")),
],
),
),
- ]
+ ],
+ optional_keys = ["sessions_perc"],
),
- forth = lambda p: type(p) == tuple and { "sessions_abs" : p } or p,
+ forth = convert_oracle_sessions
),
TextAscii(
title = _("Database name"),