Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / dmraid
blob197552c56c1a61b8097c5778be8bedae8bbd641b
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 # Author: Markus Lengler <ml@lengler-it.de>
29 # Example outputs from agent:
31 # <<<dmraid>>>
32 # name : isw_ebdabbedfh_system
33 # status : ok
34 # /dev/sda: isw, "isw_ebdabbedfh", GROUP, ok, 976773166 sectors, data@ 0 Model: WDC WD5002ABYS-5
35 # /dev/sdb: isw, "isw_ebdabbedfh", GROUP, ok, 976773166 sectors, data@ 0 Model: WDC WD5002ABYS-5
38 def inventory_dmraid(checkname, info):
39 inventory = []
40 for line in info:
41 if checkname == "dmraid.ldisks" and line[0] == "name":
42 inventory.append((line[2], None))
43 elif checkname == "dmraid.pdisks" and line[0].startswith("/dev/sd"):
44 item = line[0].split(":")[0]
45 inventory.append((item, None))
46 return inventory
49 def check_dmraid_pdisks(item, _no_params, info):
50 for line in info:
51 if line[0].startswith("/dev/sd"):
52 disk = line[0].split(":")[0]
53 if disk == item:
54 status = line[4].split(",")[0]
55 if status == "ok":
56 pos = line.index("Model:")
57 model = " ".join(line[pos + 1:])
58 return (0, "Online (%s)" % model)
59 return (2, "Error on disk!!")
60 return (2, "Missing disk!!")
63 def check_dmraid_ldisks(item, _no_params, info):
64 LDISK_FOUND = False
65 for line in info:
66 if LDISK_FOUND:
67 if line[0] == "status":
68 status = line[2]
69 if status == "ok":
70 return (0, "state is %s" % status)
71 return (2, "%s" % status)
72 if line[0] == "name" and line[2] == item:
73 LDISK_FOUND = True
75 return (3, "incomplete data from agent")
78 check_info["dmraid.ldisks"] = {
79 'check_function': check_dmraid_ldisks,
80 'inventory_function': inventory_dmraid,
81 'service_description': 'RAID LDisk %s',
84 check_info["dmraid.pdisks"] = {
85 'check_function': check_dmraid_pdisks,
86 'inventory_function': inventory_dmraid,
87 'service_description': 'RAID PDisk %s',