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.
28 '1': ('other', 3), # the status could not be determined or not present.
29 '2': ('ok', 0), # operating normally
30 '3': ('degraded', 2), # component is outside of normal operating range.
31 '4': ('failed', 2), # component detects condition that could damage system
34 factory_settings
["hp_proliant_psu_levels"] = {
39 def parse_hp_proliant_psu(info
):
41 Psu
= collections
.namedtuple("Psu", ['chassis', 'bay', 'condition', 'used', 'max'])
42 for chassis
, bay
, present
, cond
, used
, capacity_maximum
in info
:
43 if present
!= '3' or capacity_maximum
== '0':
45 item
= "%s/%s" % (chassis
, bay
)
47 parsed
[item
] = Psu(chassis
, bay
, cond
, int(used
), int(capacity_maximum
))
51 PsuTotal
= collections
.namedtuple("Psu", ['used', 'max'])
52 parsed
['Total'] = PsuTotal(
53 sum(v
.used
for v
in parsed
.values()), sum(v
.max for v
in parsed
.values()))
57 def inventory_hp_proliant_psu(parsed
):
58 """Inventorizes all present PSUs, as well as the Sum over all PSUs"""
64 def check_hp_proliant_psu(item
, params
, psu
):
66 yield 0, "Chassis %s/Bay %s" % (psu
.chassis
, psu
.bay
)
67 snmp_state
, status
= condition_map
[psu
.condition
]
68 yield status
, 'State: "%s"' % snmp_state
71 info
= 'Usage: %d Watts' % psu
.used
72 cap_perc
= psu
.used
* 100 / psu
.max
74 ('power_usage_percentage', cap_perc
),
75 ('power_usage', psu
.used
),
78 # check for user defined thresholds here
79 warn
, crit
= params
["levels"]
80 msg
= " (warn/crit at %s/%s)" % (warn
, crit
)
82 yield 2, info
+ msg
, perf_data
84 yield 1, info
+ msg
, perf_data
86 yield 0, info
, perf_data
89 check_info
["hp_proliant_psu"] = {
90 'check_function': check_hp_proliant_psu
,
91 'inventory_function': inventory_hp_proliant_psu
,
92 'parse_function': parse_hp_proliant_psu
,
93 'default_levels_variable': "hp_proliant_psu_levels",
94 'service_description': 'HW PSU %s',
97 ".1.3.6.1.4.1.232.6.2.9.3.1",
99 "1", # cpqHeFltTolPowerSupplyChassis
100 "2", # cpqHeFltTolPowerSupplyBay
101 "3", # cpqHeFltTolPowerSupplyPresent
102 "4", # cpqHeFltTolPowerSupplyCondition
103 "7", # cpqHeFltTolPowerSupplyCapacityUsed
104 "8", # cpqHeFltTolPowerSupplyCapacityMaximum
106 'snmp_scan_function': lambda oid
: "proliant" in oid(".1.3.6.1.4.1.232.2.2.4.2.0", "").lower(),
107 'has_perfdata': True,