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.
27 factory_settings
['bonding_default_levels'] = {
28 'ieee_302_3ad_agg_id_missmatch_state': 1,
29 'expect_active': 'ignore',
33 def inventory_bonding(parsed
):
35 for bond
, status
in parsed
.items():
36 if status
["status"] in ("up", "degraded"):
37 # If no information about primary interface is available
38 # then assume currently active one as primary
39 if "primary" not in status
and "active" in status
:
40 params
= {"primary": status
["active"]}
43 inventory
.append((bond
, params
))
47 def _check_ieee_302_3ad_specific(params
, status
):
48 master_id
= status
['aggregator_id']
49 missmatch_state
= params
['ieee_302_3ad_agg_id_missmatch_state']
50 msg
= "Missmatching aggregator ID of %s: %s"
51 for eth
, slave
in status
["interfaces"].items():
52 slave_id
= slave
['aggregator_id']
53 if slave_id
!= master_id
:
54 yield missmatch_state
, msg
% (eth
, slave_id
)
57 def check_bonding(item
, params
, parsed
):
58 status
= parsed
.get(item
)
62 if status
["status"] not in ("up", "degraded"):
63 yield 2, "Interface is " + status
["status"]
67 yield 0, "Mode: %s" % mode
68 if "IEEE 802.3ad" in mode
:
69 for result
in _check_ieee_302_3ad_specific(params
, status
):
72 speed
= status
.get('speed')
74 yield 0, "Speed: %s" % speed
76 for eth
, slave
in status
["interfaces"].items():
77 state
= int(slave
["status"] != 'up')
79 yield state
, "%s/%s %s" % (eth
, slave
["hwaddr"], slave
["status"])
81 yield state
, "%s %s" % (eth
, slave
["status"])
83 primary
= status
.get("primary", params
.get("primary"))
85 yield 0, "Primary: %s" % primary
87 active
= status
.get("active")
90 info
= "Active: %s" % active
92 expected_active
= None
93 expect
= params
["expect_active"]
95 if expect
== "primary":
96 expected_active
= primary
97 elif expect
== "lowest":
98 slaves
= status
["interfaces"].keys()
99 expected_active
= min(slaves
)
101 if expected_active
is not None and expected_active
!= active
:
103 info
+= " (expected is %s)" % expected_active
107 yield 0 if status
["status"] == "up" else 1, "Bond status: %s" % status
["status"]