2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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
= {
37 "4": (1, "out of service"),
38 "5": (1, "transition to out of service"),
42 netscaler_vserver_types
= {
65 "23": "secure monitor",
71 "62": "service unknown",
75 netscaler_vserver_entitytypes
= {
78 "2": "loadbalancing group",
80 "4": "content switching",
81 "5": "cache redirection",
85 def inventory_netscaler_vserver(parsed
):
86 for srv_name
in parsed
:
90 def parse_netscaler_vserver(info
):
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
),
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
)
121 @get_parsed_item_data
122 def check_netscaler_vserver(item
, params
, data
):
126 cluster_status
= params
.get('cluster_status', 'best')
128 req_rate_list
, rx_list
, tx_list
= [0], [0], [0]
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'))
138 txt
= "Status: %s (%s)" % (node
['service_state'][1], node
['node'])
140 txt
= "Status: %s" % node
['service_state'][1]
141 if cluster_status
== 'best':
142 yield min(node_stat_list
), txt
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
)
151 if crit
and health_perc
< crit
:
153 elif warn
and health_perc
< warn
:
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",
176 ".1.3.6.1.4.1.5951.4.1.3.1.1",
177 [ # nsVserverGroup.vserverTable.vserverEntry
185 43, # NS-ROOT-MIB::vsvrRequestRate
186 44, # NS-ROOT-MIB::vsvrRxBytesRate
187 45, # NS-ROOT-MIB::vsvrTxBytesRate
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",