|
| 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 | + |
0 commit comments