Module: check_mk
Branch: master
Commit: cf12abab6fcf75fe62e489d1bca0b1d550412f9d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cf12abab6fcf75…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Sep 26 10:13:11 2017 +0200
5312 FIX citrix_sessions: Fixed crash if not all session values 'total',
'active' or 'inactive' are available
Change-Id: I81e2d1cd6a11837c1b3baeeb5c3030c9355953c1
---
.werks/5312 | 11 +++++++++++
checks/citrix_sessions | 52 ++++++++++++++++++++++++++++++--------------------
2 files changed, 42 insertions(+), 21 deletions(-)
diff --git a/.werks/5312 b/.werks/5312
new file mode 100644
index 0000000..2c27525
--- /dev/null
+++ b/.werks/5312
@@ -0,0 +1,11 @@
+Title: citrix_sessions: Fixed crash if not all session values 'total',
'active' or 'inactive' are available
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1506413396
+
+
diff --git a/checks/citrix_sessions b/checks/citrix_sessions
index f3c29a7..bad10ce 100644
--- a/checks/citrix_sessions
+++ b/checks/citrix_sessions
@@ -24,43 +24,53 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+
#<<<citrix_sessions>>>
#sessions 1
#active_sessions 1
#inactive_sessions 0
+
citrix_sessions_default_levels = {
- "total" : ( 60, 65 ),
- "active" : ( 60, 65 ),
- "inactive" : ( 10, 15 ),
+ "total" : (60, 65),
+ "active" : (60, 65),
+ "inactive" : (10, 15),
}
+
+
def inventory_citrix_sessions(info):
return [ ( None, "citrix_sessions_default_levels" )]
+
def check_citrix_sessions(_no_item, params, info):
+ session = {}
+ for line in info:
+ if len(line) > 1:
+ session.setdefault(line[0], int(line[1]))
- if map(len, info) == [1, 1, 1]:
- return 3, "Could not collect session information. Please check the agent
configuration."
+ if not session:
+ yield 3, "Could not collect session information. Please check the agent
configuration."
+ return
- session = {}
- session['total'], session['active'], session['inactive'] = \
- map(int, (info[0][1], info[1][1], info[2][1]))
- state = 0
- messages = []
- perf = []
- for what in [ 'total', 'active', 'inactive' ]:
+ for key, what in [
+ ('sessions', 'total'),
+ ('active_sessions', 'active'),
+ ('inactive_sessions', 'inactive')
+ ]:
+ if session.get(key) is None:
+ continue
+ state = 0
+ value = session[key]
+ infotext = "%s: %s" % (what.title(), value)
warn, crit = params.get(what, (None, None))
- perf.append(( what, session[what], warn, crit ))
- if crit != None and session[what] > crit:
- messages.append("%s: %s(!!)" % ( what, session[what] ))
+ if crit != None and value > crit:
state = 2
- elif warn != None and session[what] > warn:
- messages.append("%s: %s(!)" % ( what, session[what] ))
- state = max(state, 1)
- else:
- messages.append("%s: %s" % ( what, session[what] ))
+ elif warn != None and value > warn:
+ state = 1
+ if state:
+ infotext += " (warn/crit at %s/%s)" % (warn, crit)
+ yield state, infotext, [(what, value, warn, crit)]
- return state, ", ".join(messages), perf
check_info["citrix_sessions"] = {
"group" : "citrix_sessions",