Skip to content

Commit 3ef33af

Browse files
committed
typechange: adsl_line-0.7.mkp
new file: local/share/check_mk/checkman/adsl_line new file: local/share/check_mk/checks/adsl_line new file: local/share/check_mk/web/plugins/metrics/adsl_line.py new file: local/share/check_mk/web/plugins/wato/adsl_line.py
1 parent 449a2c8 commit 3ef33af

File tree

5 files changed

+298
-0
lines changed

5 files changed

+298
-0
lines changed

adsl_line-0.7.mkp

-1
This file was deleted.

adsl_line-0.7.mkp

19.1 KB
Binary file not shown.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
title: ADSL Line
2+
agents: snmp
3+
catalog: hw/network/generic
4+
author: Ulrich Baumann <git@uli-baumann.de>
5+
license: GPL
6+
distribution: https://github.com/f-zappa/check_mk_adsl_line
7+
description:
8+
This Check checks status of an ADSL line via the SNMP ADSL-LINE-MIB.
9+
Written for and tested with a DrayTek Vigor165, should work on other DrayTek ADSL
10+
routers/modems and probably with other hardware (feedback is welcome).
11+
12+
item:
13+
according to adslLineSpecific
14+
15+
inventory:
16+
One check per ADSL Line is created

local/share/check_mk/checks/adsl_line

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/usr/bin/python
2+
3+
# Description: Check-MK plugin for monitoring adsl lines
4+
# File: adsl_line
5+
# Version: 1.0
6+
# Author: Ulrich Baumann <check_mk@uli-baumann.de>
7+
#
8+
# https://www.draytek.com/support/knowledge-base/5517
9+
# supported ADSL-LINE-MIB OIDs in Draytek Vigor Routers
10+
# (ADSL and VDSL are using same OIDs)
11+
# 1.3.6.1.2.1.10.94.1.1.1.1.1 adslLineCoding
12+
# 1.3.6.1.2.1.10.94.1.1.1.1.2 adslLineType
13+
# 1.3.6.1.2.1.10.94.1.1.1.1.3 adslLineSpecific
14+
# 1.3.6.1.2.1.10.94.1.1.1.1.4 adslLineConfProfile
15+
# 1.3.6.1.2.1.10.94.1.1.1.1.5 adslLineAlarmConfProfile
16+
# 1.3.6.1.2.1.10.94.1.1.3.1.1 adslAturInvSerialNumber
17+
# 1.3.6.1.2.1.10.94.1.1.3.1.2 adslAturInvVendorID
18+
# 1.3.6.1.2.1.10.94.1.1.3.1.3 adslAturInvVersionNumber
19+
# 1.3.6.1.2.1.10.94.1.1.3.1.4 adslAturCurrSnrMgn
20+
# 1.3.6.1.2.1.10.94.1.1.3.1.5 adslAturCurrAtn
21+
# 1.3.6.1.2.1.10.94.1.1.3.1.6 adslAturCurrStatus
22+
# 1.3.6.1.2.1.10.94.1.1.3.1.7 adslAturCurrOutputPwr
23+
# 1.3.6.1.2.1.10.94.1.1.3.1.8 adslAturCurrAttainableRate
24+
# 1.3.6.1.2.1.10.94.1.1.4.1.2 adslAtucChanCurrTxRate (DSL router's Rx Rate)
25+
# 1.3.6.1.2.1.10.94.1.1.5.1.1 adslAturChanInterleaveDelay
26+
# 1.3.6.1.2.1.10.94.1.1.5.1.2 adslAturChanCurrTxRate (DSL router's Tx rate)
27+
# 1.3.6.1.2.1.10.94.1.1.5.1.3 adslAturChanPrevTxRate
28+
# 1.3.6.1.2.1.10.94.1.1.5.1.4 adslAturChanCrcBlockLength
29+
30+
def inventory_adsl_line(info):
31+
for oid_end,adslLineCoding, adslLineType, adslLineSpecific, \
32+
adslAturInvSerialNumber, adslAturInvVendorID, adslAturInvVersionNumber, \
33+
adslAturCurrSnrMgn, adslAturCurrAtn, adslAturCurrStatus, adslAturCurrOutputPwr, \
34+
adslAturCurrAttainableRate, adslAtucChanCurrTxRate, adslAturChanCurrTxRate \
35+
in info:
36+
yield oid_end, None # item name follows oid enumeration
37+
38+
def check_adsl_line(item, params, info):
39+
# try to extract check parameters
40+
if 'downstream_params' in params:
41+
downstream_warn,downstream_crit = params['downstream_params']
42+
else:
43+
downstream_warn,downstream_crit = 0,0
44+
# constants from ADSL-LINE-MIB
45+
adslLineCodings = { 1: "other", 2: "dmt", 3: "cap", 4: "qam" }
46+
adslLineTypes = { 1: "noChannel", 2: "fastOnly", 3: "interleavedOnly", \
47+
4: "fastOrInterleaved", 5: "fastAndInterleaved" }
48+
# iterate ADSL Lines
49+
for oid_end,adslLineCoding, adslLineType, adslLineSpecific, \
50+
adslAturInvSerialNumber, adslAturInvVendorID, adslAturInvVersionNumber, \
51+
adslAturCurrSnrMgn, adslAturCurrAtn, adslAturCurrStatus, adslAturCurrOutputPwr, \
52+
adslAturCurrAttainableRate, adslAtucChanCurrTxRate, adslAturChanCurrTxRate \
53+
in info:
54+
if (item != oid_end): continue
55+
status = 0
56+
statusString = ''
57+
perfData = []
58+
# check link status
59+
# print upstream_warn,upstream_crit,upstream_warn,upstream_crit
60+
adslAturCurrStatus=cleanup_if_strings(adslAturCurrStatus)
61+
statusString += adslAturCurrStatus
62+
if adslAturCurrStatus != "SHOWTIME":
63+
status = max(status, 2)
64+
# check upstream
65+
statusString += ', Up: '+get_nic_speed_human_readable(adslAturChanCurrTxRate)
66+
if 'upstream_params' in params:
67+
upstream_warn,upstream_crit = params['upstream_params']
68+
upstream_warn=upstream_warn*10**6
69+
upstream_crit=upstream_crit*10**6
70+
if int(adslAturChanCurrTxRate) <= upstream_crit:
71+
status = max(status, 2)
72+
statusString += ' (CRIT at '+get_nic_speed_human_readable(upstream_crit)+')'
73+
elif int(adslAturChanCurrTxRate) <= upstream_warn:
74+
status = max(status, 1)
75+
statusString += ' (WARN at '+get_nic_speed_human_readable(upstream_warn)+')'
76+
else: upstream_warn,upstream_crit=None,None
77+
# check downstream
78+
statusString += ', Down: '+get_nic_speed_human_readable(adslAtucChanCurrTxRate)
79+
if 'downstream_params' in params:
80+
downstream_warn,downstream_crit = params['downstream_params']
81+
downstream_warn=downstream_warn*10**6
82+
downstream_crit=downstream_crit*10**6
83+
if int(adslAtucChanCurrTxRate) <= downstream_crit:
84+
status = max(status, 2)
85+
statusString += ' (CRIT at '+get_nic_speed_human_readable(downstream_crit)+')'
86+
elif int(adslAtucChanCurrTxRate) <= downstream_warn:
87+
status = max(status, 1)
88+
statusString += ' (WARN at '+get_nic_speed_human_readable(downstream_warn)+')'
89+
else: downstream_warn,downstream_crit=None,None
90+
statusString += ', Attainable: '+get_nic_speed_human_readable(adslAturCurrAttainableRate)
91+
# check snr_margin
92+
statusString += ', SNR Margin: ' + adslAturCurrSnrMgn+' dB'
93+
if 'snr_margin_params' in params:
94+
snr_margin_warn,snr_margin_crit = params['snr_margin_params']
95+
if int(adslAturCurrSnrMgn) <= snr_margin_crit:
96+
status = max(status, 2)
97+
statusString += ' (CRIT at '+str(snr_margin_crit)+'dB)'
98+
elif int(adslAturCurrSnrMgn) <= snr_margin_warn:
99+
status = max(status, 1)
100+
statusString += ' (WARN at '+str(snr_margin_warn)+'dB)'
101+
else: snr_margin_warn,snr_margin_crit=None,None
102+
# check attenuation
103+
statusString += ', Attenuation: ' + adslAturCurrAtn+' dB'
104+
if 'attenuation_params' in params:
105+
attenuation_warn,attenuation_crit = params['attenuation_params']
106+
if int(adslAturCurrAtn) >= attenuation_crit:
107+
status = max(status, 2)
108+
statusString += ' (CRIT at '+str(attenuation_crit)+'dB)'
109+
elif int(adslAturCurrAtn) >= attenuation_warn:
110+
status = max(status, 1)
111+
statusString += ' (WARN at '+str(attenuation_warn)+'dB)'
112+
else: attenuation_warn,attenuation_crit=None,None
113+
# additional info for status string
114+
statusString += ', '+\
115+
'Output Power: '+adslAturCurrOutputPwr+' db, '+\
116+
'Line Coding: '+adslLineCodings.get(int(adslLineCoding),"unknown")+', '+\
117+
'Line Type: '+adslLineTypes.get(int(adslLineType),"unknown")
118+
perfData.append(("adsl_up_rate",adslAturChanCurrTxRate,upstream_warn,upstream_crit,0 ))
119+
perfData.append(("adsl_down_rate",adslAtucChanCurrTxRate,downstream_warn,downstream_crit,0))
120+
perfData.append(("adsl_attainable",adslAturCurrAttainableRate))
121+
perfData.append(("adsl_snr_margin",adslAturCurrSnrMgn,snr_margin_warn,snr_margin_crit,0))
122+
perfData.append(("adsl_attenuation",adslAturCurrAtn,attenuation_warn,attenuation_crit,0))
123+
perfData.append(("adsl_output_power",adslAturCurrOutputPwr))
124+
statusMap = { 0: 'OK', 1: 'WARN', 2: 'CRIT' }
125+
return status,statusMap.get(status)+' - '+statusString, perfData
126+
127+
def scan_adsl(oid):
128+
sys_descr = oid(".1.3.6.1.2.1.1.1.0").lower()
129+
for type_ in [ "vigor130", "vigor165", ]:
130+
if type_ in sys_descr:
131+
return True
132+
return False
133+
134+
check_info["adsl_line"] = {
135+
"check_function" : check_adsl_line,
136+
"group" : "adsl_line",
137+
"inventory_function" : inventory_adsl_line,
138+
"service_description" : "ADSL at Interface %s",
139+
"snmp_info" : ( ".1.3.6.1.2.1.10.94.1.1", [ \
140+
OID_END, # interface number
141+
"1.1.1", # adslLineCoding
142+
"1.1.2", # adslLineType
143+
"1.1.3", # adslLineSpecific
144+
"3.1.1", # adslAturInvSerialNumber
145+
"3.1.2", # adslAturInvVendorID
146+
"3.1.3", # adslAturInvVersionNumber
147+
"3.1.4", # adslAturCurrSnrMgn
148+
"3.1.5", # adslAturCurrAtn
149+
"3.1.6", # adslAturCurrStatus
150+
"3.1.7", # adslAturCurrOutputPwr
151+
"3.1.8", # adslAturCurrAttainableRate
152+
"4.1.2", # adslAtucChanCurrTxRate
153+
"5.1.2", # adslAtucChanCurrTxRate
154+
] ),
155+
"snmp_scan_function" : scan_adsl,
156+
"includes" : ["if.include"],
157+
"has_perfdata" : True
158+
}
159+
160+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
check_metrics["check_mk-adsl_line"] = {
2+
"adsl_down_rate": { "name" : "adsl_down_rate" },
3+
"adsl_up_rate": { "name" : "adsl_up_rate" },
4+
"adsl_attainable": { "name" : "adsl_attainable" },
5+
"adsl_snr_margin": { "name" : "adsl_snr_margin" },
6+
"adsl_attenuation": { "name" : "adsl_attenuation" },
7+
"adsl_output_power": { "name" : "output_signal_power_dbm" },
8+
}
9+
10+
metric_info["adsl_down_rate"] = {
11+
"title": _("Downstream Rate"),
12+
"unit": "bits/s",
13+
"color": "33/a",
14+
}
15+
16+
metric_info["adsl_up_rate"] = {
17+
"title": _("Upstream Rate"),
18+
"unit": "bits/s",
19+
"color": "12/a",
20+
}
21+
22+
metric_info["adsl_attainable"] = {
23+
"title": _("Attainable Rate"),
24+
"unit": "bits/s",
25+
"color": "41/b",
26+
"auto_graph": False,
27+
}
28+
29+
metric_info["adsl_attenuation"] = {
30+
"title": _("Signal Attenuation"),
31+
"unit": "db",
32+
"color": "43/b",
33+
}
34+
35+
metric_info["adsl_snr_margin"] = {
36+
"title": _("SNR Margin"),
37+
"unit": "db",
38+
"color": "45/b",
39+
}
40+
41+
graph_info["adsl_down_rate"] = {
42+
"metrics": [("adsl_down_rate", "area"),
43+
("adsl_attainable","line")],
44+
"scalars": [
45+
"adsl_down_rate:warn",
46+
"adsl_down_rate:crit", ],
47+
}
48+
49+
graph_info["adsl_up_rate"] = {
50+
"metrics": ("adsl_up_rate", "area"),
51+
"scalars": [
52+
"adsl_up_rate:warn",
53+
"adsl_up_rate:crit", ],
54+
}
55+
56+
graph_info["adsl_snr_margin"] = {
57+
"metrics": ("adsl_snr_margin", "area"),
58+
"scalars": [
59+
"adsl_snr_margin:warn",
60+
"adsl_snr_margin:crit", ],
61+
}
62+
63+
graph_info["adsl_attenuation"] = {
64+
"metrics": ("adsl_attenuation", "area"),
65+
"scalars": [
66+
"adsl_attenuation:warn",
67+
"adsl_attenuation:crit", ],
68+
}
69+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/python
2+
# -*- encoding: utf-8; py-indent-offset: 4 -*-
3+
4+
# Rules for configuring parameters of check adsl_line
5+
6+
register_check_parameters(
7+
subgroup_networking,
8+
'adsl_line',
9+
_('ADSL Line'),
10+
Dictionary(
11+
title = _('ADSL Line'),
12+
help = _('Check the Status of ADSL Lines'),
13+
elements = [
14+
('upstream_params', Tuple(
15+
title='Upstream Rate',
16+
help = _('Minimum Upstream Rate'),
17+
elements = [
18+
Integer(title=_('Warning at'),unit='Mbit/s',default_value='50'),
19+
Integer(title=_('Critical at'),unit='Mbit/s',default_value='30'),
20+
] ) ),
21+
('downstream_params', Tuple(
22+
title='Downstream Rate',
23+
help = _('Minimum Downstream Rate'),
24+
elements = [
25+
Integer(title=_('Warning at'),unit='Mbit/s',default_value='50'),
26+
Integer(title=_('Critical at'),unit='Mbit/s',default_value='30'),
27+
] ) ),
28+
('snr_margin_params', Tuple(
29+
title='SNR Margin',
30+
help = _('Minimum SNR Margin'),
31+
elements = [
32+
Integer(title=_('Warning at'),unit='dB',default_value='8'),
33+
Integer(title=_('Critical at'),unit='dB',default_value='5'),
34+
] ) ),
35+
('attenuation_params', Tuple(
36+
title='Attenuation',
37+
help = _('Maximum Attenuation'),
38+
elements = [
39+
Integer(title=_('Warning at'),unit='dB',default_value='40'),
40+
Integer(title=_('Critical at'),unit='dB',default_value='50'),
41+
] ) ),
42+
]
43+
),
44+
TextAscii(
45+
title = _("ADSL Line"),
46+
help = _("Specify the Interface Number of ADSL Line. "),
47+
allow_empty = False
48+
),
49+
'dict'
50+
)
51+
52+
53+

0 commit comments

Comments
 (0)