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 # see: 1.3.6.1.4.1.3375.2.2.5.1.2.1
29 # F5-BIGIP-LOCAL-MIB::ltmPoolName. 8.80.111.111.108.asci_encoded_str = Pool_NMA
30 # F5-BIGIP-LOCAL-MIB::ltmPoolMemberCnt. 8.80.111.111.108.95.78.77.65 = 2
31 # F5-BIGIP-LOCAL-MIB::ltmPoolActiveMemberCnt. 8.80.111.111.108.95.78.77.65 = 0
33 # warn, crit numbers of pool members
34 f5_bigip_pool_default_levels
= (2, 1)
37 def parse_f5_bigip_pool(info
):
39 processed_member_info
= False
45 if len(block
[0]) == 3 and processed_member_info
:
48 if len(block
[0]) == 3:
50 parsed
.setdefault(line
[0], {"act_members": 0, "def_members": 0, "down_info": []})
51 parsed
[line
[0]]["act_members"] += int(line
[1])
52 parsed
[line
[0]]["def_members"] += int(line
[2])
53 processed_member_info
= True
56 elif len(block
[0]) == 6:
57 for key
, val
in parsed
.iteritems():
60 val
["down_info"].append(line
)
64 def inventory_f5_bigip_pool(parsed
):
65 # inventorize all pools and their member count
66 for item
in parsed
.keys():
68 yield item
, "f5_bigip_pool_default_levels"
71 def f5_bigip_pool_get_down_members(down_info
):
73 for line
in down_info
:
74 if (line
[2] != '4' or line
[3] != '4' or line
[4] in ('2', '3', '4', '5')):
75 if re
.match(r
"\/\S*\/\S*", line
[5]):
76 host
= line
[5].split("/")[2]
79 downs
.append(host
+ ":" + line
[1])
83 def check_f5_bigip_pool(item
, params
, parsed
):
86 pool_info
= parsed
.get(item
)
90 pool_act_members
= pool_info
["act_members"]
91 pool_def_members
= pool_info
["def_members"]
92 message
= "%d of %d members are up" % (pool_act_members
, pool_def_members
)
94 if pool_act_members
== pool_def_members
or pool_act_members
>= warn
:
96 elif pool_act_members
< crit
:
98 message
+= " (warn/crit: %s/%s)" % (warn
, crit
)
99 elif pool_act_members
< warn
:
101 message
+= " (warn/crit: %s/%s)" % (warn
, crit
)
103 if pool_act_members
< pool_def_members
:
104 downs
= f5_bigip_pool_get_down_members(pool_info
["down_info"])
106 message
+= ", down/disabled nodes: %s" % ", ".join(downs
)
107 return state
, message
109 check_info
["f5_bigip_pool"] = {
110 'parse_function' : parse_f5_bigip_pool
,
111 'check_function' : check_f5_bigip_pool
,
112 'group' : 'f5_pools',
113 'inventory_function' : inventory_f5_bigip_pool
,
114 'service_description' : 'Load Balancing Pool %s',
116 ('.1.3.6.1.4.1.3375.2.2.5.1.2.1', [
118 8, # ltmPoolActiveMemberCnt
119 23, # ltmPoolMemberCnt
121 ('.1.3.6.1.4.1.3375.2.2.5.3.2.1', [
122 1, # ltmPoolMemberPoolName
123 4, # ltmPoolMemberPort
124 10, # ltmPoolMemberMonitorState
125 11, # ltmPoolMemberMonitorStatus
126 13, # ltmPoolMemberSessionStatus
127 19, # ltmPoolMemberNodeName
130 'snmp_scan_function':
131 lambda oid
: '.1.3.6.1.4.1.3375.2' in oid(".1.3.6.1.2.1.1.2.0") \
132 and "big-ip" in oid(".1.3.6.1.4.1.3375.2.1.4.1.0").lower(),