So over the last few months my internet service with Comcast has been less than stellar. My connection would drop out at random times throughout the day, on some days I wouldn’t stay connected for more than 20 or so minutes at a time. At first, I was hoping that it was a random issue and it would go away on its own (wishful thinking, right?). Well, it didn’t. I contacted customer support and they told me that my modem levels were high, but they couldn’t do anything about it remotely and that a tech would have to come out. I find this weird because last year I was having a similar issue and the rep was able to resolve my problems remotely. Anyway, I scheduled an appointment and a tech came out and took a look at my equipment and was unable to find anything wrong. The only thing he said may be causing an issue was that I’d put in a splitter that wasn’t “one of theirs”. After he left i checked mine against his, and the frequency ranges on both the splitters was identical.. so.. whatever. Needless to say, my issue was not resolved. So a few days later when the issue cropped up again, I scheduled another appointment for a tech to come out. This time the guy busted his butt (much respect!) and ran brand new cable from the pole to the house, cleaned up the rats nest of cabling the initial installers left behind when we first got service and even put in an outdoor service box.
This was a few weeks ago, and up until the last few days the problem seemed to have been resolved. But then it started again. And I was about to schedule another appointment, but I’d gotten my bill that morning. Come to find out they charge you to come out and fix the issues they can’t seem to keep resolved. $30 bucks a pop! Needless to say, before I give them another excuse to gouge me for more money, I figure some internet noise is required.
I’ve decided to write a small python script that scrapes the uptime from my modem (an Arris Surfboard SB6141), and if it’s less than 5 minutes, pop a tweet at Comcast letting them know. Feel free to use this or improve upon it!
The script runs from an Ubuntu server every 5 minutes via crobjob.
Dependencies (installed with pip)
- requests
- datetime
- BeautifulSoup
- dateparser
- tweepy
Script
import requests import datetime from bs4 import BeautifulSoup import dateparser import tweepy CONSUMER_KEY='[REPLACE ME]' CONSUMER_SECRET='[REPLACE ME]' ACCESS_KEY='[REPLACE ME]' ACCESS_SECRET='[REPLACE ME]' auth=tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY,ACCESS_SECRET) api=tweepy.API(auth) page = requests.get("http://[REPLACE WITH INTERNAL IP OF MODEM]/indexData.htm") soup = BeautifulSoup(page.content, 'html.parser') modeminfo = list(soup.find_all('table')[1].children) uptime = list(modeminfo[1].children)[5] timestr = list(uptime.children)[3].get_text() timespan = dateparser.parse(timestr) currenttime = datetime.datetime.now() span = currenttime - timespan minutes = span.seconds/60 days = span.days status = "" if minutes <= 5 and days == 0: status="Hey @Comcast, my modem just rebooted at " + timespan.strftime("%Y-%m-%d %H:%M:%S") api.update_status(status) else: print "Modem has been up since " + timespan.strftime("%Y-%m-%d %H:%M:%S")