Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / 3par_ports
blob60005b4443d7191e7ec1c21b3915260892abc31f
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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'] = {
28 "1_link": 1,
29 "2_link": 1,
30 "3_link": 1,
31 "4_link": 0,
32 "5_link": 2,
33 "6_link": 2,
34 "7_link": 1,
35 "8_link": 0,
36 "9_link": 1,
37 "10_link": 1,
38 "11_link": 1,
39 "12_link": 1,
40 "13_link": 1,
41 "14_link": 1,
42 "1_fail": 0,
43 "2_fail": 2,
44 "3_fail": 2,
45 "4_fail": 2,
46 "5_fail": 2,
47 "6_fail": 2,
48 "7_fail": 1,
52 def translate_protocol_3par_ports(number):
53 protocols = {
54 1: "FC",
55 2: "iSCSI",
56 3: "FCOE",
57 4: "IP",
58 5: "SAS",
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'])
72 yield (item, {})
75 def check_3par_ports(item, params, parsed):
76 failover_translate = {
77 1: "NONE",
78 2: "FAILOVER_PENDING",
79 3: "FAILED_OVER",
80 4: "ACTIVE",
81 5: "ACTIVE_DOWN",
82 6: "ACTIVE_FAILED",
83 7: "FAILBACK_PENDING",
86 link_translate = {
87 1: "CONFIG_WAIT",
88 2: "ALPA_WAIT",
89 3: "LOGIN_WAIT",
90 4: "READY",
91 5: "LOSS_SYNC",
92 6: "ERROR_STATE",
93 7: "XXX",
94 8: "NONPARTICIPATE",
95 9: "COREDUMP",
96 10: "OFFLINE",
97 11: "FWDEAD",
98 12: "IDLE_FOR_RESET",
99 13: "DHCP_IN_PROGRESS",
100 14: "PENDING_RESET",
103 mode_translate = {
104 1: "SUSPENDED",
105 2: "TARGET",
106 3: "INITIATOR",
107 4: "PEER",
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']):
115 if "label" in entry:
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']
125 if "mode" in entry:
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"],