Module: check_mk
Branch: master
Commit: 9b3b675bbfdf5ed86ed0d4645115efefcdab69eb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9b3b675bbfdf5e…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Nov 3 15:03:17 2015 +0100
#2708 sap, sap_state: new sap_state service reports connection problems to sap hosts
The new sap_state service will be discovered on the host(s) running the sap agent plugin,
one service
for each configured host.
This service will report all problems preventing the system from reporting information
about the sap
instance.
The remaining sap services will now not become "unknown", but keep their last
state and turn stale
after a while.
---
.werks/2708 | 14 ++++++++++++++
ChangeLog | 1 +
agents/plugins/mk_sap | 5 +++++
checkman/sap_state | 18 +++++++++++++++++
checks/sap | 19 ++++++++++++++----
checks/sap_state | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 104 insertions(+), 4 deletions(-)
diff --git a/.werks/2708 b/.werks/2708
new file mode 100644
index 0000000..bb7baee
--- /dev/null
+++ b/.werks/2708
@@ -0,0 +1,14 @@
+Title: sap, sap_state: new sap_state service reports connection problems to sap hosts
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1446559117
+Class: feature
+
+The new sap_state service will be discovered on the host(s) running the sap agent plugin,
one service
+for each configured host.
+This service will report all problems preventing the system from reporting information
about the sap
+instance.
+The remaining sap services will now not become "unknown", but keep their last
state and turn stale
+after a while.
diff --git a/ChangeLog b/ChangeLog
index 5bbea07..312d690 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,7 @@
* 2444 lnx_if: now able to detect interfaces which "break" during
runtime...
* 2720 nullmailer_mailq: New check for monitoring the outgoing mail queue of
Nullmailer...
* 2707 winperf_processor: can now be configured to warn if a single cpu core exceeds
a utilization threshold for a while...
+ * 2708 sap, sap_state: new sap_state service reports connection problems to sap
hosts...
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/agents/plugins/mk_sap b/agents/plugins/mk_sap
index 7303dac..146dcbc 100755
--- a/agents/plugins/mk_sap
+++ b/agents/plugins/mk_sap
@@ -468,11 +468,16 @@ try:
for entry in cfg:
try:
check(entry)
+ sys.stdout.write('<<<sap_state:sep(9)>>>\n%s\tOK\n'
% entry['ashost'])
except sapnwrfc.RFCCommunicationError, e:
sys.stderr.write('ERROR: Unable to connect (%s)\n' % e)
+ sys.stdout.write('<<<sap_state:sep(9)>>>\n%s\tUnable to
connect (%s)\n' %\
+ (entry['ashost'], e))
processed_all = False
except Exception, e:
sys.stderr.write('ERROR: Unhandled exception (%s)\n' % e)
+ sys.stdout.write('<<<sap_state:sep(9)>>>\n%s\tUnhandled
exception (%s)\n' %\
+ (entry['ashost'], e))
processed_all = False
# Now check whether or not an old logfile needs to be removed. This can only
diff --git a/checkman/sap_state b/checkman/sap_state
new file mode 100644
index 0000000..3689db4
--- /dev/null
+++ b/checkman/sap_state
@@ -0,0 +1,18 @@
+title: SAP Host State
+agents: linux
+catalog: app/sap
+license: GPL
+distribution: check_mk
+description:
+ This check reports the state of monitored sap hosts. It turns critical if
+ there is any communication error (including failed login).
+ Please note that this check appears on systems configured to monitor
+ sap instances, that is: the system with the mk_sap agent plugin, whereas
+ the other sap checks appear on a host named after the sap instance.
+
+item:
+ The item name is the hostname of the monitored system.
+
+inventory:
+ The check creates one item for each host configured in sap.cfg
+
diff --git a/checks/sap b/checks/sap
index e508d72..8f165f4 100644
--- a/checks/sap
+++ b/checks/sap
@@ -41,7 +41,7 @@ def inventory_sap_dialog(info):
return inv
def check_sap_dialog(item, params, info):
- # First xtract all infos
+ # First extract all infos
dialog = {}
for line in info:
if line[0] == item and line[3].startswith('SAP CCMS Monitor Templates/Dialog
Overview/'):
@@ -51,7 +51,14 @@ def check_sap_dialog(item, params, info):
dialog[key] = perfval, uom
if not dialog:
- return (3, 'Unable to find dialog monitoring data in agent output')
+ # this isn't perfect. Sap data is delivered as piggyback output. Potentially
mulitple
+ # hosts can each send data for multiple sap instances. The data can also
overlap.
+ # This means technically we may not get here and report then incomplete data if
one host is
+ # down.
+ # And we would get here if the host isn't down if the item has simply
disappeared from
+ # the output.
+ # There is no way inside this check to determine the host(s) that sent the data
in info.
+ raise MKCounterWrapped("no output about sap dialogs in agent output")
def perf_clean_key(s):
return s.replace('(', '_').replace(')',
'_').replace(' ', '_').replace('.',
'_').rstrip('_')
@@ -124,6 +131,7 @@ def sap_value_path_matches(path, pattern):
def check_sap_value(item, params, info):
status = None
perfdata = []
+
for line in info:
if params.get('limit_item_levels'):
this_path =
'/'.join(line[3].split('/')[-params.get('limit_item_levels'):])
@@ -144,7 +152,7 @@ def check_sap_value(item, params, info):
break
if status is None:
- return (3, 'Unable to find the required value in agent output')
+ raise MKCounterWrapped("no output about sap value in agent output")
return (status, output, perfdata)
@@ -199,7 +207,7 @@ def check_sap_value_groups( item, params, info ):
backend = []
count_ok = 0
count_crit = 0
- state = 0
+ state = None
for line in info:
path = line[3]
if item in sap_groups_of_value( path, params ):
@@ -215,6 +223,9 @@ def check_sap_value_groups( item, params, info ):
else:
count_ok += 1
+ if state is None:
+ raise MKCounterWrapped("no output about sap value groups in agent
output")
+
return state, "%s OK, %s Crit %s\n%s" % ( count_ok, count_crit, ",
".join(frontend), "\n".join(backend) )
diff --git a/checks/sap_state b/checks/sap_state
new file mode 100644
index 0000000..a9aacc8
--- /dev/null
+++ b/checks/sap_state
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# 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-
+# ails. 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.
+
+
+def inventory_sap_state(info):
+ for node, value in info:
+ yield node, None
+
+
+def check_sap_state(item, _no_parameters, info):
+ def value_to_status(value):
+ if value == "OK":
+ return 0
+ else:
+ return 2
+
+ for node, value in info:
+ if node == item:
+ return value_to_status(value), value
+
+
+check_info['sap_state'] = {
+ "check_function" : check_sap_state,
+ "inventory_function" : inventory_sap_state,
+ "service_description" : "SAP State %s",
+ "has_perfdata" : True,
+}
+