Cleanup config.nodes_of
[check_mk.git] / checks / adva_fsp_if
blob8fc180ef1affbca10f519034cb4b331bdb0a7a9c
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 adva_fsp_if_inventory_porttypes = ['1', '6', '56']
28 adva_fsp_if_inventory_portstates = ['1']
29 adva_fsp_if_inventory_uses_description = True
30 adva_fsp_if_inventory_uses_alias = False
32 adva_fsp_if_operstates = {
33 "1": ("up", 0),
34 "2": ("down", 2),
35 "3": ("testing", 1),
36 "4": ("unknown", 3),
37 "5": ("dormant", 1),
38 "6": ("notPresent", 2),
39 "7": ("lowerLayerDown", 2),
42 adva_fsp_if_adminstates = {
43 "1": ("up", 0),
44 "2": ("down", 2),
45 "3": ("testing", 1),
49 @network_interface_scan_registry.register
50 def snmp_scan_function_adva_fsp_if(oid):
51 return oid(".1.3.6.1.2.1.1.1.0") == "Fiber Service Platform F7"
54 def inventory_adva_fsp_if(info):
55 inventory = []
56 for line in info:
57 if line[2] in adva_fsp_if_inventory_porttypes and line[
58 3] in adva_fsp_if_inventory_portstates:
59 if adva_fsp_if_inventory_uses_description and line[1] != "":
60 item = line[1]
61 elif adva_fsp_if_inventory_uses_alias and line[5] != "":
62 item = line[5]
63 else:
64 item = line[0]
65 inventory.append((item, {}))
66 return inventory
69 def adva_fsp_if_getindex(item, info):
70 for line in info:
71 if adva_fsp_if_inventory_uses_description:
72 if line[1] == item:
73 return line[0]
74 elif adva_fsp_if_inventory_uses_alias:
75 if line[5] == item:
76 return line[0]
77 else:
78 return item
81 def check_adva_fsp_if(item, params, info):
82 index = adva_fsp_if_getindex(item, info)
83 for line in info:
84 if line[0] == index:
85 state = 0
86 admintxt, adminstate = adva_fsp_if_adminstates[line[3]]
87 state = max(adminstate, state)
88 opertxt, operstate = adva_fsp_if_operstates[line[4]]
89 state = max(operstate, state)
90 if state == 2:
91 statesym = "(!!)"
92 elif state == 1:
93 statesym = "(!)"
94 else:
95 statesym = ""
96 infotext = "Admin/Operational State: %s/%s %s" % (admintxt, opertxt, statesym)
98 perfdata = []
99 for power, name in [(line[6], "output"), (line[7], "input")]:
100 try:
101 sym = ""
102 climits = ""
103 fpower = float(power) / 10.0
104 if params.get("limits_%s_power" % name):
105 lower, upper = params.get("limits_%s_power" % name)
106 climits = "%s:%s" % params.get("limits_%s_power" % name)
107 if fpower < lower or fpower > upper:
108 state = 2
109 sym = "(!!)"
110 infotext += ", %s Power: %.1f%s" % (name.title(), fpower, sym)
111 perfdata.append(("%s_power" % name, "%.1fdBm" % fpower, "", climits))
113 except:
114 if not re.match("S", item): # if no service interface and no power parameter
115 infotext += ", %s Power: n.a. (!)" % name.title()
116 state = max(1, state)
118 return (state, infotext, perfdata)
120 return (3, "no such interface found")
123 check_info['adva_fsp_if'] = {
124 "inventory_function": inventory_adva_fsp_if,
125 "check_function": check_adva_fsp_if,
126 "service_description": 'Interface %s',
127 "has_perfdata": True,
128 "group": "adva_ifs",
129 "snmp_info": (
130 ".1.3.6.1",
132 "2.1.2.2.1.1", # ifIndex
133 "2.1.2.2.1.2", # ifDescr
134 "2.1.2.2.1.3", # ifType
135 "2.1.2.2.1.7", # ifAdminStatus
136 "2.1.2.2.1.8", # ifOperStatus
137 "31.1.1.1.18", # ifAlias
138 "4.1.2544.1.11.2.4.3.5.1.4", # opticalIfDiagOutputPower
139 "4.1.2544.1.11.2.4.3.5.1.3", # opticalIfDiagInputPower
142 "includes": ["if.include"],
143 "snmp_scan_function": snmp_scan_function_adva_fsp_if,