Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / emcvnx_disks
blobbef57f715df7cf2e7e40184d646fb537db9e63c5
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_disks>>>
30 # All Disks Information
31 # ---------------------
34 # Bus 0 Enclosure 0 Disk 0
35 # Vendor Id: SEAGATE
36 # Product Id: STE60005 CLAR600
37 # Product Revision: ES0F
38 # Lun: Unbound
39 # Type: N/A
40 # State: Unbound
41 # Hot Spare: NO
42 # Prct Rebuilt: Unbound
43 # Prct Bound: Unbound
44 # Serial Number: 6SL342E6
45 # Sectors: 0 (0)
46 # Capacity: 549691
47 # Private: Unbound
48 # Bind Signature: 0x0, 0, 0
49 # Hard Read Errors: 0
50 # Hard Write Errors: 0
51 # Soft Read Errors: 0
52 # Soft Write Errors: 0
53 # Read Retries: N/A
54 # Write Retries: N/A
55 # Remapped Sectors: N/A
56 # Number of Reads: 15922079
57 # Number of Writes: 14841793
58 # Number of Luns: 0
59 # Raid Group ID: This disk does not belong to a RAIDGroup
60 # Clariion Part Number: DG118032656
61 # Request Service Time: N/A
62 # Read Requests: 15922079
63 # Write Requests: 14841793
64 # Kbytes Read: 998099223
65 # Kbytes Written: 1661571498
66 # Stripe Boundary Crossing: None
67 # Drive Type: SAS
68 # Clariion TLA Part Number:005049274
69 # User Capacity: 0
70 # Idle Ticks: 162808947
71 # Busy Ticks: 1220056
72 # Current Speed: 6Gbps
73 # Maximum Speed: 6Gbps
74 # Queue Max: N/A
75 # Queue Avg: N/A
76 # Prct Idle: 0
77 # Prct Busy: 0
78 # Hardware Power Savings Qualified: NO
79 # Hardware Power Savings Eligible: NO
80 # Power Savings State: Full Power
81 # Current Power Savings Log Timestamp: N/A
82 # Spinning Ticks: N/A
83 # Standby Ticks: N/A
84 # Number of Spin Ups: N/A
85 # Arrivals with Nonzero Queue: 8982980
86 # High Sum of Seeks: 315504963402436
87 # Idle Ticks SPA: 81201290
88 # Idle Ticks SPB: 81607657
89 # Busy Ticks SPA: 812651
90 # Busy Ticks SPB: 407405
91 # Queue Length: 83023848
93 # Bus 1 Enclosure 0 Disk 7
94 # State: Removed
96 # Bus 1 Enclosure 0 Disk 8
97 # Vendor Id: SEAGATE
98 # Product Id: STE60005 CLAR600
99 # Product Revision: ES0F
100 # [...]
102 # Parse agent output into a dict of the form:
103 # parsed = {
104 # '0/0 Disk 0': {'Hard Read Errors': '0',
105 # 'Hard Write Errors': '0',
106 # 'state': 'Unbound'},
107 # '1/0 Disk 7': {'state': 'Removed'},
108 # '1/0 Disk 8': {'Hard Read Errors': '0',
109 # 'Hard Write Errors': '0',
110 # 'state': 'Enabled'},
113 factory_settings['emcvnx_disks_default_levels'] = {
114 'state_read_error': (2, 2), # (state, count of errors)
115 'state_write_error': (2, 2), # (state, count of errors)
116 'state_rebuilding': 1,
120 def parse_emcvnx_disks(info):
121 parsed = {}
122 for line in info:
123 if len(line) > 4 and line[0] == "Bus" and line[4] == "Disk":
124 encid = line[1] + "/" + line[3] + " " + line[4] + " " + line[5]
125 enc = {}
126 parsed[encid] = enc
127 elif len(line) > 1 and line[0] == "State:":
128 state = line[-1]
129 enc["state"] = state
130 elif len(line) > 2 and line[0] == "Hard" and line[2] == "Errors:":
131 error_count = saveint(line[-1])
132 enc[line[0] + " " + line[1] + " Errors"] = error_count
133 elif len(line) > 1 and line[0] == "Kbytes" and line[1] in ["Read:", "Written:"]:
134 io_kbytes = saveint(line[-1])
135 enc[line[0] + " " + line[1].replace(':', '')] = io_kbytes
136 return parsed
139 def inventory_emcvnx_disks(parsed):
140 inventory = []
141 for disk in parsed:
142 if parsed[disk]["state"] != "Empty":
143 inventory.append((disk, {}))
144 return inventory
147 def check_emcvnx_disks(item, params, parsed):
148 now = time.time()
149 perfdata = []
150 if params is None: # convert legacy params
151 params = {}
153 if item not in parsed:
154 return 3, "Enclosure %s not found in agent output" % item
156 diskstate = parsed[item]["state"]
157 message = "Enclosure %s is %s" % (item, diskstate)
158 if diskstate in ["Unbound", "Hot Spare Ready", "Enabled", "Ready"]:
159 nagstate = 0
160 elif diskstate == "Rebuilding":
161 nagstate = params.get("state_rebuilding", 1)
162 message += " %s" % state_markers[nagstate]
163 else:
164 nagstate = 2
165 message += " (!!)"
166 # on error state all other fields besides "State:" are missing, omitting...
167 return nagstate, message
169 read_errors = parsed[item]["Hard Read Errors"]
170 message += ", Hard Read Errors: %s" % read_errors
171 if read_errors >= params["state_read_error"][1]:
172 nagstate = params["state_read_error"][0]
173 message += " %s" % state_markers[nagstate]
175 write_errors = parsed[item]["Hard Write Errors"]
176 message += ", Hard Write Errors: %s" % write_errors
177 if write_errors >= params["state_write_error"][1]:
178 nagstate = params["state_write_error"][0]
179 message += " %s" % state_markers[nagstate]
181 read_bytes = parsed[item]["Kbytes Read"] * 1024
182 write_bytes = parsed[item]["Kbytes Written"] * 1024
183 countername_r = "emcvnx_disks.read_bytes.%s" % item.replace(" ", "_")
184 countername_w = "emcvnx_disks.write_bytes.%s" % item.replace(" ", "_")
186 read_bytes_per_sec = get_rate(countername_r, now, read_bytes)
187 message += ", Read: %s/s" % get_bytes_human_readable(read_bytes_per_sec)
188 perfdata.append(("read", read_bytes_per_sec))
190 write_bytes_per_sec = get_rate(countername_w, now, write_bytes)
191 message += ", Write: %s/s" % get_bytes_human_readable(write_bytes_per_sec)
192 perfdata.append(("write", write_bytes_per_sec))
194 return nagstate, message, perfdata
197 check_info['emcvnx_disks'] = {
198 "parse_function": parse_emcvnx_disks,
199 "inventory_function": inventory_emcvnx_disks,
200 "check_function": check_emcvnx_disks,
201 "service_description": "Enclosure %s",
202 "group": "emcvnx_disks",
203 "has_perfdata": True,
204 "default_levels_variable": "emcvnx_disks_default_levels"