Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / tsm_drives
blobecbb6404b59a1c30eb30708067159e5e6945337a
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 # <<<tsm_drives>>>
28 # tsmfarm3 LIBRARY3 DRIVE01 LOADED YES 000782XXXX
29 # tsmfarm3 LIBRARY3 DRIVE02 LOADED YES 002348XXXX
30 # tsmfarm3 LIBRARY3 DRIVE03 EMPTY YES 000783XXXX
31 # tsmfarm3 LIBRARY3 DRIVE04 EMPTY NO 000784XXXX
32 # tsmfarm3 LIBRARY3 DRIVE05 LOADED YES 000785XXXX
34 # <<<tsm_drives>>>
35 # default GPFSFILE GPFSFILE1 UNKNOWN YES
36 # default GPFSFILE GPFSFILE10 UNKNOWN YES
37 # default GPFSFILE GPFSFILE11 UNKNOWN YES
38 # default GPFSFILE GPFSFILE12 UNKNOWN YES
39 # default GPFSFILE GPFSFILE13 UNKNOWN YES
41 # Possible values for state:
42 # LOADED
43 # EMPTY
44 # UNAVAILABLE -> crit
45 # UNLOADED
46 # RESERVED
47 # UNKNOWN -> crit
49 # Possible values for loaded:
50 # YES -> OK
51 # NO
52 # UNAVAILABLE_SINCE?
53 # POLLING?
56 def inventory_tsm_drives(info):
57 inventory = []
58 for line in info:
59 if len(line) == 6:
60 inst, library, drive, _state, _online = line[:5]
61 item = "%s / %s" % (library, drive)
62 if inst != "default":
63 item = inst + " / " + item
64 inventory.append((item, None))
66 return inventory
69 def check_tsm_drives(item, params, info):
70 for line in info:
71 if len(line) >= 5:
72 inst, library, drive, state, online = line[:5]
73 libdev = "%s / %s" % (library, drive)
74 if item == libdev or item == inst + " / " + libdev:
75 if len(line) >= 6:
76 serial = line[5]
77 infotext = "[%s] " % serial
78 else:
79 serial = None
80 infotext = ""
82 monstate = 0
83 infotext += "state: %s" % state
84 if state in ["UNAVAILABLE", "UNKNOWN"]:
85 monstate = 2
86 infotext += "(!!)"
88 infotext += ", online: %s" % online
89 if online != "YES":
90 monstate = 2
91 infotext += "(!!)"
93 return (monstate, infotext)
94 return (3, "drive not found")
97 check_info['tsm_drives'] = {
98 "check_function": check_tsm_drives,
99 "inventory_function": inventory_tsm_drives,
100 "service_description": "TSM Drive %s",