Cleanup config.nodes_of
[check_mk.git] / checks / emcvnx_hba
blob3a49d041fa3ffd21ceba792b09c4d81c3fad8ab3
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 # Example output from agent:
28 # <<<emcvnx_hba>>>
29 # Information about each SPPORT:
31 # SP Name: SP A
32 # SP Port ID: 0
33 # SP UID: 50:06:01:60:BE:A0:5D:E5:50:06:01:60:3E:A0:5D:E5
34 # Link Status: Up
35 # Port Status: Online
36 # Switch Present: YES
37 # Switch UID: 10:00:00:27:F8:28:52:5B:20:02:00:27:F8:28:52:5B
38 # SP Source ID: 66048
39 # ALPA Value: 0
40 # Speed Value : 8Gbps
41 # Auto Negotiable : NO
42 # Available Speeds:
43 # 2Gbps
44 # 4Gbps
45 # 8Gbps
46 # Auto
47 # Requested Value: Auto
48 # MAC Address: Not Applicable
49 # SFP State: Online
50 # Reads: 426729
51 # Writes: 8683578
52 # Blocks Read: 4917783
53 # Blocks Written: 12008476
54 # Queue Full/Busy: 0
55 # I/O Module Slot: Onboard
56 # Physical Port ID: 2
57 # Usage: Mirrorview
58 # SFP/Connector EMC Part Number: 019-078-042
59 # SFP/Connector EMC Serial Number: 00000000000
60 # SFP/Connector Vendor Part Number: AFBR-57D7APZ-E2
61 # SFP/Connector Vendor Serial Number: AGL1213A3188822
62 # SFP/Connector Supported Speeds:
63 # 2Gbps
64 # 4Gbps
65 # 8Gbps
67 # SP Name: SP A
68 # SP Port ID: 1
69 # SP UID: 50:06:01:60:BE:A0:5D:E5:50:06:01:61:3E:A0:5D:E5
70 # Link Status: Up
71 # Port Status: Online
72 # Switch Present: YES
73 # [...]
75 # Parse agent output into a dict of the form:
76 # parsed = {
77 # {'SP A Port 0': {'Blocks Read': 4917783, 'Blocks Written': 12008476},
78 # 'SP A Port 1': {'Blocks Read': 363283639, 'Blocks Written': 218463965},
79 # 'SP A Port 2': {'Blocks Read': 2, 'Blocks Written': 0},
80 # 'SP B Port 0': {'Blocks Read': 0, 'Blocks Written': 4348086},
81 # }
84 def parse_emcvnx_hba(info):
85 parsed = {}
86 for line in info:
87 if len(line) > 2 and line[0] == "SP" and line[1] == "Name:":
88 hba_id = " ".join(line[2:])
89 elif len(line) > 2 and line[0] == "SP" and line[1] == "Port" and line[2] == "ID:":
90 hba_id += " Port " + line[-1]
91 hba = {}
92 parsed[hba_id] = hba
93 elif len(line) > 2 and line[0] == "Blocks" and line[1] in ("Read:", "Written:"):
94 hba["Blocks " + line[1].replace(":", "")] = saveint(line[-1])
95 return parsed
98 def inventory_emcvnx_hba(parsed):
99 for hba, values in parsed.items():
100 # Old Versions of EMC don't have any Information
101 if values:
102 yield hba, None
105 def check_emcvnx_hba(item, _no_params, parsed):
106 now = time.time()
107 perfdata = []
108 if item not in parsed:
109 return 3, "HBA %s not found in agent output" % item
111 read_blocks = parsed[item]["Blocks Read"]
112 write_blocks = parsed[item]["Blocks Written"]
113 countername_r = "emcvnx_hba.read_blocks.%s" % item.replace(" ", "_")
114 countername_w = "emcvnx_hba.write_blocks.%s" % item.replace(" ", "_")
116 read_blocks_per_sec = get_rate(countername_r, now, read_blocks)
117 write_blocks_per_sec = get_rate(countername_w, now, write_blocks)
118 read_blocks_per_sec = saveint(read_blocks_per_sec)
119 write_blocks_per_sec = saveint(write_blocks_per_sec)
120 perfdata.append(("read_blocks", read_blocks_per_sec))
121 perfdata.append(("write_blocks", write_blocks_per_sec))
123 return 0, "Read: %s Blocks/s, Write: %s Blocks/s" % (read_blocks_per_sec,
124 write_blocks_per_sec), perfdata
127 check_info['emcvnx_hba'] = {
128 "parse_function": parse_emcvnx_hba,
129 "inventory_function": inventory_emcvnx_hba,
130 "check_function": check_emcvnx_hba,
131 "service_description": "HBA %s",
132 'has_perfdata': True,