Cleanup config.nodes_of
[check_mk.git] / checks / synology_disks
blob27112bb8fcda5edd0dd6720b4d2db97b79416ee5
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2013 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.
28 def inventory_synology_disks(info):
29 for disk, model, status, _temperature in info:
30 # SSD used as cache are "not initialized". We remember that
31 # here.
32 if "SSD" in model and status == '3':
33 params = {"used_as_cache": True}
34 else:
35 params = {}
37 yield disk, params
40 def check_synology_disks(item, params, info):
41 states = {
42 1: (0, "OK"),
43 2: (0, "OK"),
44 3: (1, "not initialized"),
45 4: (2, "system partition failed"),
46 5: (2, "crashed")
49 if params is None:
50 params = {}
52 for disk, model, status, temperature in info:
53 if disk == item:
54 temp = int(temperature)
55 if status == '3' and params.get("used_as_cache"):
56 status_text = "used as cache"
57 status_code = 0
58 else:
59 status_code, status_text = states[int(status)]
61 message = u"Status: %s, Temperature: %d °C, Model: %s" % (status_text, temp, model)
62 return status_code, message, [("temp", temp)]
65 check_info["synology_disks"] = {
66 "check_function": check_synology_disks,
67 "inventory_function": inventory_synology_disks,
68 "service_description": "Disk %s",
69 "has_perfdata": True,
70 "snmp_scan_function": synology_scan_function,
71 "snmp_info": (
72 ".1.3.6.1.4.1.6574.2.1.1",
74 2, #SYNOLOGY-DISK-MIB::diskID
75 3, #SYNOLOGY-DISK-MIB::diskModel
76 5, #SYNOLOGY-DISK-MIB::diskStatus
77 6, #SYNOLOGY-DISK-MIB::diskTemperature
78 ]),
79 "includes": ["synology.include"]