Cleanup config.nodes_of
[check_mk.git] / checks / hpux_fchba
blob89713cd759a7068bc2a836a182ded23df7e53695
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 # <<<hpux_fchba>>>
28 # /dev/fcd0
29 # ISP Code version = 4.4.4
30 # Topology = PTTOPT_FABRIC
31 # N_Port Port World Wide Name = 0x500143800252658a
32 # Switch Port World Wide Name = 0x200400051e6302d7
33 # Driver state = ONLINE
34 # Hardware Path is = 0/0/1/1/0
35 # Driver-Firmware Dump Available = NO
36 # /dev/fcd1
37 # ISP Code version = 4.4.4
38 # Topology = PTTOPT_FABRIC
39 # N_Port Port World Wide Name = 0x500143800252658c
40 # Switch Port World Wide Name = 0x200400051e5d1942
41 # Driver state = ONLINE
42 # Hardware Path is = 1/0/12/1/0
43 # Driver-Firmware Dump Available = NO
46 def parse_hpux_fchba(info):
47 hbas = {}
48 for line in info:
49 if line[0].startswith("/dev/"):
50 name = line[0][5:]
51 hba = {"name": name}
52 hbas[name] = hba
53 elif len(line) == 2:
54 hba[line[0].strip()] = line[1].strip()
55 return hbas
58 def inventory_hpux_fchba(info):
59 parsed = parse_hpux_fchba(info)
60 return [(name, None) for name, hba in parsed.items() if hba["Driver state"] == "ONLINE"]
63 def check_hpux_fchba(item, _no_params, info):
64 parsed = parse_hpux_fchba(info)
65 if item not in parsed:
66 return (3, "HBA noch found")
68 hba = parsed[item]
70 state = 0
71 infos = []
73 infos.append("Hardware Path: %s" % hba["Hardware Path is"])
75 infos.append("Driver State: %s" % hba["Driver state"])
76 if hba["Driver state"] != "ONLINE":
77 state = 2
78 infos[-1] += "(!!)"
80 infos.append("Topology: %s" % hba.get("Topology", "(none)"))
81 if hba.get("Topology") not in [
82 "PTTOPT_FABRIC",
83 "PRIVATE_LOOP",
84 "PUBLIC_LOOP",
86 state = 2
87 infos[-1] += "(!!)"
89 if hba.get("Driver-Firmware Dump Available", "NO") != "NO":
90 infos.append("Driver-Firmware Dump Available(!!)")
91 state = 2
93 return (state, ", ".join(infos))
96 check_info['hpux_fchba'] = {
97 "check_function": check_hpux_fchba,
98 "inventory_function": inventory_hpux_fchba,
99 "service_description": "FC HBA %s",