Module: check_mk
Branch: master
Commit: 1f81ebebfd6b2f939f70bfd97b801c144279e7f8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1f81ebebfd6b2f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Aug 31 09:58:22 2016 +0200
3865 oracle_sessions: now relative levels for sessions are configurable
Please note: you have to update the {{mk_oracle}} plugin in order to get new data.
---
.werks/3865 | 9 +++
ChangeLog | 1 +
agents/plugins/mk_oracle | 12 ++--
checks/oracle_sessions | 126 +++++++++++++++++++++++++++-------
web/plugins/wato/check_parameters.py | 37 +++++++---
5 files changed, 145 insertions(+), 40 deletions(-)
diff --git a/.werks/3865 b/.werks/3865
new file mode 100644
index 0000000..a4b079b
--- /dev/null
+++ b/.werks/3865
@@ -0,0 +1,9 @@
+Title: oracle_sessions: now relative levels for sessions are configurable
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i1
+Date: 1472630212
+Class: feature
+
+ Please note: you have to update the {{mk_oracle}} plugin in order to get new data.
diff --git a/ChangeLog b/ChangeLog
index 55efa0f..6b27a0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -148,6 +148,7 @@
* 3834 hitachi_hus_dku, hitachi_hus_dkc: now recognises Hitachi G800/HM800 devices
* 3796 agent_vsphere: new option allows monitoring of ESX hostsystem and windows
agent
* 3797 Check_MK Check helpers: Decreased memory consumption in distributed setups...
+ * 3865 oracle_sessions: now relative levels for sessions are configurable...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/plugins/mk_oracle b/agents/plugins/mk_oracle
index 8c4d6a9..2acbe98 100755
--- a/agents/plugins/mk_oracle
+++ b/agents/plugins/mk_oracle
@@ -529,12 +529,14 @@ sql_instance()
sql_sessions()
{
- echo 'prompt <<<oracle_sessions>>>'
+ echo 'prompt <<<oracle_sessions:sep(124)>>>'
echo "select upper(i.instance_name)
- || ' ' || CURRENT_UTILIZATION
- from v\$resource_limit, v\$instance i
- where RESOURCE_NAME = 'sessions';
- "
+ || '|' || CURRENT_UTILIZATION
+ || '|' || ltrim(LIMIT_VALUE)
+ || '|' || MAX_UTILIZATION
+ from v\$resource_limit, v\$instance i
+ where RESOURCE_NAME = 'sessions';"
+
}
sql_processes()
diff --git a/checks/oracle_sessions b/checks/oracle_sessions
index 82a36dd..048ab12 100644
--- a/checks/oracle_sessions
+++ b/checks/oracle_sessions
@@ -19,7 +19,7 @@
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
-# tails. You should have received a copy of the GNU General Public
+# tails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
@@ -27,32 +27,104 @@
# <<<oracle_sessions>>>
# pengt 15
# hirni 22
+# newdb 47 772 65
-oracle_sessions_default_levels = (50, 100)
-def inventory_oracle_sessions(info):
- oracle_handle_ora_errors_discovery(info)
- return [ (line[0], "oracle_sessions_default_levels") for line in info if
len(line) >= 2 ]
+factory_settings["oracle_sessions_default_levels"] = {
+ "sessions_abs" : (50, 100),
+}
+
-def check_oracle_sessions(item, params, info):
+def parse_oracle_sessions(info):
+ parsed = {}
for line in info:
- if line[0] == item:
- err = oracle_handle_ora_errors(line)
- if err == False:
- continue
- elif isinstance(err, tuple):
- return err
-
- warn, crit = params
- sessions = int(line[1])
- infotext = "%d active sessions (warn/crit at %d/%d)" % (sessions,
warn, crit)
- perfdata = [("sessions", sessions, warn, crit)]
+ if len(line) == 4:
+ # new format with max values
+ sid, cursess, maxsess, curmax = line
+ parsed.setdefault(sid, {
+ "cursess" : int(cursess),
+ "maxsess" : int(maxsess),
+ "curmax" : int(curmax),
+ })
+
+ elif len(line) == 7:
+ # detailed session information for PDBs
+ sid, pdb_name, sstate, smode, stype, bmode, cnt = line
+
+ if pdb_name <> '' and pdb_name <> 'CDB$ROOT':
+ sid = '%s.%s' % (sid, pdb_name)
+
+ if sstate == '':
+ # found a line with only number of sessions
+ # typically found in PDB without any connected session
+ parsed.setdefault(sid, {
+ "count" : cnt,
+ })
+
+ else:
+ parsed.setdefault(sid, {
+ "count" : cnt,
+ "sessstate" : sstate,
+ "sessmode" : smode,
+ "sesstype" : stype,
+ "blockmode" : bmode,
+ })
+
+ elif len(line) == 2:
+ # old agent format!
+ sid, cursess = line
+ parsed.setdefault(sid, {
+ "cursess" : int(cursess),
+ })
+
+ return parsed
+
+
+def inventory_oracle_sessions(parsed):
+ for sid in parsed:
+ if sid.find(".") < 0:
+ yield sid, {}
+
+
+def check_oracle_sessions(item, params, parsed):
+ if type(params) == tuple:
+ params = { "sessions_abs" : params }
+
+ if item in parsed and 'cursess' in parsed[item]:
+ data = parsed[item]
+ sessions = data['cursess']
+ sessions_max = data.get('maxsess')
+
+ if sessions_max is not None:
+ state = 0
+ infotext = "%d of %d sessions" % (sessions, sessions_max)
+ sessions_perc = 100.0*sessions/sessions_max
+ infotext_perc = "%.2f%%" % sessions_perc
+ if "sessions_perc" in params:
+ warn_perc, crit_perc = params["sessions_perc"]
+ if sessions_perc >= crit_perc:
+ state = 2
+ elif sessions_perc >= warn_perc:
+ state = 1
+ if state:
+ infotext_perc += " (warn/crit at %.1f%%/%.1f%%)" %
(warn_perc, crit_perc)
+ yield state, infotext_perc
+
+ else:
+ infotext = "%d sessions" % sessions
+
+ state = 0
+ warn, crit = None, None
+ if "sessions_abs" in params:
+ warn, crit = params["sessions_abs"]
if sessions >= crit:
- return (2, infotext, perfdata)
+ state = 2
elif sessions >= warn:
- return (1, infotext, perfdata)
- else:
- return (0, infotext, perfdata)
+ state = 1
+ 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
# the database has failed and we simply skip this check. It won't
@@ -61,9 +133,11 @@ def check_oracle_sessions(item, params, info):
check_info["oracle_sessions"] = {
- 'check_function': check_oracle_sessions,
- 'inventory_function': inventory_oracle_sessions,
- 'service_description': 'ORA %s Sessions',
- 'has_perfdata': True,
- 'group': 'oracle_sessions',
+ "parse_function" : parse_oracle_sessions,
+ 'inventory_function' : inventory_oracle_sessions,
+ 'check_function' : check_oracle_sessions,
+ 'service_description' : 'ORA %s Sessions',
+ 'has_perfdata' : True,
+ 'group' : 'oracle_sessions',
+ 'default_levels_variable' : 'oracle_sessions_default_levels'
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 45619ce..f6eae09 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -8128,18 +8128,37 @@ register_check_parameters(
subgroup_applications,
"oracle_sessions",
_("Oracle Sessions"),
- 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),
- ],
- ),
+ Transform(
+ 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),
+ ],
+ ),
+ ),
+ ("sessions_perc",
+ Tuple(
+ title = _("Relative levels of active sessions."),
+ help = _("Set upper levels of active sessions relative to
max. number of sessions."),
+ elements = [
+ Percentage(title = _("Warning at")),
+ Percentage(title = _("Critical at")),
+ ],
+ ),
+ ),
+ ]
+ ),
+ forth = lambda p: type(p) == tuple and { "sessions_abs" : p } or p,
+ ),
TextAscii(
title = _("Database name"),
allow_empty = False),
- match_type = "first",
+ match_type = "dict",
)
register_check_parameters(