Modem Monitor Update [Updated]

I bought a new modem today, slightly hoping that it will fix whatever connection issues i’m having, it’s a newer model surfboard (SB6190) and as such I’ve had to update my script which checks the status.

import requests
import datetime
from bs4 import BeautifulSoup
#import dateparser
import tweepy
import re

#Set up Twitter creds

#Authenticate with Twitter

#Set up regex patterns
timespanPattern = re.compile("^(\d+)\s+d:\s+(\d{1,2})\s+h:\s+(\d{1,2})\s+m$")

#scrape the modem page
page = requests.get("http://[REPLACE WITH INTERNAL IP OF MODEM]/cgi-bin/swinfo")
soup = BeautifulSoup(page.content, 'html.parser')

#navigate the DOM to get the desired data
modeminfo = list(soup.find_all('table', {"class": "simpleTable"})[1])
#print modeminfo
uptime = list(modeminfo[3].children)[3]
#print uptime
timestr = uptime.get_text()
#print timestr

#Take the text and get the time data out
matches = timespanPattern.match(timestr)
#print "Days: " +
#print "Hours: " +
#print "Minutes: " +
days = int(
hours = int(
minutes = int(

#create timespan so we can figure out at what time the reboot happened
span = datetime.timedelta(days=days,hours=hours,minutes=minutes)
currenttime =
timespan = currenttime - span
status = ""

if minutes < 5 and days == 0:
status="Hey @Comcast, my modem just rebooted at " + timespan.strftime("%Y-%m-%d %H:%M:%S")
print status
print "Modem has been up since " + timespan.strftime("%Y-%m-%d %H:%M:%S")

Update 7/15/2017 19:04
It looks like the new modem doesn’t behave like the old one. The old one would reboot automatically when things got unstable and would log a bunch of T3 and T4 errors. The new one does similar, but doesn’t reboot, it’ll just stay up. I’ll have to find a new approach to annoy Comcast 😛 Today the internet connection wouldn’t stay up for longer than an hour after I put the new modem on. I got in contact with Comcast’s online support and they did some magic on their end and after a few modem reboots and reboot of my firewall, things seem to be more stable. At this point the connection has been up for ~2 hours without incident. Here’s to hoping we’ll get a few weeks more of uptime 🙂

Published by Dan

I'm a technophile at heart. I love tech and how it can make our lives better. Let's take a little trip into my mind :P

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.