A Python script that scrapes an Arris modem status page to insert signal levels into InfluxDB and ultimately Grafana.
The scraper is flexible in that you can subclass pieces to scrape other modems and upload to other databases. With a few tweaks it could be an all-purpose HTML -> Grafana scraper for something entirely unrelated to cable modems!
A preset Grafana dashboard is included with this project with some alerts that monitor the modem's signal levels. The level thresholds were created from the data on this website.
Expand for list of fields and tags
- Fields: - Downstream - SNR - DCID - Frequency - Power - Octets - Correcteds - Uncorrectables - Upstream - UCID - Frequency - Power - Symbol Rate - Tags: - Downstream ID - Modulation (downstream / upstream) - Upstream ID - Channel Type (upstream)- You must know your modem's IP address. Typically these status pages are accessible without authentication from your LAN by going to a URL such as http://192.168.100.1.
- Hopefully your status page matches the screenshot above. If not, see the section below entitled Extending.
Copy config_sample.py
to config.py
and fill in your modem's URL and model as well as your InfluxDB hostname. Depending on your InfluxDB configuration, you may need to add more options (e.g. authentication). See the influxdb.InfluxDBClient
Python module for all possibilities.
Python only
- Follow the instructions above to set up the config file.
pip install -r requirements.txt
python scrape.py
Docker
- Follow the instructions above to set up the config file.
- Install Docker
- Run
docker-compose build
- Run
docker-compose up
Import the included Grafana JSON and tweak appropriately.
Option B: I don't run InfluxDB or Grafana but I want to scrape my modem, or I want to test drive this project.
- Install Docker
- Copy
config_sample.py
toconfig.py
and configure the modem URL. Set the host for the InfluxDB section toinfluxdb
('host': 'influxdb'
). - Run
docker-compose -f full-service.yml build
- Run
docker-compose -f full-service.yml up
- Login to Grafana at http://localhost:3000 with the credentials
admin
/admin
- Open the Modem dashboard
There's a good chance your modem status page doesn't match this one, but you want to accomplish the same task. If your modem allows you to see a status page without any authentication but it just has a different layout, then adapting is straightforward. Just create a new subclass of arris_modem.py
target and change the fields and xpath queries as needed. Use the PrinterOutputter
to see what data points would be uploaded to InfluxDB before doing any real uploading.
If your modem requires some form of authentication, you'll need to implement that part. It may be as simple as snooping on HTTP headers using your browser to see what the script needs to send.
A simple debugging tool exists in tools
that will process and output either a remote or local HTML status page.
- Run
pip install -r requirements.txt
in the root of the repo (or install modules as needed) - Copy
config_sample.py
toconfig.py
(in its directory) and populate the values - Run
python3 debugger.py
Save the modem's status page as an HTML file locally and point config.py
to its path, then set is_remote
to True
. Relative paths are supported, so if dropping this file in the tools
directory just supply the filename.