2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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.
28 # Strange: Channel IDs seem to be not unique. But the second
29 # usage has '0' in the docsIfUpChannelFrequency...
31 # Info might look different: on the one hand the channel id is the connector
32 # on the other hand the OID. In some cases the channel id is not unique:
34 # [[[u'4', u'3', u'38000000']], [[u'3', u'541092', u'36', u'6', u'498']], []]
36 # [[[u'1337', u'1', u'20000000'],
37 # [u'1338', u'2', u'32000000'],
38 # [u'1339', u'3', u'38000000'],
39 # [u'1361', u'1', u'0'],
40 # [u'1362', u'2', u'0'],
41 # [u'1363', u'3', u'0'],
42 # [u'1364', u'4', u'0']],
43 # [[u'1337', u'2262114535', u'322661943', u'406110', u'293'],
44 # [u'1338', u'2567058620', u'5306417', u'78105', u'328'],
45 # [u'1339', u'4222307191', u'4132447', u'19600', u'339'],
46 # [u'1361', u'0', u'0', u'0', u'0'],
47 # [u'1362', u'0', u'0', u'0', u'0'],
48 # [u'1363', u'0', u'0', u'0', u'0'],
49 # [u'1364', u'0', u'0', u'0', u'0']],
50 # [[u'1337', u'9', u'9', u'9', u'5'],
51 # [u'1338', u'10', u'10', u'10', u'61'],
52 # [u'1339', u'10', u'10', u'10', u'4'],
53 # [u'1361', u'0', u'0', u'0', u'0'],
54 # [u'1362', u'0', u'0', u'0', u'0'],
55 # [u'1363', u'0', u'0', u'0', u'0'],
56 # [u'1364', u'0', u'0', u'0', u'0']]]
58 # [[[u'4', u'3', u'32400000'],
59 # [u'80', u'1', u'25200000'],
60 # [u'81', u'2', u'27600000'],
61 # [u'82', u'4', u'38800000']],
62 # [[u'3', u'104052489', u'22364', u'23308', u'389']],
65 factory_settings
["docsis_channels_upstream_default_levels"] = {
66 "signal_noise": (10.0, 5.0), # dB
67 "corrected": (5.0, 8.0), # Percent
68 "uncorrectable": (1.0, 2.0), # Percent
72 def parse_docsis_channels_upstream(info
):
74 freq_info_dict
= dict([(x
[0], x
[1:]) for x
in freq_info
])
75 sig_info_dict
= dict([(x
[0], x
[1:]) for x
in info
[1]])
76 cm_info_dict
= dict([(x
[0], x
[1:]) for x
in info
[2]])
79 for endoid
, (cid
, freq_str
) in freq_info_dict
.items():
80 unique_name
= cid
if len(freq_info
) == len({x
[1] for x
in freq_info
81 }) else ('%s.%s' % (endoid
, cid
))
84 if endoid
in sig_info_dict
:
85 data
= sig_info_dict
[endoid
] + cm_info_dict
.get(endoid
, [])
86 elif cid
in sig_info_dict
:
87 data
= sig_info_dict
[cid
] + cm_info_dict
.get(cid
, [])
90 parsed
[unique_name
] = [float(freq_str
)] + data
95 def inventory_docsis_channels_upstream(parsed
):
96 for unique_name
, entry
in parsed
.items():
97 if entry
[0] != '0' and entry
[4] != '0':
101 def check_docsis_channels_upstream(item
, params
, parsed
):
104 mhz
, unerroreds
, correcteds
, uncorrectables
, signal_noise
= entry
[:5]
107 noise_db
= float(signal_noise
) / 10
108 infotext
= "Signal/Noise ratio: %.2f dB" % noise_db
109 warn
, crit
= params
['signal_noise']
114 elif noise_db
< warn
:
118 infotext
+= " (warn/crit below %.1f/%.1f dB)" % (warn
, crit
)
120 yield state
, infotext
, [('signal_noise', noise_db
, warn
, crit
)]
122 fields
= [("frequency", float(mhz
) / 1000000, "Frequency", "%.2f", " MHz")]
124 total
, active
, registered
, avg_util
= entry
[5:9]
125 fields
+= [("total", int(total
), "Modems total", "%d", ""),
126 ("active", int(active
), "Active", "%d", ""),
127 ("registered", int(registered
), "Registered", "%d", ""),
128 ("util", int(avg_util
), "Aaverage utilization", "%d", "%")]
130 for varname
, value
, title
, form
, unit
in fields
:
131 yield 0, title
+ ": " + (form
+ "%s") % (value
, unit
), [(varname
, value
)]
133 # Handle codewords. These are counters.
137 for what
, counter
in [(
143 ), ("uncorrectable", int(uncorrectables
))]:
144 rate
= get_rate("docsis_channels_upstream.%s.%s" % (item
, what
), now
, counter
)
149 for what
, title
in [(
154 "uncorrectable errors",
156 ratio
= rates
[what
] / total_rate
158 warn
, crit
= params
[what
]
159 infotext
= "%s %s" % (get_percent_human_readable(perc
), title
)
167 infotext
+= " (warn/crit at %.1f/%.1f%%)" % (warn
, crit
)
169 yield state
, infotext
, [("codewords_" + what
, ratio
, warn
/ 100.0, crit
/ 100.0)]
172 check_info
["docsis_channels_upstream"] = {
173 "parse_function": parse_docsis_channels_upstream
,
174 "inventory_function": inventory_docsis_channels_upstream
,
175 "check_function": check_docsis_channels_upstream
,
176 "service_description": "Upstream Channel %s",
177 "has_perfdata": True,
178 "snmp_scan_function": docsis_scan_function
,
181 ".1.3.6.1.2.1.10.127.1.1.2.1",
184 "1", # DOCS-IF-MIB::docsIfUpChannelId
185 "2", # DOCS-IF-MIB::docsIfUpChannelFrequency
188 ".1.3.6.1.2.1.10.127.1.1.4.1",
191 "2", # DOCS-IF-MIB::docsIfSigQUnerroreds:
192 # "Codewords received on this channel without error.
193 # This includes all codewords, whether or not they
194 # were part of frames destined for this device."
195 "3", # DOCS-IF-MIB::docsIfSigQCorrecteds:
196 # "Codewords received on this channel with correctable
197 # errors. This includes all codewords, whether or not
198 # they were part of frames destined for this device."
199 "4", # DOCS-IF-MIB::docsIfSigQUncorrectables:
200 # "Codewords received on this channel with uncorrectable
201 # errors. This includes all codewords, whether or not
202 # they were part of frames destined for this device."
203 "5", # DOCS-IF-MIB::docsIfSigQSignalNoise
206 ".1.3.6.1.4.1.9.9.116.1.4.1.1",
209 "3", # CISCO-DOCS-EXT-MIB::cdxIfUpChannelCmTotal
210 "4", # CISCO-DOCS-EXT-MIB::cdxIfUpChannelCmActive
211 "5", # CISCO-DOCS-EXT-MIB::cdxIfUpChannelCmRegistered
212 "7", # CISCO-DOCS-EXT-MIB::cdxIfUpChannelAvgUtil
215 "default_levels_variable": "docsis_channels_upstream_default_levels",
216 "group": "docsis_channels_upstream",
217 "includes": ["docsis.include"],