Refactored snapin server_time to new snapin API
[check_mk.git] / checks / hp_msa.include
blob74943e32d0ce748ddcac1afee8fe5ba330f9b7bc
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 hp_msa_state_map = {
28 "Up" : (0, "up"),
29 "OK" : (0, "OK"),
30 "Warning" : (1, "warning"),
31 "Degraded" : (1, "degraded"),
32 "Error" : (2, "error"),
33 "Not Present" : (2, "not present"),
34 "Fault" : (2, "fault"),
35 "Unknown" : (3, "unknown"),
39 def parse_hp_msa(info):
40 info_enrolment = {}
41 for line in info:
42 if line[2] == "durable-id":
43 item_id = " ".join(line[3:])
44 info_enrolment.setdefault(item_id, {"item_type" : line[0]})
45 else:
46 info_enrolment[item_id][line[2]] = " ".join(line[3:])
48 parsed = {}
49 now = time.time()
50 for key, values in info_enrolment.items():
51 item_name = values.get("location", key).replace("- ", "")
52 item_name = (item_name.rsplit("_", 1)[-1]).strip()
53 if values.get("data-read-numeric", ""):
54 values["data-read-numeric"] = \
55 get_rate("%s_read" % item_name, now, int(values["data-read-numeric"]))
56 if values.get("data-written-numeric", ""):
57 values["data-written-numeric"] = \
58 get_rate("%s_write" % item_name, now, int(values["data-written-numeric"]))
59 parsed[item_name] = values
61 return parsed
64 def inventory_hp_msa_health(parsed):
65 return [ (key, None) for key in parsed ]
68 def check_hp_msa_health(item, _no_params, parsed):
69 if item in parsed:
70 infotexts = []
71 health_state, health_state_readable = hp_msa_state_map[parsed[item]["health"]]
72 health_info = "Status: %s" % health_state_readable
73 if health_state and parsed[item].get("health-reason", ""):
74 health_info += " (%s)" % parsed[item]["health-reason"]
76 infotexts.append(health_info)
78 # extra info of volumes
79 if parsed[item]["item_type"] == "volumes":
80 volume_info = parsed[item].get("container-name", "")
81 if volume_info:
82 if parsed[item].get("raidtype", ""):
83 volume_info += " (%s)" % parsed[item]["raidtype"]
84 infotexts.append("container name: %s" % volume_info)
86 # extra info of disks
87 elif parsed[item]["item_type"] == "drives":
88 for disk_info in ["serial-number", "vendor", "model", "description", "size"]:
89 if parsed[item].get(disk_info, ""):
90 infotexts.append("%s: %s" % \
91 (disk_info.replace("-", " "), parsed[item][disk_info].replace("GB", " GB") ))
93 if parsed[item].get("rpm", ""):
94 infotexts.append("speed: %s RPM" % (parsed[item]["rpm"]))
96 return health_state, ", ".join(infotexts)
99 def inventory_hp_msa_io(parsed):
100 return inventory_diskstat_generic([[None, item] for item in parsed])
103 def check_hp_msa_io(item, params, parsed):
104 disks = {}
105 for key, values in parsed.items():
106 disks[key] = {
107 "read_throughput" : values["data-read-numeric"],
108 "write_throughput" : values["data-written-numeric"],
111 return check_diskstat_dict(item, params, disks)