Cleanup config.nodes_of
[check_mk.git] / checks / f5_bigip_interfaces
blob68708b2cf831c04c67d6c6fcc626c49b652765e7
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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.
27 # .1.3.6.1.4.1.3375.2.1.2.4.4.3.1.1. index for ifname
28 # .1.3.6.1.4.1.3375.2.1.2.4.1.2.1.17. index for ifstate
29 # .1.3.6.1.4.1.3375.2.1.2.4.4.3.1.3. index for IN bytes
30 # .1.3.6.1.4.1.3375.2.1.2.4.4.3.1.5. index for OUT bytes
32 f5_bigip_interface_states = {
33 1: "down (has no link and is initialized)",
34 2: "disabled (has been forced down)",
35 3: "uninitialized (has not been initialized)",
36 4: "loopback (in loopback mode)",
37 5: "unpopulated (interface not physically populated)",
41 def check_f5_bigip_interfaces(item, params, info):
42 for port, ifstate, inbytes, outbytes in info:
43 if item != port:
44 continue
46 if int(ifstate) != 0:
47 return (2, "State of %s is %s" % (f5_bigip_interface_states.get(
48 ifstate, "unhandled (%d)" % ifstate), port))
50 this_time = int(time.time())
51 in_per_sec = get_rate("f5_interface.in.%s" % item, this_time, saveint(inbytes))
52 out_per_sec = get_rate("f5_interface.out.%s" % item, this_time, saveint(outbytes))
54 inbytes_h = get_bytes_human_readable(in_per_sec)
55 outbytes_h = get_bytes_human_readable(out_per_sec)
56 perf = [
57 ("bytes_in", in_per_sec),
58 ("bytes_out", out_per_sec),
60 return (0, "in bytes: %s/s, out bytes: %s/s" % (inbytes_h, outbytes_h), perf)
61 return 3, "Interface not found in SNMP data"
64 check_info["f5_bigip_interfaces"] = {
65 "check_function" : check_f5_bigip_interfaces,
66 "inventory_function" : lambda info: [ (x[0], {'state': 0 } ) for x in info if int(x[1]) == 0],
67 "service_description" : "f5 Interface %s",
68 "has_perfdata" : True,
69 "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") in \
70 [ ".1.3.6.1.4.1.3375.2.1.3.4.10", ".1.3.6.1.4.1.3375.2.1.3.4.20" ],
71 "snmp_info" : ( ".1.3.6.1.4.1.3375.2.1.2.4", ["4.3.1.1", "1.2.1.17", "4.3.1.3", "4.3.1.5"]),