Module: check_mk
Branch: master
Commit: 42d3c3726a27a32a305ad3524f5929552f0c6690
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42d3c3726a27a3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 28 12:14:41 2014 +0200
tcp_conn_stats: fix missing performance data
---
checks/tcp_conn_stats | 8 +++++---
modules/check_mk_base.py | 14 ++++++++------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/checks/tcp_conn_stats b/checks/tcp_conn_stats
index 032afcc..55fc841 100644
--- a/checks/tcp_conn_stats
+++ b/checks/tcp_conn_stats
@@ -49,10 +49,10 @@ def check_tcp_conn_stats(item, params, info):
stats = dict(info)
for stat_state, hex in tcp_conn_stats_states:
num = int(stats.get(stat_state, stats.get(hex, 0)))
+ state = 0
if num > 0: # Only check positive counts
infotext = "%s: %d" % (stat_state, num)
- state = 0
- perf = [state, num]
+ perf = [stat_state, num]
levels = params.get(stat_state)
if levels:
warn, crit = levels
@@ -64,7 +64,9 @@ def check_tcp_conn_stats(item, params, info):
elif num >= warn:
state = 1
infotext += " (warning at %d)" % warn
- yield state, infotext, [perf]
+ else:
+ infotext = None
+ yield state, infotext, [perf]
check_info["tcp_conn_stats"] = {
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 2494e02..61984e2 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1142,7 +1142,8 @@ def convert_check_result(result):
return subresults[0]
# Several sub results issued with multiple yields. Make that worst sub check
- # decide the total state, join the texts and performance data
+ # decide the total state, join the texts and performance data. Subresults with
+ # an infotext of None are used for adding performance data.
else:
perfdata = []
infotexts = []
@@ -1150,11 +1151,12 @@ def convert_check_result(result):
for subresult in subresults:
st, text = subresult[:2]
- infotexts.append(text + ["", "(!)", "(!!)",
"(?)"][st])
- if st == 2 or status == 2:
- status = 2
- else:
- status = max(status, st)
+ if text != None:
+ infotexts.append(text + ["", "(!)",
"(!!)", "(?)"][st])
+ if st == 2 or status == 2:
+ status = 2
+ else:
+ status = max(status, st)
if len(subresult) == 3:
perfdata += subresult[2]