Cleanup config.nodes_of
[check_mk.git] / checks / huawei_osn_laser
blob70d6fa48eec605facf88cf66591ea5d7c7543d9b
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 dBm should not get too low. So we check only for lower levels
28 factory_settings['huawei_osn_laser_default_levels'] = {
29 'levels_low_in': (-160.0, -180.0),
30 'levels_low_out': (-35.0, -40.0)
34 def inventory_huawei_osn_laser(info):
35 for line in info:
36 yield (line[0], None)
39 def check_huawei_osn_laser(item, params, info):
40 def check_state(reading, params):
41 warn, crit = params
42 if reading <= crit:
43 state = 2
44 elif reading <= warn:
45 state = 1
46 else:
47 state = 0
49 if state:
50 return state, "(warn/crit below %s/%s dBm)" % (warn, crit)
51 return 0, None
53 for line in info:
54 if item == line[0]:
55 dbm_in = float(line[2]) / 10
56 dbm_out = float(line[1]) / 10
58 warn_in, crit_in = params['levels_low_in']
59 warn_out, crit_out = params['levels_low_out']
61 # In
62 yield 0, "In: %.1f dBm" % dbm_in, \
63 [ ("input_signal_power_dBm", dbm_in, warn_in, crit_in), ]
64 yield check_state(dbm_in, (warn_in, crit_in))
66 # And out
67 yield 0, "Out: %.1f dBm" % dbm_out, \
68 [ ("output_signal_power_dBm", dbm_out, warn_out, crit_out) ]
69 yield check_state(dbm_out, (warn_out, crit_out))
71 # FEC Correction
72 fec_before = line[3]
73 fec_after = line[4]
74 if not fec_before == "" and not fec_after == "":
75 yield 0, "FEC Correction before/after: %s/%s" % (fec_before, fec_after)
78 check_info['huawei_osn_laser'] = {
79 'inventory_function': inventory_huawei_osn_laser,
80 'check_function': check_huawei_osn_laser,
81 'service_description': 'Laser %s',
82 'snmp_info': (
83 '.1.3.6.1.4.1.2011.2.25.3.40.50.119.10.1',
85 "6.200", # OPTIX-GLOBAL-NGWDM-MIB::laser_groupPer15mCurPara.w32LaserOutputOfPowerCurrent
86 "2.200", # OPTIX-GLOBAL-NGWDM-MIB::laser_groupPer15mCurMonValue.w32LaserOutputOfPowerCurrent
87 "2.203", # OPTIX-GLOBAL-NGWDM-MIB::laser_groupPer15mCurMonValue.w32LaserInputOfPowerCurrent
88 "2.252", # OPTIX-GLOBAL-NGWDM-MIB::laser_groupPer15mCurMonValue.beforeFECCorrectErrorRatio
89 "2.253", # OPTIX-GLOBAL-NGWDM-MIB::laser_groupPer15mCurMonValue.afterFECCorrectErrorRatio
90 ]),
91 'snmp_scan_function': huawei_osn_scan_function,
92 'has_perfdata': True,
93 'includes': ['huawei_osn.include'],
94 'default_levels_variable': 'huawei_osn_laser_default_levels',
95 'group': 'huawei_osn_laser',