Skip to content

Commit

Permalink
7837 FIX citrix_controller: Fixed several problems if some values are…
Browse files Browse the repository at this point in the history
… missing

Change-Id: Ic0431102803243394f6a0ef715e26b4147a2c731
  • Loading branch information
si-23 committed Jun 19, 2019
1 parent 1cf4282 commit 339c731
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .werks/7837
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Title: citrix_controller: Fixed several problems if some values are missing
Level: 1
Component: checks
Class: fix
Compatible: compat
Edition: cre
State: unknown
Version: 1.5.0p19
Date: 1560851775


24 changes: 18 additions & 6 deletions checks/citrix_controller
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ def inventory_citrix_controller_registered(info):
def check_citrix_controller_registered(_no_item, _no_params, info):
for line in info:
if line[0] == "DesktopsRegistered":
desktops = int(line[1])
return 0, "%d" % desktops, [ ("registered_desktops", desktops) ]
try:
count_desktops = int(line[1])
except (IndexError, ValueError):
# Is UNKNOWN right behaviour?
return 3, 'No desktops registered'
return 0, "%d" % count_desktops, [("registered_desktops", count_desktops)]


check_info["citrix_controller.registered"] = {
Expand Down Expand Up @@ -212,8 +216,12 @@ def check_citrix_controller_licensing(_no_item, _no_params, info):
for line in info:
if line[0].lower() in statedict and line[0] not in detected_states:
detected_states.append(line[0])
title, states = statedict[line[0].lower()]
state, state_readable = states[line[1]]
title, states = statedict[line[0].lower()]
try:
raw_state = line[1]
except IndexError:
continue
state, state_readable = states[raw_state]
yield state, "%s: %s" % (title, state_readable)


Expand Down Expand Up @@ -250,9 +258,13 @@ def check_citrix_controller(_no_item, _no_params, info):
for line in info:
if line[0] == "ControllerState":
state = 0
if line[1] != "Active":
try:
raw_state = line[1]
except IndexError:
return 3, 'unknown'
if raw_state != "Active":
state = 2
return state, line[1]
return state, raw_state


check_info["citrix_controller"] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- encoding: utf-8
# yapf: disable


checkname = u'citrix_controller'


info = [[u'ControllerState'],
[u'ControllerVersion'],
[u'DesktopsRegistered'],
[u'LicensingServerState'],
[u'LicensingGraceState'],
[u'ActiveSiteServices'],
[u'TotalFarmActiveSessions', u'0'],
[u'TotalFarmInactiveSessions', u'0']]


discovery = {'': [(None, None)],
'licensing': [(None, None)],
'registered': [(None, None)],
'services': [(None, None)],
'sessions': [(None, {})]}


checks = {'': [(None, {}, [(3, 'unknown', [])])],
'licensing': [(None, {}, [])],
'registered': [(None, {}, [(3, 'No desktops registered', [])])],
'services': [(None, {}, [(0, '', [])])],
'sessions': [(None,
{},
[(0,
'total: 0, active: 0, inactive: 0',
[('total_sessions', 0, None, None, None, None),
('active_sessions', 0, None, None, None, None),
('inactive_sessions', 0, None, None, None, None)])])]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- encoding: utf-8
# yapf: disable


checkname = u'citrix_controller'


info = [[u'ControllerState', u'Active'],
[u'ControllerVersion', u'7.6.0.5024'],
[u'DesktopsRegistered', u'29'],
[u'LicensingServerState', u'OK'],
[u'LicensingGraceState', u'NotActive'],
[u'ActiveSiteServices', u'XenPool01', u'-', u'Cisco', u'UCS', u'VMware'],
[u'TotalFarmActiveSessions', u'262'],
[u'TotalFarmInactiveSessions', u'14']]


discovery = {'': [(None, None)],
'licensing': [(None, None)],
'registered': [(None, None)],
'services': [(None, None)],
'sessions': [(None, {})]}


checks = {'': [(None, {}, [(0, u'Active', [])])],
'licensing': [(None,
{},
[(0, 'Licensing Server State: OK', []),
(0, 'Licensing Grace State: not active', [])])],
'registered': [(None,
{},
[(0,
'29',
[('registered_desktops', 29, None, None, None, None)])])],
'services': [(None, {}, [(0, u'XenPool01 - Cisco UCS VMware', [])])],
'sessions': [(None,
{},
[(0,
'total: 276, active: 262, inactive: 14',
[('total_sessions', 276, None, None, None, None),
('active_sessions', 262, None, None, None, None),
('inactive_sessions', 14, None, None, None, None)])])]}

0 comments on commit 339c731

Please sign in to comment.