Module: check_mk
Branch: master
Commit: af144e3c313cb312fe831e42daedb1dea51ef6e3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=af144e3c313cb3…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jan 10 14:56:40 2017 +0100
4259 FIX aix_sap_processlist: fixed ValueError; if process has stopped and does not report
any start time
Change-Id: Ic56981d29e48a3886f8eb5b579b711736fed1c30
---
.werks/4259 | 10 ++++++
ChangeLog | 1 +
checks/aix_sap_processlist | 87 +++++++++++++++++++++++++++++++---------------
3 files changed, 70 insertions(+), 28 deletions(-)
diff --git a/.werks/4259 b/.werks/4259
new file mode 100644
index 0000000..0b22d01
--- /dev/null
+++ b/.werks/4259
@@ -0,0 +1,10 @@
+Title: aix_sap_processlist: fixed ValueError; if process has stopped and does not report
any start time
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i4
+Date: 1484056407
+
+
diff --git a/ChangeLog b/ChangeLog
index 553214e..6260396 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@
* 4230 FIX: db2_logsizes Removed debug output (regression since 1.4.0i3)
* 4232 FIX: tsm_storagepools: Fixed missing perfdata
* 4233 FIX: cisco_temp_sensor: Fixed possible wrong calculated thresholds
+ * 4259 FIX: aix_sap_processlist: fixed ValueError; if process has stopped and does
not report any start time
Multisite:
* 4169 View action: Default values of sticky, notification and persistent options can
now be configured via global settings....
diff --git a/checks/aix_sap_processlist b/checks/aix_sap_processlist
index 087fe0b..48cf170 100644
--- a/checks/aix_sap_processlist
+++ b/checks/aix_sap_processlist
@@ -24,6 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+
# Example output from agent:
# <<<aix_sap_processlist:sep(44)>>>
# [01]
@@ -41,52 +42,82 @@
# GetProcessList
# FAIL: NIECONN_REFUSED (Connection refused), NiRawConnect failed in plugin_fopen()
+# <<<aix_sap_processlist:sep(44)>>>
+# [04]
+# 10.01.2017 09:10:41
+# GetProcessList
+# OK
+# name, description, dispstatus, textstatus, starttime, elapsedtime, pid
+# msg_server, MessageServer, GREEN, Running, 2017 01 08 14:38:18, 42:32:23, 12714224
+# disp+work, Dispatcher, GREEN, Running, 2017 01 08 14:38:18, 42:32:23, 15794214
+# aaaaaaaa, Central Syslog Collector, GRAY, Stopped, , , 9961478
+# bbbbbbbb, Central Syslog Sender, GRAY, Stopped, , , 9109548
+
def parse_aix_sap_processlist(info):
- instance = None
- new_info = []
+ instance, description = None, None
+ parsed = {}
for line in info:
if line[0].startswith('['):
instance = line[0][1:-1]
+
elif instance and line[0].startswith("FAIL:"):
instance = None
+
elif instance and len(line) == 7 and line[-1] != " pid":
description, status, textstatus, start = map(lambda x: re.sub("^
","",x), line[1:5])
- start_time = time.strptime(start, "%Y %m %d %H:%M:%S")
- new_info.append([instance, description, status, textstatus, start_time])
+
elif instance and len(line) == 9:
description, status, textstatus = map(lambda x: re.sub("^
","",x), line[1:4])
- start = re.sub("^ ","",line[6])
- start_time = time.strptime(start, "%Y %m %d %H:%M:%S")
- new_info.append([instance, description, status, textstatus, start_time])
- return new_info
+ start = re.sub("^ ","", line[6])
-def inventory_aix_sap_processlist(info):
- for line in info:
- item = "%s on Instance %s" % (line[1], line[0])
- yield item, None
+ else:
+ continue
+
+ if instance is not None and description is not None:
+ itemname = "%s on Instance %s" % (description, instance)
+ parsed.setdefault(itemname, { "status" : status,
"textstatus" : textstatus })
+ try:
+ parsed[itemname]["start_time"] = time.strptime(start, "%Y
%m %d %H:%M:%S")
+ except ValueError:
+ continue
+
+ return parsed
+
+
+def inventory_aix_sap_processlist(parsed):
+ for entry in parsed:
+ yield entry, None
-def check_aix_sap_processlist(item, _no_params, info):
- now = time.time()
- for line in info:
- if item == "%s on Instance %s" % (line[1], line[0]):
- start = time.strftime("%c", line[4])
- elapsed = now - time.mktime(line[4])
- infotext = "%s, Start Time: %s, Elapsed Time: %s" % (line[3],
start, get_age_human_readable(elapsed))
- perfdata = [ ("runtime", elapsed) ]
- if line[2] == "GREEN":
- state = 0
- elif line[2] == "YELLOW":
- state = 1
- else:
- state = 2
- return state, infotext, perfdata
+
+def check_aix_sap_processlist(item, _no_params, parsed):
+ if item in parsed:
+ data = parsed[item]
+ status = data["status"]
+ textstatus = data["textstatus"]
+ infotexts = [ "Status: %s" % textstatus ]
+ perfdata = []
+
+ if "start_time" in data:
+ start_time = data["start_time"]
+ start = time.strftime("%c", start_time)
+ elapsed = time.time() - time.mktime(start_time)
+ perfdata = [ ("runtime", elapsed) ]
+ infotexts.append( "Start Time: %s, Elapsed Time: %s" % (start,
get_age_human_readable(elapsed)) )
+
+ if status == "GREEN":
+ state = 0
+ elif status == "YELLOW":
+ state = 1
+ else:
+ state = 2
+ return state, ", ".join(infotexts), perfdata
check_info["aix_sap_processlist"] = {
+ 'parse_function' : parse_aix_sap_processlist,
'inventory_function' : inventory_aix_sap_processlist,
'check_function' : check_aix_sap_processlist,
- 'parse_function' : parse_aix_sap_processlist,
'service_description' : 'SAP Process %s',
'has_perfdata' : True,
}