Earlier this year, I switched from Spectrum internet to ATT Fiber. I was hestiant to make the switch due to ATT’s reputation in my area, but I’d heard that the fiber service was much better than their older internet offerings, so I decided to give it a shot. For the first couple months, everything was wonderful. The speeds were great - 1000mbps up and down - and it seemed rock solid. But, then I started noticing apps disconnecting on my computer. Icons of programs that were connected to the internet would grey out (lose connectivity) for a second, then come back. It was usually fast - off and back on within seconds - but it began to happen more frequently. Songs I’d be streaming would grey out, then come back, almost flickering sometimes from the disconnects. While it wasn’t impacting my work directly (yet), it was annoying, so I decided I needed to start logging the outages - both to see if there was a pattern and to have some hard data to give to the ISP if it continued.
Of course, I could manually log each outage with pen and paper, but I’m a programmer, so of course I decided to automate it. I debated for a bit on what language to use. Any number of them would have worked, but I’d been learning Go this year and this gave me a nice small project to work on. That decided, I just had to figure out the best way to detect that the internet was down. Do I simply ping a server? Do a HTTP request periodically with a short timeout? Check packets at a lower level?
For this first attempt, I decided to just do a simple request to google.com
every 10 seconds and write the results to a log file. It was a very simple program that just
used the standard library for part of the process. I added custom flags so that I could change the interval, the log file, and whether to print the results to STDOUT
or not.
After that, I made a simple infinite for
loop that would check the connection and log the status based on the results of the request.
The log file was very simple, but got across the information I was trying to convey to the ISP. It was just a date and time and a status message:
The full implementation is only 69 lines of code, but it’s been very helpful seeing the amount of disconnects happening.