Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the TC4400 modem #15

Open
DeflateAwning opened this issue Sep 18, 2023 · 6 comments
Open

Add support for the TC4400 modem #15

DeflateAwning opened this issue Sep 18, 2023 · 6 comments

Comments

@DeflateAwning
Copy link

No description provided.

@andresp
Copy link
Owner

andresp commented Sep 18, 2023

Thanks for opening the issue. Do you have access to a TC4400? Unfortunately I don't, but I'm happy to take a contribution to the project if you do.

@DeflateAwning
Copy link
Author

I do yeah, I may work on it eventually! Any suggestions on where to start/things to watch out for?

@andresp
Copy link
Owner

andresp commented Sep 24, 2023

That depends a bit in particular how you need to authenticate to the modem. If it's a simple process you could follow the process from the MB8600 modem. If you need to run complex javascript and if it is too complicated to replicate through a few POST calls, then you can follow the TG3492 approach, where Selenium is leveraged to navigate the actual login page through a virtual browser session.

@DeflateAwning
Copy link
Author

The way auth works is you just pass simple HTTP Authentication parameters with every request

@andresp
Copy link
Owner

andresp commented Jan 16, 2024

I've refactored the code a bit. You should be able to create a copy of the Technicolor_xb7 modem or similar and focus on implementing the collectStatus() method, then register your modem in modemtype.py with a new string. Said string can then be used in a configuration. If possible, add a few unittests for the new modem with sample content and responses (successful, failed logins, sample channels page, etc.).

I may add more tests to the existing modems soon, so you could use that as a template to follow.

@biochemie
Copy link

Dumping this out here as I used this to get a scraper for the TC4400 going. I'm not entirely sure where the rest of the script went that did the output/formatting, especially considering the CODA45 scraper I wrote after that is in its (mostly) complete state (had a full telegraf output operational but never got to finishing the syslog or json output formats before we had to get yet another modem). But thought this would at least help to lay out the page scraping for a modem config file.

import requests
from bs4 import BeautifulSoup as bs
from pandas import read_html as rh

auth = requests.auth.HTTPBasicAuth('admin', 'bEn2o#US9s')

if __name__ == '__main__':
    # Pull modem page data
    d = requests.get("http://192.168.100.1/cmconnectionstatus.html", auth=auth)
    # Pull modem event logs
    l = requests.get("http://192.168.100.1/cmeventlog.html", auth=auth)
    # Parse out the page data
    dp = bs(d.text, 'lxml')
    lp = bs(l.text, 'lxml')
    # Pull out the tables of interest
    ds, us, md = dp.find_all('table')[1:4]
    ip = rh(str(md))[0][0][1].split('=')[1]
    uptime = rh(str(md))[0][1][1]
    ds = rh(str(ds), skiprows=1)[0]
    us = rh(str(us), skiprows=1)[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants