GUI CSS: Deployed view styles for layouts (CMK-1171)
[check_mk.git] / checks / netscaler_vserver
bloba9a8c610ce0d58aaa97ea418926b1b1a447b1516
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2019 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 factory_settings["netscaler_vserver_default_levels"] = {
28 "health_levels": (100.0, 0.1),
29 "cluster_status": "best",
32 netscaler_vserver_states = {
33 "0": (1, "unknown"),
34 "1": (2, "down"),
35 "2": (1, "unknown"),
36 "3": (1, "busy"),
37 "4": (1, "out of service"),
38 "5": (1, "transition to out of service"),
39 "7": (0, "up"),
42 netscaler_vserver_types = {
43 "0": "http",
44 "1": "ftp",
45 "2": "tcp",
46 "3": "udp",
47 "4": "ssl bridge",
48 "5": "monitor",
49 "6": "monitor udp",
50 "7": "nntp",
51 "8": "http server",
52 "9": "http client",
53 "10": "rpc server",
54 "11": "rpc client",
55 "12": "nat",
56 "13": "any",
57 "14": "ssl",
58 "15": "dns",
59 "16": "adns",
60 "17": "snmp",
61 "18": "ha",
62 "19": "monitor ping",
63 "20": "sslOther tcp",
64 "21": "aaa",
65 "23": "secure monitor",
66 "24": "ssl vpn udp",
67 "25": "rip",
68 "26": "dns client",
69 "27": "rpc server",
70 "28": "rpc client",
71 "62": "service unknown",
72 "69": "tftp",
75 netscaler_vserver_entitytypes = {
76 "0": "unknown",
77 "1": "loadbalancing",
78 "2": "loadbalancing group",
79 "3": "ssl vpn",
80 "4": "content switching",
81 "5": "cache redirection",
85 def inventory_netscaler_vserver(parsed):
86 for srv_name in parsed:
87 yield srv_name, {}
90 def parse_netscaler_vserver(info):
91 parsed = {}
92 for (node, name, ip, port, svr_type, svr_state, svr_health, svr_entitytype, request_rate,
93 rx_bytes, tx_bytes, full_name) in info:
95 server_name = full_name if full_name else name
96 svr_state, svr_state_readable = netscaler_vserver_states.get(svr_state, (1, "unknown"))
98 entity_service_type = "Type: %s, Protocol: %s, Socket: %s:%s" % (
99 netscaler_vserver_entitytypes.get(svr_entitytype, "unknown (%s)" % svr_entitytype),
100 netscaler_vserver_types.get(svr_type, "service unknown (%s)" % svr_type),
102 port,
105 tmp_dict = {
106 'node': node,
107 'service_state': (svr_state, svr_state_readable),
108 'entity_service_type': entity_service_type,
109 'request_rate': int(request_rate),
110 'rx_bytes': int(rx_bytes),
111 'tx_bytes': int(tx_bytes),
114 if svr_entitytype in ["1", "2"]:
115 tmp_dict['health'] = float(svr_health)
117 parsed.setdefault(server_name, []).append(tmp_dict)
118 return parsed
121 @get_parsed_item_data
122 def check_netscaler_vserver(item, params, data):
123 if params is None:
124 params = {}
126 cluster_status = params.get('cluster_status', 'best')
127 node_stat_list = []
128 req_rate_list, rx_list, tx_list = [0], [0], [0]
130 for node in data:
131 node_stat_list.append(node['service_state'][0])
132 req_rate_list.append(node.get('request_rate'))
133 rx_list.append(node.get('rx_bytes'))
134 tx_list.append(node.get('tx_bytes'))
136 for node in data:
137 if node['node']:
138 txt = "Status: %s (%s)" % (node['service_state'][1], node['node'])
139 else:
140 txt = "Status: %s" % node['service_state'][1]
141 if cluster_status == 'best':
142 yield min(node_stat_list), txt
143 else:
144 yield node['service_state'][0], txt
146 if params.get('entity_service_type') in ["1", "2"]:
147 warn, crit = params.get("health_levels", (None, None))
148 health_perc = data[0]['health']
149 info_txt = "Health: %s" % get_percent_human_readable(health_perc)
150 health_state = 0
151 if crit and health_perc < crit:
152 health_state = 2
153 elif warn and health_perc < warn:
154 health_state = 1
156 if health_state > 0:
157 info_txt += " (warn/crit below %s/%s)" % (get_percent_human_readable(warn),
158 get_percent_human_readable(crit))
159 yield health_state, info_txt, [("health_perc", health_perc, warn, crit, 0, 100)]
161 yield 0, data[0]["entity_service_type"]
163 info_txt = "Request rate: %s/s, In: %s/s, Out: %s/s" % (max(req_rate_list),
164 get_bytes_human_readable(max(rx_list)),
165 get_bytes_human_readable(max(tx_list)))
166 yield 0, info_txt, [("request_rate", max(req_rate_list)), ("if_in_octets", max(rx_list)),
167 ("if_out_octets", max(tx_list))]
170 check_info["netscaler_vserver"] = {
171 "parse_function": parse_netscaler_vserver,
172 "check_function": check_netscaler_vserver,
173 "inventory_function": inventory_netscaler_vserver,
174 "service_description": "VServer %s",
175 "snmp_info": (
176 ".1.3.6.1.4.1.5951.4.1.3.1.1",
177 [ # nsVserverGroup.vserverTable.vserverEntry
178 1, # vsvrName
179 2, # vsvrIpAddress
180 3, # vsvrPort
181 4, # vsvrType
182 5, # vsvrState
183 62, # vsvrHealth
184 64, # vsvrEntityType
185 43, # NS-ROOT-MIB::vsvrRequestRate
186 44, # NS-ROOT-MIB::vsvrRxBytesRate
187 45, # NS-ROOT-MIB::vsvrTxBytesRate
188 59, # vsvrFullName
190 "has_perfdata": True,
191 "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5951.1"),
192 "group": "netscaler_vserver",
193 "default_levels_variable": "netscaler_vserver_default_levels",
194 "node_info": True,