2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 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.
28 def parse_f5_bigip_vserver(info
):
29 def ip_from_string(ip
):
31 ip
= "".join(chr(ord(x
)) for x
in ip
)
32 return socket
.inet_ntop(socket
.AF_INET
, ip
)
34 ip
= "".join([chr(ord(x
)) for x
in ip
])
35 return socket
.inet_ntop(socket
.AF_INET6
, ip
)
40 instance
= vservers
.setdefault(line
[0], {
41 "ip": ip_from_string(line
[4]),
47 ("connections_duration_min", 5),
48 ("connections_duration_max", 6),
49 ("connections_duration_mean", 7),
53 ("if_out_octets", 11),
54 ("connections_rate", 12),
56 ("packet_velocity_asic", 14),
59 value
= int(line
[index
])
60 except (IndexError, ValueError):
62 instance
.setdefault(key
, []).append(value
)
66 def inventory_f5_bigip_vserver(parsed
):
67 for name
, vserver
in parsed
.items():
68 if vserver
["status"][0] in [1, 4]: # Green and Blue
72 def check_f5_bigip_vserver(item
, params
, parsed
):
73 # Need compatibility to version with _no_params
78 vserver
= parsed
[item
]
90 "packet_velocity_asic",
92 summed_values
.setdefault(what
, 0)
93 for idx
, entry
in enumerate(vserver
[what
]):
94 rate
= get_rate("%s.%s" % (what
, idx
), now
, entry
)
95 summed_values
[what
] += rate
97 # Calucate min/max/sum/mean values
98 for what
, function
in [
99 ("connections_duration_min", min),
100 ("connections_duration_max", max),
101 ("connections", sum),
102 ("connections_duration_mean", lambda x
: float(sum(x
) / len(x
))),
104 value_list
= [x
for x
in vserver
[what
] if x
!= 0]
106 summed_values
[what
] = 0
108 summed_values
[what
] = function(value_list
)
110 # Current number of connections
111 yield 0, "Client connections: %d" % summed_values
["connections"], summed_values
.items()
113 # New connections per time
114 yield 0, "Rate: %.2f/sec" % summed_values
["connections_rate"]
116 # Current server status
119 # 1 - GREEN: available in some capacity
120 # 2 - YELLOW: not currently available
121 # 3 - RED: not available
122 # 4 - BLUE: availability is unknown
123 # 5 - GREY: unlicensed
124 map_server_status
= {
125 0: (1, "is disabled"),
126 1: (0, "is up and available"),
127 2: (2, "is currently not available"),
128 3: (2, "is not available"),
129 4: (1, "availability is unknown"),
130 5: (3, "is unlicensed")
132 state
, state_readable
= map_server_status
.get(
133 vserver
["status"][0], (3, "Unhandled status (%d)" % vserver
["status"][0]))
134 state
= params
.get('state', {}).get(state_readable
.replace(' ', '_'), state
)
140 # 3 - disabledbyparent
141 enabled
= ["NONE", "enabled", "disabled", "disabled by parent"][vserver
["enabled"][0]]
143 output
= "Virtual Server with IP %s is %s, State %s, Detail: %s" % (vserver
["ip"][0],\
144 enabled
, state_readable
, vserver
["detail"][0])
147 if vserver
["status"][0] == 3: # not available
148 # Statement from the network team, it's uncritical when the childrens are down
149 if vserver
["detail"][0].lower() == "The children pool member(s) are down".lower():
150 state
= params
.get('state', {}).get("children_pool_members_down_if_not_available",
155 # Check configured limits
156 map_paramvar_to_text
= {
157 "if_in_octets": "Incoming Bytes",
158 "if_out_octets": "Outgoing Bytes",
159 "if_total_octets": "Total Bytes",
160 "if_in_pkts": "Incoming Packets",
161 "if_out_pkts": "Outgoing Packets",
162 "if_total_pkts": "Total Packets",
165 "if_total_octets"] = summed_values
["if_in_octets"] + summed_values
["if_out_octets"]
166 summed_values
["if_total_pkts"] = summed_values
["if_in_pkts"] + summed_values
["if_out_pkts"]
167 for param_var
, levels
in params
.items():
168 if param_var
== "state":
170 if param_var
.endswith("_lower") and isinstance(levels
, tuple):
171 levels
= (None, None) + levels
172 value
= summed_values
[param_var
.rstrip("_lower")]
173 state
, infotext
, _extra_perfdata
= check_levels(
178 lambda x
, p
=param_var
: get_bytes_human_readable(x
, base
=1000.0) if "octets" in p
else str(x
),
179 infoname
=map_paramvar_to_text
[param_var
.rstrip("_lower")])
181 yield state
, infotext
184 check_info
["f5_bigip_vserver"] = {
185 "parse_function" : parse_f5_bigip_vserver
,
186 "check_function" : check_f5_bigip_vserver
,
187 "inventory_function" : inventory_f5_bigip_vserver
,
188 "group" : "f5_bigip_vserver",
189 "service_description" : "Virtual Server %s",
190 "has_perfdata" : True,
191 "snmp_info" : (".1.3.6.1.4.1.3375.2.2.10", [
192 "13.2.1.1", # ltmVsStatusName
193 "13.2.1.2", # ltmVsStatusAvailState
194 "13.2.1.3", # ltmVsStatusEnabledState
195 "13.2.1.5", # ltmVsStatusDetailReason
196 "1.2.1.3", # IP Address
197 "2.3.1.2", # min conn duration
198 "2.3.1.3", # max conn duration
199 "2.3.1.4", # mean connection duration
200 "2.3.1.6", # Client Packets In
201 "2.3.1.8", # Client Packets Out
202 "2.3.1.7", # Client Bytes In
203 "2.3.1.9", # Client Bytes Out
204 "2.3.1.11", # Client Total Connections
205 "2.3.1.12", # Client Current Connections
206 "2.3.1.25", # packet_velocity_asic Total Connections
208 "snmp_scan_function" : lambda oid
: ".1.3.6.1.4.1.3375.2" in oid(".1.3.6.1.2.1.1.2.0") \
209 and "big-ip" in oid(".1.3.6.1.4.1.3375.2.1.4.1.0").lower(),