Cleanup config.nodes_of
[check_mk.git] / checks / lsi
blob9454ba0b8cb5a8320d7eb362a1bde6422fe00918
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.
28 def inventory_lsi(check_type, info):
30 # convert [ 0, 1, 2, 3, 4, 5, ...] into [ (0,1), (2,3), (4,5), ... ]
31 entries = zip(info[::2], info[1::2])
33 arrays = []
34 disks = []
35 for entry in entries:
36 id_ = int(entry[0][1])
37 state = entry[1][1].split('(')[-1][:-1]
38 if entry[0][0] == 'VolumeID':
39 arrays.append((id_, state))
40 else:
41 disks.append((id_, state))
43 if check_type == 'lsi.array':
44 return [(item, "None") for (item, state) in arrays]
45 return [(item, '"%s"' % state) for (item, state) in disks]
48 def check_lsi_array(item, _no_params, info):
49 volumeid = -1
50 for line in info:
51 if line[0] == 'VolumeID':
52 volumeid = int(line[1])
53 elif line[0] == 'Statusofvolume' and volumeid == item:
54 status = line[1]
55 if status == 'Okay(OKY)':
56 return (0, 'Status is Okay (OKY)')
57 return (2, 'Status is %s' % (status,))
58 return (2, 'RAID volume %d not existing' % item)
61 check_info["lsi.array"] = {
62 'check_function': check_lsi_array,
63 'default_levels_variable': None,
64 'group': 'raid',
65 'inventory_function': lambda info: inventory_lsi('lsi.array', info),
66 'service_description': 'RAID array %s',
67 'snmp_info': None,
68 'snmp_scan_function': None
72 def check_lsi_disk(item, target_state, info):
73 target_id = -1
74 for line in info:
75 if line[0] == 'TargetID':
76 target_id = int(line[1])
77 elif line[0] == 'State' and target_id == item:
78 state = line[1].split('(')[-1][:-1]
79 if state == target_state:
80 return (0, 'disk has state %s' % state)
81 return (2, 'disk has state %s (should be %s)' % (state, target_state))
82 return (2, 'disk not present')
85 check_info["lsi.disk"] = {
86 'check_function': check_lsi_disk,
87 'default_levels_variable': None,
88 'group': 'raid_disk',
89 'inventory_function': lambda info: inventory_lsi('lsi.disk', info),
90 'service_description': 'RAID disk %s',
91 'snmp_info': None,
92 'snmp_scan_function': None