2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # Example output from agent:
28 # <<<ibm_svc_enclosurestats:sep(58)>>>
29 # 1:power_w:207:218:140410113051
30 # 1:temp_c:22:22:140410113246
31 # 1:temp_f:71:71:140410113246
32 # 2:power_w:126:128:140410113056
33 # 2:temp_c:21:21:140410113246
34 # 2:temp_f:69:69:140410113246
35 # 3:power_w:123:126:140410113041
36 # 3:temp_c:22:22:140410113246
37 # 3:temp_f:71:71:140410113246
38 # 4:power_w:133:138:140410112821
39 # 4:temp_c:22:23:140410112836
40 # 4:temp_f:71:73:140410112836
42 # .--temperature---------------------------------------------------------.
44 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
45 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
46 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
47 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
49 # '----------------------------------------------------------------------'
51 factory_settings
["ibm_svc_enclosurestats_temperature_default_levels"] = {"levels": (35, 40)}
54 def inventory_ibm_svc_enclosurestats_temp(info
):
55 for enclosure_id
, stat_name
, _stat_current
, _stat_peak
, _stat_peak_time
in info
:
56 if stat_name
== "temp_c":
57 yield enclosure_id
, {}
60 def check_ibm_svc_enclosurestats_temp(item
, params
, info
):
61 for enclosure_id
, stat_name
, stat_current
, _stat_peak
, _stat_peak_time
in info
:
62 if enclosure_id
== item
and stat_name
== "temp_c":
63 return check_temperature(int(stat_current
), params
, "ibm_svc_enclosurestats_%s" % item
)
66 check_info
["ibm_svc_enclosurestats.temp"] = {
67 "check_function": check_ibm_svc_enclosurestats_temp
,
68 "inventory_function": inventory_ibm_svc_enclosurestats_temp
,
69 "service_description": "Temperature Enclosure %s",
71 "group": "temperature",
72 "includes": ["temperature.include"],
73 'default_levels_variable': "ibm_svc_enclosurestats_temperature_default_levels"
77 # .--power---------------------------------------------------------------.
79 # | _ __ _____ _____ _ __ |
80 # | | '_ \ / _ \ \ /\ / / _ \ '__| |
81 # | | |_) | (_) \ V V / __/ | |
82 # | | .__/ \___/ \_/\_/ \___|_| |
84 # '----------------------------------------------------------------------'
87 def inventory_ibm_svc_enclosurestats_power(info
):
89 for enclosure_id
, stat_name
, _stat_current
, _stat_peak
, _stat_peak_time
in info
:
90 if stat_name
== "power_w":
91 inventory
.append((enclosure_id
, None))
95 def check_ibm_svc_enclosurestats_power(item
, _no_params
, info
):
98 for enclosure_id
, stat_name
, stat_current
, _stat_peak
, _stat_peak_time
in info
:
99 if enclosure_id
== item
and stat_name
== "power_w":
100 stat_current
= int(stat_current
)
101 perfdata
= [('power', str(stat_current
) + "Watt")]
102 return 0, "Enclosure %s Power Consumption is %s Watt" % (enclosure_id
,
103 stat_current
), perfdata
105 return 3, "Power for enclosure %s not found in agent output" % item
108 check_info
["ibm_svc_enclosurestats.power"] = {
109 "check_function": check_ibm_svc_enclosurestats_power
,
110 "inventory_function": inventory_ibm_svc_enclosurestats_power
,
111 "service_description": "Power Enclosure %s",
112 "has_perfdata": True,