From d8ef1a40a179d22f93709265452597d86f73e752 Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Sat, 10 Mar 2012 23:58:28 -0800 Subject: [PATCH] add plugin to monitor ARRIS TM502G cable modem --- plugins/network/arris-tm502g_ | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 plugins/network/arris-tm502g_ diff --git a/plugins/network/arris-tm502g_ b/plugins/network/arris-tm502g_ new file mode 100755 index 00000000..8e1bf35d --- /dev/null +++ b/plugins/network/arris-tm502g_ @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# -*- python -*- + +# This plugin graphs the following values of the ARRIS TM502G cable +# modem: +# +# * upstream and downstream powers +# * downstream signal-to-noise ratio +# +# The values are retrieved from the cable modem's status web pages at +# 192.168.100.1. So, this plugin must be installed on a munin node +# which can access those pages. +# +# Symlink this plugin into the node's plugins directory (like +# /etc/munin/plugins) as arris-tm502g_power for the powers, and +# arris-tm502g_snr for the SNR. +# +# Author: Kenyon Ralph +# +# The latest version of this plugin can be found in the munin contrib +# repository at https://github.com/munin-monitoring/contrib. Issues +# with this plugin may be reported there. Patches accepted through the +# normal github process of forking the repository and submitting a +# pull request with your commits. + +import html.parser +import os +import urllib.request +import sys + +plugin_name=list(os.path.split(sys.argv[0]))[1] +plugin_var=plugin_name.split('_', 1)[-1] + +if len(sys.argv) == 2 and sys.argv[1] == 'config': + if plugin_var == 'power': + print('graph_title ARRIS Cable Modem Power') + print('graph_vlabel Signal Strength (dBmV)') + print('graph_info This graph shows the downstream and upstream power reported by an ARRIS TM502G cable modem.') + print('downstream.label Downstream Power (dBmV)') + print('upstream.label Upstream Power (dBmV)') + if plugin_var == 'snr': + print('graph_title ARRIS Cable Modem SNR') + print('graph_vlabel Signal-to-Noise Ratio (dB)') + print('graph_info This graph shows the downstream signal-to-noise ratio reported by an ARRIS TM502G cable modem.') + print('snr.label Signal-to-Noise Ratio (dB)') + print('graph_category network') + sys.exit(0) + +class ArrisHTMLParser(html.parser.HTMLParser): + stats = list() + down_power = 'U' + up_power = 'U' + snr = 'U' + def handle_data(self, data): + data = data.strip() + if data != '' and 'dB' in data: + self.stats.append(data) + def done(self): + """Call this when done feeding the HTML page to the parser.""" + self.down_power = self.stats[0].split()[0] + self.snr = self.stats[1].split()[0] + self.up_power = self.stats[2].split()[0] + +page = urllib.request.urlopen("http://192.168.100.1/") +parser = ArrisHTMLParser() +for line in page: + parser.feed(line.decode()) +parser.done() + +if plugin_var == 'power': + print('downstream.value ' + parser.down_power) + print('upstream.value ' + parser.up_power) + sys.exit(0) + +if plugin_var == 'snr': + print('snr.value ' + parser.snr) + sys.exit(0)