Cleanup config.nodes_of
[check_mk.git] / checks / hitachi_hnas_temp
blobf638610bbc2f3e7787eabcc9bed93bd89beaf47f
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.
28 def format_hitachi_hnas_name(nodeid, sensorid, new_format):
29 # net item format is used in 1.2.7i? and newer
30 if new_format:
31 return "Node %s Sensor %s" % (nodeid, sensorid)
32 return "%s.%s" % (nodeid, sensorid)
35 def inventory_hitachi_hnas_temp(info):
36 for clusternode, id_, _status, _temp in info:
37 yield format_hitachi_hnas_name(clusternode, id_, True), None
40 def check_hitachi_hnas_temp(item, params, info):
41 temp_status_map = (
42 ("", 3), # 0
43 ("ok", 0), # 1
44 ("tempWarning", 1), # 2
45 ("tempSevere", 2), # 3
46 ("tempSensorFailed", 2), # 4
47 ("tempSensorWarning", 1), # 5
48 ("unknown", 3), # 6
51 for clusternode, id_, status, temp in info:
52 new_format = item.startswith("Node")
53 if format_hitachi_hnas_name(clusternode, id_, new_format) == item:
54 status = int(status)
55 temp = int(temp)
57 if status == 0 or status >= len(temp_status_map):
58 return 3, "unidentified status %s" % status, []
60 return check_temperature(
61 temp,
62 params,
63 "hitachi_hnas_temp_%s" % item,
64 dev_status=temp_status_map[status][1],
65 dev_status_name="Unit: %s" % temp_status_map[status][0])
66 return 3, "No sensor found", []
69 check_info["hitachi_hnas_temp"] = {
70 "check_function": check_hitachi_hnas_temp,
71 "inventory_function": inventory_hitachi_hnas_temp,
72 "service_description": "Temperature %s",
73 "has_perfdata": True,
74 "snmp_info": (
75 ".1.3.6.1.4.1.11096.6.1.1.1.2.1.9.1",
77 1, # temperatureSensorClusterNode
78 2, # temperatureSensorIndex
79 3, # temperatureSensorStatus
80 4 # temperatureSensorCReading
81 ]),
82 "snmp_scan_function": hitachin_hnas_scan_function,
83 "group": "temperature",
84 "includes": ["temperature.include", "hitachi_hnas.include"],