Révision 7b078749
Address review comments
Signed-off-by: Nathaniel Clark <Nathaniel.Clark@misrule.us>
| plugins/router/arris-sb6183 | ||
|---|---|---|
| 1 |
#!/usr/bin/python
|
|
| 1 |
#!/usr/bin/env python3
|
|
| 2 | 2 |
|
| 3 |
# modem: |
|
| 4 |
# |
|
| 5 |
# * upstream and downstream power levels |
|
| 6 |
# * downstream signal to noise ratio |
|
| 7 |
# * downstream error counts |
|
| 3 |
# Copyright 2020 Nathaniel Clark <nathaniel.clark@misrule.us> |
|
| 8 | 4 |
# |
| 9 |
# The values are retrieved from the cable modem's status web pages at
|
|
| 10 |
# 192.168.100.1. So, this plugin must be installed on a munin node
|
|
| 11 |
# which can access those pages.
|
|
| 5 |
# This program is free software; you can redistribute it and/or modify
|
|
| 6 |
# it under the terms of the GNU Library General Public License as published by
|
|
| 7 |
# the Free Software Foundation; version 2 only
|
|
| 12 | 8 |
# |
| 13 |
# To install, place this plugin in the node's plugins directory, |
|
| 14 |
# /etc/munin/plugins and restart munin-node. |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU Library General Public License for more details. |
|
| 15 | 13 |
# |
| 16 |
# Developed and tested with:
|
|
| 17 |
# firmware: D30CM-OSPREY-2.4.0.1-GA-02-NOSH
|
|
| 18 |
# hardware version: 1
|
|
| 14 |
# You should have received a copy of the GNU Library General Public License
|
|
| 15 |
# along with this program; if not, write to the Free Software
|
|
| 16 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
| 19 | 17 |
# |
| 20 |
# Copyright 2020 Nathaniel Clark <nathaniel.clark@misrule.us> |
|
| 21 | 18 |
|
| 22 | 19 |
""" |
| 23 | 20 |
=head1 NAME |
| 24 | 21 |
|
| 25 | 22 |
arris-sb6183 - Health monitoring plugin for Arris SB6183 Cable Modem |
| 26 | 23 |
|
| 24 |
=head1 DESCRIPTION |
|
| 25 |
|
|
| 26 |
This provides the following multigraphs: |
|
| 27 |
* upstream and downstream power levels |
|
| 28 |
* downstream signal to noise ratio |
|
| 29 |
* downstream error counts |
|
| 30 |
|
|
| 31 |
The values are retrieved from the cable modem's status web pages at |
|
| 32 |
192.168.100.1. So, this plugin must be installed on a munin node |
|
| 33 |
which can access those pages. |
|
| 34 |
|
|
| 27 | 35 |
=head1 CONFIGURATION |
| 28 | 36 |
|
| 29 | 37 |
Make sure 192.168.100.1 is accessible through your firewall. |
| ... | ... | |
| 34 | 42 |
[arris*] |
| 35 | 43 |
env.hostname modem |
| 36 | 44 |
|
| 45 |
=head1 TESTING |
|
| 46 |
|
|
| 47 |
Developed and tested with: |
|
| 48 |
firmware: D30CM-OSPREY-2.4.0.1-GA-02-NOSH |
|
| 49 |
hardware version: 1 |
|
| 50 |
|
|
| 37 | 51 |
=head1 VERSION |
| 38 | 52 |
|
| 39 | 53 |
0.0.1 |
| ... | ... | |
| 57 | 71 |
import re |
| 58 | 72 |
import os |
| 59 | 73 |
import sys |
| 60 |
import requests |
|
| 61 |
from lxml import html |
|
| 74 |
from urllib import request |
|
| 62 | 75 |
|
| 63 |
|
|
| 64 |
URL = os.getenv("url", "http://192.168.100.1/RgConnect.asp")
|
|
| 65 | 76 |
HOSTNAME = os.getenv("hostname", None)
|
| 66 |
UPCOUNT = int(os.getenv("up", 4))
|
|
| 67 |
DOWNCOUNT = int(os.getenv("down", 16))
|
|
| 77 |
URL = "http://192.168.100.1/RgConnect.asp" |
|
| 78 |
UPCOUNT = 4 |
|
| 79 |
DOWNCOUNT = 16 |
|
| 68 | 80 |
|
| 69 | 81 |
if len(sys.argv) == 2: |
| 70 | 82 |
if sys.argv[1] == "config": |
| ... | ... | |
| 83 | 95 |
for i in range(1, UPCOUNT + 1): |
| 84 | 96 |
print("up_{0}.label Up Ch {1}".format(i, i))
|
| 85 | 97 |
print("up_{0}.type GAUGE".format(i))
|
| 86 |
# print("up_{0}.draw LINE1".format(i))
|
|
| 98 |
print("up_{0}.draw LINE1".format(i))
|
|
| 87 | 99 |
|
| 88 | 100 |
for i in range(1, DOWNCOUNT + 1): |
| 89 | 101 |
name = "down_{0}".format(i)
|
| ... | ... | |
| 156 | 168 |
|
| 157 | 169 |
if sys.argv[1] == "autoconfig": |
| 158 | 170 |
try: |
| 159 |
page = requests.get(URL) |
|
| 160 |
except: |
|
| 171 |
from lxml import html |
|
| 172 |
|
|
| 173 |
resp = request.urlopen(URL) |
|
| 174 |
except ImportError: |
|
| 175 |
print("no (missing lxml module)")
|
|
| 176 |
except OSError: |
|
| 161 | 177 |
print("no (no router)")
|
| 162 | 178 |
else: |
| 163 |
if page.status_code == 200:
|
|
| 179 |
if resp.status == 200:
|
|
| 164 | 180 |
print("yes")
|
| 165 | 181 |
else: |
| 166 | 182 |
print("no (Bad status code: %d)" % page.status_code)
|
| 167 | 183 |
sys.exit(0) |
| 168 | 184 |
|
| 185 |
from lxml import html |
|
| 186 |
|
|
| 169 | 187 |
rxblank = re.compile(r"[\x00\n\r\t ]+", re.MULTILINE) |
| 170 | 188 |
rxcomment = re.compile(r"<!--.*?-->") |
| 171 | 189 |
rxscript = re.compile(r"<script.*?</script>", re.MULTILINE) |
| 172 | 190 |
|
| 173 |
page = requests.get(URL) |
|
| 174 |
data = rxscript.sub("", rxcomment.sub("", rxblank.sub(" ", page.text)))
|
|
| 191 |
resp = request.urlopen(URL) |
|
| 192 |
data = rxscript.sub( |
|
| 193 |
"", |
|
| 194 |
rxcomment.sub( |
|
| 195 |
"", |
|
| 196 |
rxblank.sub(" ", "".join(map(lambda x: x.decode("utf-8"), resp.readlines()))),
|
|
| 197 |
), |
|
| 198 |
) |
|
| 175 | 199 |
dom = html.fromstring(data) |
| 176 | 200 |
|
| 177 | 201 |
arr = dom.xpath('//table[contains(@class, "simpleTable")]')
|
| ... | ... | |
| 185 | 209 |
headings = ["".join(x.itertext()).strip() for x in trs.pop(0).findall("td")]
|
| 186 | 210 |
# ['Channel', 'Lock Status', 'Modulation', 'Channel ID', 'Frequency', 'Power', 'SNR', 'Corrected', 'Uncorrectables'] |
| 187 | 211 |
|
| 188 |
mapper = lambda x, y: (x, y) |
|
| 189 |
|
|
| 190 | 212 |
# Summation Graphs |
| 191 | 213 |
correct = 0 |
| 192 | 214 |
uncorr = 0 |
| ... | ... | |
| 194 | 216 |
snr = ["U"] * DOWNCOUNT |
| 195 | 217 |
for row in trs: |
| 196 | 218 |
data = dict( |
| 197 |
map( |
|
| 198 |
mapper, headings, ["".join(x.itertext()).strip() for x in row.findall("td")]
|
|
| 199 |
) |
|
| 219 |
zip(headings, ["".join(x.itertext()).strip() for x in row.findall("td")])
|
|
| 200 | 220 |
) |
| 201 | 221 |
uncorr += int(data["Uncorrectables"]) |
| 202 | 222 |
correct += int(data["Corrected"]) |
| ... | ... | |
| 245 | 265 |
# ['Channel', 'Lock Status', 'US Channel Type', 'Channel ID', 'Symbol Rate', 'Frequency', 'Power'] |
| 246 | 266 |
for row in trs: |
| 247 | 267 |
data = dict( |
| 248 |
map( |
|
| 249 |
mapper, headings, ["".join(x.itertext()).strip() for x in row.findall("td")]
|
|
| 250 |
) |
|
| 268 |
zip(headings, ["".join(x.itertext()).strip() for x in row.findall("td")])
|
|
| 251 | 269 |
) |
| 252 | 270 |
channel = int(data["Channel"]) |
| 253 | 271 |
print("multigraph arris_power.up_{0}".format(channel))
|
| plugins/router/arris-sb6183_uptime | ||
|---|---|---|
| 1 |
#!/usr/bin/python
|
|
| 1 |
#!/usr/bin/env python3
|
|
| 2 | 2 |
|
| 3 |
# modem: |
|
| 4 |
# |
|
| 5 |
# * uptime |
|
| 3 |
# Copyright 2020 Nathaniel Clark <nathaniel.clark@misrule.us> |
|
| 6 | 4 |
# |
| 7 |
# The values are retrieved from the cable modem's status web pages at
|
|
| 8 |
# 192.168.100.1. So, this plugin must be installed on a munin node
|
|
| 9 |
# which can access those pages.
|
|
| 5 |
# This program is free software; you can redistribute it and/or modify
|
|
| 6 |
# it under the terms of the GNU Library General Public License as published by
|
|
| 7 |
# the Free Software Foundation; version 2 only
|
|
| 10 | 8 |
# |
| 11 |
# To install, place this plugin in the node's plugins directory, |
|
| 12 |
# /etc/munin/plugins and restart munin-node. |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU Library General Public License for more details. |
|
| 13 | 13 |
# |
| 14 |
# Developed and tested with:
|
|
| 15 |
# firmware: D30CM-OSPREY-2.4.0.1-GA-02-NOSH
|
|
| 16 |
# hardware version: 1
|
|
| 14 |
# You should have received a copy of the GNU Library General Public License
|
|
| 15 |
# along with this program; if not, write to the Free Software
|
|
| 16 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
| 17 | 17 |
# |
| 18 |
# Copyright 2020 Nathaniel Clark <nathaniel.clark@misrule.us> |
|
| 19 | 18 |
|
| 20 | 19 |
""" |
| 21 | 20 |
=head1 NAME |
| ... | ... | |
| 32 | 31 |
[arris*] |
| 33 | 32 |
env.hostname modem |
| 34 | 33 |
|
| 34 |
=head1 TESTING |
|
| 35 |
|
|
| 36 |
Developed and tested with: |
|
| 37 |
firmware: D30CM-OSPREY-2.4.0.1-GA-02-NOSH |
|
| 38 |
hardware version: 1 |
|
| 39 |
|
|
| 35 | 40 |
=head1 VERSION |
| 36 | 41 |
|
| 37 | 42 |
0.0.1 |
| ... | ... | |
| 54 | 59 |
import re |
| 55 | 60 |
import os |
| 56 | 61 |
import sys |
| 57 |
import requests |
|
| 58 |
from lxml import html |
|
| 62 |
from urllib import request |
|
| 59 | 63 |
|
| 60 | 64 |
|
| 61 |
URL = os.getenv("url", "http://192.168.100.1/RgSwInfo.asp")
|
|
| 62 | 65 |
HOSTNAME = os.getenv("hostname", None)
|
| 66 |
URL = "http://192.168.100.1/RgSwInfo.asp" |
|
| 63 | 67 |
|
| 64 | 68 |
if len(sys.argv) == 2: |
| 65 | 69 |
if sys.argv[1] == "config": |
| 66 |
print("host_name {0}".format(HOSTNAME))
|
|
| 70 |
if HOSTNAME: |
|
| 71 |
print("host_name {0}".format(HOSTNAME))
|
|
| 67 | 72 |
|
| 68 | 73 |
# POWER |
| 69 | 74 |
print( |
| ... | ... | |
| 83 | 88 |
|
| 84 | 89 |
if sys.argv[1] == "autoconfig": |
| 85 | 90 |
try: |
| 86 |
page = requests.get(URL) |
|
| 87 |
except: |
|
| 91 |
from lxml import html |
|
| 92 |
|
|
| 93 |
resp = request.urlopen(URL) |
|
| 94 |
except ImportError: |
|
| 95 |
print("no (missing lxml module)")
|
|
| 96 |
except OSError: |
|
| 88 | 97 |
print("no (no router)")
|
| 89 | 98 |
else: |
| 90 | 99 |
if page.status_code == 200: |
| ... | ... | |
| 93 | 102 |
print("no (Bad status code: %d)" % page.status_code)
|
| 94 | 103 |
sys.exit(0) |
| 95 | 104 |
|
| 105 |
from lxml import html |
|
| 106 |
|
|
| 96 | 107 |
rxblank = re.compile(r"[\x00\n\r\t ]+", re.MULTILINE) |
| 97 | 108 |
rxcomment = re.compile(r"<!--.*?-->") |
| 98 | 109 |
rxscript = re.compile(r"<script.*?</script>", re.MULTILINE) |
| 99 | 110 |
|
| 100 |
page = requests.get(URL) |
|
| 101 |
data = rxscript.sub("", rxcomment.sub("", rxblank.sub(" ", page.text)))
|
|
| 111 |
resp = request.urlopen(URL) |
|
| 112 |
if resp.status != 200: |
|
| 113 |
print( |
|
| 114 |
"failed to get status page %d: %s" % (resp.status, resp.reason), file=sys.stderr |
|
| 115 |
) |
|
| 116 |
print("uptime.value U")
|
|
| 117 |
sys.exit(0) |
|
| 118 |
|
|
| 119 |
data = rxscript.sub( |
|
| 120 |
"", |
|
| 121 |
rxcomment.sub( |
|
| 122 |
"", |
|
| 123 |
rxblank.sub(" ", "".join(map(lambda x: x.decode("utf-8"), resp.readlines()))),
|
|
| 124 |
), |
|
| 125 |
) |
|
| 102 | 126 |
dom = html.fromstring(data) |
| 103 | 127 |
|
| 104 | 128 |
arr = dom.xpath('//table[contains(@class, "simpleTable")]')
|
Formats disponibles : Unified diff