2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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
['threepar_ports_default_levels'] = {
52 def translate_protocol_3par_ports(number
):
60 return protocols
[number
]
63 def inventory_3par_ports(parsed
):
64 for entry
in parsed
.get('members', {}):
65 # Only create an item if not "FREE" (type = 3)
66 if not entry
.get('type', 3) == 3:
67 item
= "%s Node %s Slot %s Port %s" % \
68 (translate_protocol_3par_ports(entry
['protocol']), \
69 entry
['portPos']['node'],
70 entry
['portPos']['slot'],
71 entry
['portPos']['cardPort'])
75 def check_3par_ports(item
, params
, parsed
):
76 failover_translate
= {
78 2: "FAILOVER_PENDING",
83 7: "FAILBACK_PENDING",
99 13: "DHCP_IN_PROGRESS",
110 for entry
in parsed
.get('members', {}):
111 if item
== "%s Node %s Slot %s Port %s" % (translate_protocol_3par_ports(entry
['protocol']), \
112 entry
['portPos']['node'],
113 entry
['portPos']['slot'],
114 entry
['portPos']['cardPort']):
116 yield 0, "Label: %s" % entry
['label']
118 if "linkState" in entry
:
119 state
= entry
['linkState']
120 yield params
["%s_link" % state
], link_translate
[state
]
122 if "portWWN" in entry
:
123 yield 0, "portWWN: %s" % entry
['portWWN']
126 yield 0, "Mode: %s" % mode_translate
[entry
['mode']]
128 if "failoverState" in entry
:
129 state
= entry
['failoverState']
130 yield params
["%s_fail" % state
], "Failover: %s" % failover_translate
[state
]
133 check_info
['3par_ports'] = {
134 'parse_function': parse_3par
,
135 'inventory_function': inventory_3par_ports
,
136 'check_function': check_3par_ports
,
137 'service_description': "Port %s",
138 'default_levels_variable': "threepar_ports_default_levels",
139 'group': "threepar_ports",
140 'includes': ["3par.include"],