Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / citrix_controller
blob6580e7b98540d337800969a186b47d27aa00760c
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # <<<citrix_controller>>>
28 # ControllerState Active
29 # ControllerVersion 7.6.0.5024
30 # DesktopsRegistered 29
31 # LicensingServerState OK
32 # LicensingGraceState NotActive
33 # ActiveSiteServices RZ2XenPool01 - Cisco UCS VMware
34 # TotalFarmActiveSessions 262
35 # TotalFarmInactiveSessions 14
37 # .--Active Site Services------------------------------------------------.
38 # | _ _ _ ____ _ _ |
39 # | / \ ___| |_(_)_ _____ / ___|(_) |_ ___ |
40 # | / _ \ / __| __| \ \ / / _ \ \___ \| | __/ _ \ |
41 # | / ___ \ (__| |_| |\ V / __/ ___) | | || __/ |
42 # | /_/ \_\___|\__|_| \_/ \___| |____/|_|\__\___| |
43 # | |
44 # | ____ _ |
45 # | / ___| ___ _ ____ _(_) ___ ___ ___ |
46 # | \___ \ / _ \ '__\ \ / / |/ __/ _ \/ __| |
47 # | ___) | __/ | \ V /| | (_| __/\__ \ |
48 # | |____/ \___|_| \_/ |_|\___\___||___/ |
49 # | |
50 # '----------------------------------------------------------------------'
53 def inventory_citrix_controller_services(info):
54 for line in info:
55 if line[0] == "ActiveSiteServices":
56 return [(None, None)]
59 def check_citrix_controller_services(_no_item, _no_params, info):
60 for line in info:
61 if line[0] == "ActiveSiteServices":
62 return 0, " ".join(line[1:])
65 check_info["citrix_controller.services"] = {
66 "inventory_function": inventory_citrix_controller_services,
67 "check_function": check_citrix_controller_services,
68 "service_description": "Citrix Active Site Services",
72 # .--Desktops Registered-------------------------------------------------.
73 # | ____ _ _ |
74 # | | _ \ ___ ___| | _| |_ ___ _ __ ___ |
75 # | | | | |/ _ \/ __| |/ / __/ _ \| '_ \/ __| |
76 # | | |_| | __/\__ \ <| || (_) | |_) \__ \ |
77 # | |____/ \___||___/_|\_\\__\___/| .__/|___/ |
78 # | |_| |
79 # | ____ _ _ _ |
80 # | | _ \ ___ __ _(_)___| |_ ___ _ __ ___ __| | |
81 # | | |_) / _ \/ _` | / __| __/ _ \ '__/ _ \/ _` | |
82 # | | _ < __/ (_| | \__ \ || __/ | | __/ (_| | |
83 # | |_| \_\___|\__, |_|___/\__\___|_| \___|\__,_| |
84 # | |___/ |
85 # '----------------------------------------------------------------------'
88 def inventory_citrix_controller_registered(info):
89 for line in info:
90 if line[0] == "DesktopsRegistered":
91 return [(None, None)]
94 def check_citrix_controller_registered(_no_item, _no_params, info):
95 for line in info:
96 if line[0] == "DesktopsRegistered":
97 desktops = int(line[1])
98 return 0, "%d" % desktops, [("registered_desktops", desktops)]
101 check_info["citrix_controller.registered"] = {
102 "inventory_function": inventory_citrix_controller_registered,
103 "check_function": check_citrix_controller_registered,
104 "service_description": "Citrix Desktops Registered",
105 "has_perfdata": True,
109 # .--Total Sessions------------------------------------------------------.
110 # | _____ _ _ ____ _ |
111 # | |_ _|__ | |_ __ _| | / ___| ___ ___ ___(_) ___ _ __ ___ |
112 # | | |/ _ \| __/ _` | | \___ \ / _ \/ __/ __| |/ _ \| '_ \/ __| |
113 # | | | (_) | || (_| | | ___) | __/\__ \__ \ | (_) | | | \__ \ |
114 # | |_|\___/ \__\__,_|_| |____/ \___||___/___/_|\___/|_| |_|___/ |
115 # | |
116 # '----------------------------------------------------------------------'
119 def inventory_citrix_controller_sessions(info):
120 inv = False
121 for line in info:
122 inv = inv or ("sessions" in line[0].lower())
124 if inv:
125 return [(None, {})]
126 return []
129 def check_citrix_controller_sessions(_no_item, params, info):
130 if params is None:
131 params = {}
133 session = {
134 "active": 0,
135 "inactive": 0,
137 for line in info:
138 if line[0] == "TotalFarmActiveSessions":
139 session["active"] = int(line[1])
140 elif line[0] == "TotalFarmInactiveSessions":
141 session["inactive"] = int(line[1])
143 session["total"] = session["active"] + session["inactive"]
145 state = 0
146 messages = []
147 perf = []
148 for what in ['total', 'active', 'inactive']:
149 warn, crit = params.get(what, (None, None))
150 perf.append((what + "_sessions", session[what], warn, crit))
151 if crit is not None and session[what] >= crit:
152 messages.append("%s: %s(!!)" % (what, session[what]))
153 state = 2
154 elif warn is not None and session[what] >= warn:
155 messages.append("%s: %s(!)" % (what, session[what]))
156 state = max(state, 1)
157 else:
158 messages.append("%s: %s" % (what, session[what]))
160 return state, ", ".join(messages), perf
163 check_info["citrix_controller.sessions"] = {
164 "inventory_function": inventory_citrix_controller_sessions,
165 "check_function": check_citrix_controller_sessions,
166 "service_description": "Citrix Total Sessions",
167 "has_perfdata": True,
168 "group": "citrix_sessions",
172 # .--Licensing State-----------------------------------------------------.
173 # | _ _ _ ____ _ _ |
174 # | | | (_) ___ ___ _ __ ___(_)_ __ __ _ / ___|| |_ __ _| |_ ___ |
175 # | | | | |/ __/ _ \ '_ \/ __| | '_ \ / _` | \___ \| __/ _` | __/ _ \ |
176 # | | |___| | (_| __/ | | \__ \ | | | | (_| | ___) | || (_| | || __/ |
177 # | |_____|_|\___\___|_| |_|___/_|_| |_|\__, | |____/ \__\__,_|\__\___| |
178 # | |___/ |
179 # '----------------------------------------------------------------------'
182 def inventory_citrix_controller_licensing(info):
183 if info:
184 return [(None, None)]
187 def check_citrix_controller_licensing(_no_item, _no_params, info):
189 statedict = {
190 "licensingserverstate": ("Licensing Server State", {
191 "ServerNotSpecified": (2, "server not specified"),
192 "NotConnected": (1, "not connected"),
193 "OK": (0, "OK"),
194 "LicenseNotInstalled": (2, "license not installed"),
195 "LicenseExpired": (2, "licenese expired"),
196 "Incompatible": (2, "incompatible"),
197 "Failed": (2, "failed"),
199 "licensinggracestate": ("Licensing Grace State", {
200 "NotActive": (0, "not active"),
201 "Active": (2, "active"),
202 "InOutOfBoxGracePeriod": (1, "in-out-of-box grace period"),
203 "InSupplementalGracePeriod": (1, "in-supplemental grace period"),
204 "InEmergencyGracePeriod": (2, "in-emergency grace period"),
205 "GracePeriodExpired": (2, "grace period expired"),
208 # piggy back data might deliver double data
209 detected_states = []
210 for line in info:
211 if line[0].lower() in statedict and line[0] not in detected_states:
212 detected_states.append(line[0])
213 title, states = statedict[line[0].lower()]
214 state, state_readable = states[line[1]]
215 yield state, "%s: %s" % (title, state_readable)
218 check_info["citrix_controller.licensing"] = {
219 "inventory_function": inventory_citrix_controller_licensing,
220 "check_function": check_citrix_controller_licensing,
221 "service_description": "Citrix Controller Licensing",
225 # .--Controller State----------------------------------------------------.
226 # | ____ _ _ _ |
227 # | / ___|___ _ __ | |_ _ __ ___ | | | ___ _ __ |
228 # | | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| |
229 # | | |__| (_) | | | | |_| | | (_) | | | __/ | |
230 # | \____\___/|_| |_|\__|_| \___/|_|_|\___|_| |
231 # | |
232 # | ____ _ _ |
233 # | / ___|| |_ __ _| |_ ___ |
234 # | \___ \| __/ _` | __/ _ \ |
235 # | ___) | || (_| | || __/ |
236 # | |____/ \__\__,_|\__\___| |
237 # | |
238 # '----------------------------------------------------------------------'
241 def inventory_citrix_controller(info):
242 for line in info:
243 if line[0] == "ControllerState":
244 return [(None, None)]
247 def check_citrix_controller(_no_item, _no_params, info):
248 for line in info:
249 if line[0] == "ControllerState":
250 state = 0
251 if line[1] != "Active":
252 state = 2
253 return state, line[1]
256 check_info["citrix_controller"] = {
257 "inventory_function": inventory_citrix_controller,
258 "check_function": check_citrix_controller,
259 "service_description": "Citrix Controller State",