Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / huawei_osn_power
blob3322b56c394e7663f478e93c88930031797a7411
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2017 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 # The typical OSN power unit delivers 750 W max
28 factory_settings['huawei_osn_power_default_levels'] = {
29 'levels': (700, 730),
33 def inventory_huawei_osn_power(info):
34 for line in info:
35 yield (line[0], None)
38 def check_huawei_osn_power(item, params, info):
39 for line in info:
40 if item == line[0]:
41 state = 0
42 reading = int(line[1])
43 warn, crit = params['levels']
45 yield 0, "Current reading: %s W" % reading, \
46 [ ("power", reading, warn, crit, 0) ]
48 if reading >= crit:
49 state = 2
50 elif reading >= warn:
51 state = 1
53 if state:
54 yield state, "(warn/crit at %s/%s W)" % (warn, crit)
57 check_info['huawei_osn_power'] = {
58 'inventory_function': inventory_huawei_osn_power,
59 'check_function': check_huawei_osn_power,
60 'service_description': 'Unit %s (Power)',
61 'snmp_info': (
62 '.1.3.6.1.4.1.2011.2.25.4.70.20.20.10.1',
64 '1', # OPTIX-OSN902-FUNCTION-MIB::optixWDMGetPsuBID
65 '2', # OPTIX-OSN902-FUNCTION-MIB::optixWDMGetPsuPowerConsumption
66 ]),
67 'snmp_scan_function': huawei_osn_scan_function,
68 'has_perfdata': True,
69 'includes': ['huawei_osn.include'],
70 'default_levels_variable': 'huawei_osn_power_default_levels',