2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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.
28 # Parse the snmp data from the IBM agent.
29 # must be cautius since a failed disk makes the snmp output
30 # shift and gives false info for "slot_id"
31 def parse_ibm_xraid_pdisks(info
):
34 slot_id
, disk_id
, disk_type
, disk_state
, slot_desc
= line
35 if "slot" in slot_desc
.lower():
36 slot_id
= int(slot_desc
.split(", ")[-1][-1])
37 enc_id
= int(slot_desc
.split(", ")[-2][-1])
38 hba_id
= int(slot_desc
.split(", ")[-3][-1])
39 disk_path
= ("%d/%d/%d") % (hba_id
, enc_id
, slot_id
)
40 data
.update({disk_path
: (slot_id
, disk_id
, disk_type
, disk_state
, slot_desc
)})
44 def inventory_ibm_xraid_pdisks(info
):
45 return [(disk_id
, None) for disk_id
in parse_ibm_xraid_pdisks(info
)]
48 def check_ibm_xraid_pdisks(item
, _no_params
, info
):
50 data
= parse_ibm_xraid_pdisks(info
)
51 for disk_path
, disk_entry
in data
.items():
53 _slot_label
, _disk_id
, _disk_type
, disk_state
, slot_desc
= disk_entry
55 return (0, "Disk is active" + " [%s]" % slot_desc
)
56 elif disk_state
== "4":
57 return (1, "Disk is rebuilding" + " [%s]" % slot_desc
)
58 elif disk_state
== "5":
59 return (2, "Disk is dead" + " [%s]" % slot_desc
)
61 return (2, "disk is missing") # + " [%s]" % data[item][4])
64 check_info
["ibm_xraid_pdisks"] = {
65 "check_function" : check_ibm_xraid_pdisks
,
66 "service_description": "RAID PDisk %s",
67 "inventory_function" : inventory_ibm_xraid_pdisks
,
68 # there is no information about the ext mib in the right place
69 # (at least on windows)
70 # this means the check has to fetch a specific oid. Limit this
71 # effect to relevant systems to lessen useless scanning.
72 "snmp_scan_function" : lambda oid
: \
73 oid(".1.3.6.1.2.1.1.1.0").lower() in ["software: windows", "linux"] \
74 and oid(".1.3.6.1.4.1.795.14.1.100.1.0"),
75 "snmp_info" : (".1.3.6.1.4.1.795.14.1", [