Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / citrix_state
blobcdd81fc33525b64bf9bd0d8bb578412842d8c499
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_state>>>
28 # Catalog XenApp - Standard - RZ5
29 # Controller rx2345.extern.foobar
30 # DesktopGroupName XenApp - Standard
31 # FaultState None
32 # HostingServer rz1tgn03.extern.foobar
33 # MaintenanceMode False
34 # PowerState On
35 # RegistrationState Registered
36 # VMToolsState Running
37 # AgentVersion 7.6.0.5026
40 def parse_citrix_state(info):
41 parsed = {
42 "instance": {},
44 for line in info:
45 if line[0] == "Controller":
46 parsed["controller"] = " ".join(line[1:])
47 elif line[0] == "HostingServer":
48 parsed["hosting_server"] = " ".join(line[1:])
49 elif line[0] in [
50 "FaultState", "MaintenanceMode", "PowerState", "RegistrationState", "VMToolsState"
52 parsed["instance"][line[0]] = line[1]
54 return parsed
57 # .--Controller----------------------------------------------------------.
58 # | ____ _ _ _ |
59 # | / ___|___ _ __ | |_ _ __ ___ | | | ___ _ __ |
60 # | | | / _ \| '_ \| __| '__/ _ \| | |/ _ \ '__| |
61 # | | |__| (_) | | | | |_| | | (_) | | | __/ | |
62 # | \____\___/|_| |_|\__|_| \___/|_|_|\___|_| |
63 # | |
64 # '----------------------------------------------------------------------'
67 def inventory_citrix_state_controller(parsed):
68 if "controller" in parsed:
69 return [(None, None)]
72 def check_citrix_state_controller(_no_item, _no_params, parsed):
73 return 0, parsed["controller"]
76 check_info["citrix_state.controller"] = {
77 "inventory_function": inventory_citrix_state_controller,
78 "check_function": check_citrix_state_controller,
79 "service_description": "Citrix Controller",
83 # .--Hosting Server------------------------------------------------------.
84 # | _ _ _ _ ____ |
85 # || | | | ___ ___| |_(_)_ __ __ _ / ___| ___ _ ____ _____ _ __ |
86 # || |_| |/ _ \/ __| __| | '_ \ / _` | \___ \ / _ \ '__\ \ / / _ \ '__| |
87 # || _ | (_) \__ \ |_| | | | | (_| | ___) | __/ | \ V / __/ | |
88 # ||_| |_|\___/|___/\__|_|_| |_|\__, | |____/ \___|_| \_/ \___|_| |
89 # | |___/ |
90 # '----------------------------------------------------------------------'
93 def inventory_citrix_state_hosting_server(parsed):
94 if "hosting_server" in parsed:
95 return [(None, None)]
98 def check_citrix_state_hosting_server(_no_item, _no_params, parsed):
99 return 0, parsed["hosting_server"]
102 check_info["citrix_state.hosting_server"] = {
103 "inventory_function": inventory_citrix_state_hosting_server,
104 "check_function": check_citrix_state_hosting_server,
105 "service_description": "Citrix Hosting Server",
109 # .--State---------------------------------------------------------------.
110 # | ____ _ _ |
111 # | / ___|| |_ __ _| |_ ___ |
112 # | \___ \| __/ _` | __/ _ \ |
113 # | ___) | || (_| | || __/ |
114 # | |____/ \__\__,_|\__\___| |
115 # | |
116 # '----------------------------------------------------------------------'
119 def inventory_citrix_state(parsed):
120 if parsed["instance"]:
121 return [(None, {})]
124 def check_citrix_state(_no_item, params, parsed):
125 map_states = {
126 "maintenancemode": {
127 "False": 0,
128 "True": 1,
130 "powerstate": {
131 "Unmanaged": 1,
132 "Unknown": 1,
133 "Unavailable": 2,
134 "Off": 2,
135 "On": 0,
136 "Suspended": 2,
137 "TurningOn": 1,
138 "TurningOff": 1,
140 "vmtoolsstate": {
141 "NotPresent": 2,
142 "Unknown": 3,
143 "NotStarted": 1,
144 "Running": 0,
146 "registrationstate": {
147 "Unregistered": 2,
148 "Initializing": 1,
149 "Registered": 0,
150 "AgentError": 2,
152 "faultstate": {
153 "None": 0,
154 "FailedToStart": 2,
155 "StuckOnBoot": 2,
156 "Unregistered": 2,
157 "MaxCapacity": 1,
160 map_states.update(params)
161 for state_type, state in parsed["instance"].items():
162 state_key = state_type.lower()
163 if state_key in map_states:
164 yield map_states[state_key][state], "%s: %s" % (state_type, state)
167 check_info["citrix_state"] = {
168 "parse_function": parse_citrix_state,
169 "inventory_function": inventory_citrix_state,
170 "check_function": check_citrix_state,
171 "service_description": "Citrix Instance State",
172 "group": "citrix_state",