2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2015 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 # .1.3.6.1.4.1.110901.1.2.1.1.1.2.1 lib status
28 # .1.3.6.1.4.1.110901.1.2.2.1.1.8.1.1.x drive x status
29 # .1.3.6.1.4.1.110901.1.3.1.1.4.1 actor status
31 # .1.3.6.1.4.1.110901.1.4.1.0 archive status
32 # .1.3.6.1.4.1.110901.1.4.2.0 archive objects count
33 # .1.3.6.1.4.1.110901.1.4.3.0 blank tapes count
34 # .1.3.6.1.4.1.110901.1.4.4.0 remaining size on tapes
35 # .1.3.6.1.4.1.110901.1.4.5.0 total size on tapes
38 # Note: These checks was designed a bit atypically (for no good reason):
39 # The drive, actor, archive, tapes and library checks are subchecks of the status
40 # check although none of these checks share the same oids.
41 # As a result, "info" is always a list of 6 sublists and each check only
42 # acceses exactly one of the sublists.
46 # .--Status--------------------------------------------------------------.
48 # | / ___|| |_ __ _| |_ _ _ ___ |
49 # | \___ \| __/ _` | __| | | / __| |
50 # | ___) | || (_| | |_| |_| \__ \ |
51 # | |____/ \__\__,_|\__|\__,_|___/ |
53 # '----------------------------------------------------------------------'
56 def item_name_oracle_diva_csm(name
, element_id
):
57 return ("%s %s" % (name
, element_id
)).strip()
60 def inventory_oracle_diva_csm_status(name
, idx
, info
):
61 for line
in info
[idx
]:
63 element_id
, _reading
= line
67 yield item_name_oracle_diva_csm(name
, element_id
), None
70 def status_result_oracle_diva_csm(reading
):
77 return 3, "unexpected state"
80 def check_oracle_diva_csm_status(name
, idx
, item
, params
, info
):
81 for line
in info
[idx
]:
83 element_id
, reading
= line
88 if item_name_oracle_diva_csm(name
, element_id
) == item
:
89 return status_result_oracle_diva_csm(reading
)
92 check_info
['oracle_diva_csm'] = {
94 lambda item
, params
, info
: check_oracle_diva_csm_status("Library", 0, item
, params
, info
),
95 "inventory_function": lambda info
: inventory_oracle_diva_csm_status("Library", 0, info
),
96 "service_description": "DIVA Status %s",
98 (".1.3.6.1.4.1.110901.1.2.1.1.1", ['1', '2']), # lib status
99 (".1.3.6.1.4.1.110901.1.2.2.1.1", ['3', '8']), # drive status
100 (".1.3.6.1.4.1.110901.1.3.1.1", ['2', '4']), # actor status
101 (".1.3.6.1.4.1.110901.1.4", ['1']), # archive status
103 ".1.3.6.1.4.1.110901.1.4",
106 '4', # remaining size
109 (".1.3.6.1.4.1.110901.1.4", ['3']), # blank tape count
111 "snmp_scan_function": lambda oid
: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.311.1.1.3.1.2",
114 check_info
['oracle_diva_csm.drive'] = {
116 lambda item
, params
, info
: check_oracle_diva_csm_status("Drive", 1, item
, params
, info
),
117 "inventory_function": lambda info
: inventory_oracle_diva_csm_status("Drive", 1, info
),
118 "service_description": "DIVA Status %s",
121 check_info
['oracle_diva_csm.actor'] = {
123 lambda item
, params
, info
: check_oracle_diva_csm_status("Actor", 2, item
, params
, info
),
124 "inventory_function": lambda info
: inventory_oracle_diva_csm_status("Actor", 2, info
),
125 "service_description": "DIVA Status %s",
128 check_info
['oracle_diva_csm.archive'] = {
130 lambda item
, params
, info
: check_oracle_diva_csm_status("Manager", 3, item
, params
, info
),
131 "inventory_function": lambda info
: inventory_oracle_diva_csm_status("Manager", 3, info
),
132 "service_description": "DIVA Status %s",
136 # .--Managed Objects-----------------------------------------------------.
138 # | | \/ | __ _ _ __ __ _ __ _ ___ __| | |
139 # | | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \/ _` | |
140 # | | | | | (_| | | | | (_| | (_| | __/ (_| | |
141 # | |_| |_|\__,_|_| |_|\__,_|\__, |\___|\__,_| |
144 # | / _ \| |__ (_) ___ ___| |_ ___ |
145 # | | | | | '_ \| |/ _ \/ __| __/ __| |
146 # | | |_| | |_) | | __/ (__| |_\__ \ |
147 # | \___/|_.__// |\___|\___|\__|___/ |
149 # '----------------------------------------------------------------------'
152 def inventory_oracle_diva_csm_objects(info
):
153 if len(info
) > 4 and len(info
[4]) > 0:
157 def check_oracle_diva_csm_objects(item
, params
, info
):
158 GB
= 1024 * 1024 * 1024
159 if len(info
) > 4 and len(info
[4]) > 0:
160 object_count
, remaining_size
, total_size
= map(int, info
[4][0])
162 infotext
= "managed objects: %s, remaining size: %s GB of %s GB" % (
163 object_count
, remaining_size
, total_size
)
165 return 0, infotext
, [("managed_object_count", object_count
),
166 ("storage_used", (total_size
- remaining_size
) * GB
, None, None, 0,
170 check_info
['oracle_diva_csm.objects'] = {
171 "check_function": check_oracle_diva_csm_objects
,
172 "inventory_function": inventory_oracle_diva_csm_objects
,
173 "has_perfdata": True,
174 "service_description": "DIVA Managed Objects",
178 # .--Tapes---------------------------------------------------------------.
180 # | |_ _|_ _ _ __ ___ ___ |
181 # | | |/ _` | '_ \ / _ \/ __| |
182 # | | | (_| | |_) | __/\__ \ |
183 # | |_|\__,_| .__/ \___||___/ |
185 # '----------------------------------------------------------------------'
187 oracle_diva_csm_tapes_default_levels
= (5, 1) # number of remaining blank tapes. invented levels
190 def inventory_oracle_diva_csm_tapes(info
):
191 if len(info
) > 5 and len(info
[5]) > 0 and len(info
[5][0]) > 0:
192 yield None, 'oracle_diva_csm_tapes_default_levels'
195 def check_oracle_diva_csm_tapes(item
, params
, info
):
196 if len(info
) > 5 and len(info
[5]) > 0 and len(info
[5][0]) > 0:
197 blank_tapes
= int(info
[5][0][0])
199 state
= blank_tapes
<= crit
and 2 \
200 or blank_tapes
<= warn
and 1 \
203 infotext
= "blank tapes %d" % blank_tapes
205 infotext
+= " (warn/crit at %d/%d)" % (warn
, crit
)
207 return state
, infotext
, [("tapes_free", blank_tapes
)]
210 check_info
['oracle_diva_csm.tapes'] = {
211 "check_function": check_oracle_diva_csm_tapes
,
212 "inventory_function": inventory_oracle_diva_csm_tapes
,
213 "group": "blank_tapes",
214 "has_perfdata": True,
215 "service_description": "DIVA Blank Tapes",