Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / ibm_tl_media_access_devices
blob616b882fca030e21e249e831a93cc3523af33f26
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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.14851.3.1.6.2.1.2.1 3 --> SNIA-SML-MIB::mediaAccessDeviceObjectType.1
28 # .1.3.6.1.4.1.14851.3.1.6.2.1.2.2 3 --> SNIA-SML-MIB::mediaAccessDeviceObjectType.2
29 # .1.3.6.1.4.1.14851.3.1.6.2.1.3.1 IBM ULT3580-TD6 00078B5F0F --> SNIA-SML-MIB::mediaAccessDevice-Name.1
30 # .1.3.6.1.4.1.14851.3.1.6.2.1.3.2 IBM ULT3580-TD6 00078B5FCF --> SNIA-SML-MIB::mediaAccessDevice-Name.2
31 # .1.3.6.1.4.1.14851.3.1.6.2.1.6.1 2 --> SNIA-SML-MIB::mediaAccessDevice-NeedsCleaning.1
32 # .1.3.6.1.4.1.14851.3.1.6.2.1.6.2 2 --> SNIA-SML-MIB::mediaAccessDevice-NeedsCleaning.2
34 # .1.3.6.1.4.1.14851.3.1.12.2.1.3.1 IBM ULT3580-TD6 00078B5F0F --> SNIA-SML-MIB::scsiProtocolController-ElementName.1
35 # .1.3.6.1.4.1.14851.3.1.12.2.1.3.2 IBM ULT3580-TD6 00078B5FCF --> SNIA-SML-MIB::scsiProtocolController-ElementName.2
36 # .1.3.6.1.4.1.14851.3.1.12.2.1.4.1 2 --> SNIA-SML-MIB::scsiProtocolController-OperationalStatus.1
37 # .1.3.6.1.4.1.14851.3.1.12.2.1.4.2 2 --> SNIA-SML-MIB::scsiProtocolController-OperationalStatus.2
38 # .1.3.6.1.4.1.14851.3.1.12.2.1.6.1 3 --> SNIA-SML-MIB::scsiProtocolController-Availability.1
39 # .1.3.6.1.4.1.14851.3.1.12.2.1.6.2 3 --> SNIA-SML-MIB::scsiProtocolController-Availability.2
42 def parse_ibm_tl_media_access_devices(info):
43 parsed = {}
44 media_access_info, controller_info = info
45 for ty, name, clean in media_access_info:
46 parsed.setdefault(
47 ibm_tape_library_parse_device_name(name), {
48 "type": {
49 "0": "unknown",
50 "1": "worm drive",
51 "2": "magneto optical drive",
52 "3": "tape drive",
53 "4": "dvd drive",
54 "5": "cdrom drive",
55 }[ty],
56 "clean": {
57 "0": "unknown",
58 "1": "true",
59 "2": "false",
60 }[clean],
63 for ctrl_name, ctrl_avail, ctrl_status in controller_info:
64 ctrl_name = ibm_tape_library_parse_device_name(ctrl_name)
65 if ctrl_name in parsed:
66 parsed[ctrl_name]["ctrl_avail"] = ctrl_avail
67 parsed[ctrl_name]["ctrl_status"] = ctrl_status
69 return parsed
72 def inventory_ibm_tl_media_access_devices(parsed):
73 for device in parsed:
74 yield device, None
77 def check_ibm_tl_media_access_devices(item, params, parsed):
78 if item in parsed:
79 data = parsed[item]
80 if data.get("ctrl_avail") and data.get("ctrl_status"):
81 for res in ibm_tape_library_get_device_state(data["ctrl_avail"], data["ctrl_status"]):
82 yield res
83 yield 0, "Type: %s, Needs cleaning: %s" % (data["type"], data["clean"])
86 check_info['ibm_tl_media_access_devices'] = {
87 'parse_function': parse_ibm_tl_media_access_devices,
88 'inventory_function': inventory_ibm_tl_media_access_devices,
89 'check_function': check_ibm_tl_media_access_devices,
90 'service_description': 'Media access device %s',
91 'snmp_info': [
93 '.1.3.6.1.4.1.14851.3.1.6.2.1',
95 "2", # SNIA-SML-MIB::mediaAccessDeviceObjectType
96 "3", # SNIA-SML-MIB::mediaAccessDevice-Name
97 "6", # SNIA-SML-MIB::mediaAccessDevice-NeedsCleaning
98 ]),
100 '.1.3.6.1.4.1.14851.3.1.12.2.1',
102 "3", # SNIA-SML-MIB::scsiProtocolController-ElementName
103 "6", # SNIA-SML-MIB::scsiProtocolController-Availability
104 "4", # SNIA-SML-MIB::scsiProtocolController-OperationalStatus
107 'snmp_scan_function': scan_ibm_tape_library,
108 'includes': ['ibm_tape_library.include'],