Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / perle.include
blobb1e839f4c6b6053d402583907113f1fe9820de52
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 perle_scan_function(oid):
29 return oid('.1.3.6.1.2.1.1.2.0').startswith('.1.3.6.1.4.1.1966.20')
32 def perle_check_alarms(alarms_str):
33 state = 0
34 alarminfo = ""
35 if int(alarms_str) > 0:
36 state = 2
37 alarminfo += " (User intervention is needed to resolve the outstanding alarms)"
39 return state, "Alarms: %s%s" % (alarms_str, alarminfo)
42 # .--modules-------------------------------------------------------------.
43 # | _ _ |
44 # | _ __ ___ ___ __| |_ _| | ___ ___ |
45 # | | '_ ` _ \ / _ \ / _` | | | | |/ _ \/ __| |
46 # | | | | | | | (_) | (_| | |_| | | __/\__ \ |
47 # | |_| |_| |_|\___/ \__,_|\__,_|_|\___||___/ |
48 # | |
49 # '----------------------------------------------------------------------'
52 def inventory_perle_cm_modules(info):
53 inventory = []
54 for _name, _led, index, \
55 _fiber_lprf, _fiber_link, _fiber_conn, _fiber_speed, \
56 _cooper_lprf, _copper_link, _copper_conn, _copper_speed in info:
57 inventory.append((index, None))
58 return inventory
61 def check_perle_cm_modules(item, _no_params, info):
62 mappings = {
63 "speed": {
64 "0": "10 Mbs",
65 "1": "100 Mbps",
66 "2": "1000 Mbps",
68 "power_led": {
69 "0": (2, "no power"),
70 "1": (0, "power to the module"),
71 "2": (0, "loopback enabled"),
73 "fiber_lprf": {
74 "0": (0, "ok"),
75 "1": (2, "offline"),
76 "2": (2, "link fault"),
77 "3": (2, "auto neg error"),
78 # available for cm1110 modules
79 "99": (2, "not applicable"),
81 "fiber_link": {
82 "0": (1, "down"),
83 "1": (0, "up"),
85 "fiber_connector": {
86 "0": "sc",
87 "1": "lc",
88 "2": "st",
89 "3": "sfp",
90 "5": "fc",
91 "6": "mtrj",
93 "copper_lprf": {
94 "0": (0, "ok"),
95 "1": (2, "remote fault"),
97 "copper_link": {
98 "0": (1, "down"),
99 "1": (0, "ok"),
101 "copper_connector": {
102 "0": "rj45",
106 for _name, power_led, index, \
107 fiber_lprf, fiber_link, fiber_connector, fiber_speed, \
108 cooper_lprf, copper_link, copper_connector, copper_speed in info:
109 if item == index:
110 state, state_readable = mappings["power_led"][power_led]
111 yield state, "Power status: %s" % state_readable
113 for what, lprf, link, speed, connector in [("Fiber", fiber_lprf, fiber_link,
114 fiber_speed, fiber_connector),
115 ("Copper", cooper_lprf, copper_link,
116 copper_speed, copper_connector)]:
118 yield 0, "%s Speed: %s" % (what, mappings["speed"][speed])
120 for what_state, what_key in [(lprf, "LPRF"), (link, "Link")]:
121 state, state_readable = mappings["%s_%s" % (what.lower(),
122 what_key.lower())][what_state]
123 yield state, "%s: %s" % (what_key, state_readable)
125 yield 0, "Connector: %s" % mappings["%s_connector" % what.lower()][connector]