Raspberry Pi Network Traffic Monitor

I needed a project. It had been a couple weeks, and I was getting antsy to build something. I didn’t necessarily feel like working on my car, smelting cans, or practicing my welding however. I wanted a nerd project. And then I decided it needed to be hard. Maybe not “build yourself a time machine” hard, but more than usual, in order to stretch my brain. I set forth, and began researching. After about a half hour, I found it.

I was going to build an internet speed test box.

Why, do you ask? A very simple answer indeed. Because its cool. With that in my head, I picked up a Raspberry Pi (Really? Are you surprised at this point?), and a tiny case with an LCD touchscreen for it. I then started digging, and found bunches of instructions for different way to accomplish my intended goal.

Sunday came, and my hardware arrived. I promptly imaged my Pi’s memory card, assembled everything, plugged it into my network, and kicked on the power. The pi turned on, but there was no video. A quick check of the instructions indicated I needed to install drivers for this display. I SSH’d in, installed them, and rebooted. Hmm. No video. I was starting to question my choice of screens (I wasn’t wrong to do so). 30 minutes of internet searching, and I found a forum where someone else indicated the same issue, and linked to a different set of drivers, saying they worked with the screen I had. A quick install and reboot…and video! We were off to the races.

Emboldened, I quickly began following the instructions I had found. I set the little box up to query speedtest.net every hour. I then set it up to log the data into a specific file. I tested and checked. Data was not being logged. The query ran perfectly. But the data wasn’t getting saved. Curses. I poured over my code, and after an hour, found two errant brackets that needed removing. I did so, rebooted, and things started working! We were now at the three hour mark…

Next up, I installed another piece of software called Grafana. After 2.5 hours, I finally had it pulling from my SpeedTest log, and generating a graph. While this sounds easy, it was head-smackingly annoying to get working. But once it lit up, baby, I had data! I now had a public local URL that displayed my download, upload, ping, and jitter. Only 5.5 hours in, and we’re making progress!

Next up, I wanted to rotate the screen 180 degrees (cable placement), and set the unit up so that it would boot, load Chrome fullscreen, and display my graphs.

Sadly, the drivers and display that I had used, seemed to gray out the options in the OS, that allowed screen rotation. Another hour of research confirmed that I should have bought the official raspberry pi display, in order to make this work. Oh well. We’re now at 6.5 hours.

Next up, login and load. A quick internet search turned up numerous ways to do this. For the sake of brevity, and saving you. we can add 3.5 hours to the clock. Note that I tried 20 different ways to get this to work. They all failed. I was ready to throw in the towel. I walked away from the project, and sat down to dinner with The Missus. I told her of my frustrations. She encouraged me not to give up, and bless her for it.

After dinner, I decided, one more whack at it. I found a previously untried way of getting the unit to do what I wanted. I re-coded everything, and rebooted. This time, the Pi booted, loaded chrome full screen, and displayed my graphs!

Could it really be true? Had I completed all of my tasks? Solved all of my problems? Well, maybe not that display rotation bit, but who cares! The damned thing was pulling data and showing me what I asked for! I now had a little box that was displaying my internet speed, with up to date information!

And now, here’s where everyone asks, “Isn’t there an app on your phone that can do that, like, whenever you want?”

Yes, to be sure there is, and there are computers that can do it too. But I wanted to automate it. I wanted to build an appliance for it. Sure, I can mix the pancake batter by hand, but I have a stand mixer, and its better. So yes, while I can look this stuff up in a browser, I have an automated box that displays the info I want 24/7. And thats cool.