Cleanup config.nodes_of
[check_mk.git] / checks / vxvm_objstatus
blobdb04c8ea63120e7c8b2d94aa26700d8898914461
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:
28 #<<<vxvm_objstatus>>>
29 #v datadg lalavol CLEAN DISABLED
30 #v datadg oravol ACTIVE ENABLED
31 #v datadg oravol-L01 ACTIVE ENABLED
32 #v datadg oravol-L02 ACTIVE ENABLED
33 #v testgroup oravol-L02 ACTIVE ENABLED
36 def vxvm_objstatus_disks(info):
37 groups = {}
38 found_groups = []
39 for dg_type, dg_name, name, admin_state, kernel_state in info:
40 if dg_type == 'v':
41 if dg_name not in found_groups:
42 groups[dg_name] = [(name, admin_state, kernel_state)]
43 found_groups.append(dg_name)
44 else:
45 groups[dg_name].append((name, admin_state, kernel_state))
46 return groups
49 def inventory_vxvm_objstatus(info):
50 return vxvm_objstatus_disks(info).items()
53 def check_vxvm_objstatus(item, params, info):
54 groups = vxvm_objstatus_disks(info)
55 volumes = groups.get(item)
56 if volumes is not None:
57 state = 0
58 messages = []
59 for volume, admin_state, kernel_state in volumes:
60 text = []
61 error = False
62 if admin_state != "CLEAN" and admin_state != 'ACTIVE':
63 state = 2
64 text.append("%s: Admin state is %s(!!)" % (volume, admin_state))
65 error = True
66 if kernel_state != 'ENABLED' and kernel_state != 'DISABLED':
67 state = 2
68 text.append("%s: Kernel state is %s(!!)" % (volume, kernel_state))
69 error = True
70 if error is False:
71 text = ["%s: OK" % volume]
72 messages.append(", ".join(text))
73 return (state, ', '.join(messages))
75 return (2, "Group not found")
78 check_info["vxvm_objstatus"] = {
79 "check_function": check_vxvm_objstatus,
80 "inventory_function": inventory_vxvm_objstatus,
81 "service_description": "VXVM objstatus %s",