February 9, 2017 at 9:51 pm

Back in December, I bought the Netgear GS108E gigabit managed switch for my flat’s home network (£25 at the time of writing). It lives in a random cupboard along with my servers and internet router, and so far it has served me very well. However, it’s cheap. The web interface certainly shows off it’s cheapness with limited options and information. The switch also provides no SNMP data, which makes monitoring devices and traffic fairly difficult using tools like PRTG or Munin.

I needed a solution to see what devices were absorbing bandwidth in my flat. Having a horrible 3.5mbps internet connection (thanks BT for your insistence to not upgrade infrastructure in a busy growing residential area in a major city), one device can very quickly suck up bandwidth and it’s always difficult to pinpoint who’s guzzling data. I had set up the port connections so so my room was on port 4, wifi was on port 8 and the living room was on port 7, so I had some way of setting QoS port rules and throttle the ports, but I still had no way of easily monitoring the bandwidth consumption. The only bit of information the switch gives me through the GUI is bytes sent and received.

Hmm, I can use that information. PRTG has a sensor API and a python interpreter.

The switch provides a limited amount of port traffic information, but it’s useful enough!

The final result, I wrote a small python script to scrape this information from the switch and create a custom sensor for PRTG. The script authenticates with the web interface and stores the auth cookie for future use (the switch will only allow a certain number of active sessions at one time). The script then loads the port_statistics.html page allowing me to scrape the bytes sent and received. I load the page twice over a recorded time period, do some maths to convert the difference in bytes into a kbps value, and get a nice readable kbps value.

The script also creates a child class of CustomSensorResult (found in the PRTG paepy library). While the class is incredibly useful and sped up my development time by not having to worry about crafting a json response, it was missing the ability to define size and time units as documented in the PRTG API.

An example of the custom sensor information displayed in PRTG

Is it perfect, definitely not. While the script functions, it’s not the most elegantly written thing in the world and can be tidied up heavily. The switch is also not exactly fast to respond to requests, and during testing the script did timeout occasionally or give me really bizarre results, so caching data is certainly needed.  Debugging with PRTG is also a challenge, as I’ve not yet found a way of seeing any python error dumps within the GUI.

I’ve missed building little useful scripts like this. It was good fun to build this and develop my python knowledge (and get out my python book to figure out how to properly work with parent classes), and I certainly need to do this more often.

If you find this script useful with any compatible Netgear ProSafe GS switch, please star the git repository or drop me a tweet @mattyribbo. It’s always nice to know that someone found something I wrote handy.

February 9, 2017 at 9:51 pm | Blog, Programming | No comments

July 6, 2014 at 3:42 pm

Back in October, I was involved with a different kind of charity fundraising event – a 25 hour gaming marathon. The event, ‘Ctrl Alt Donate’, was run by one of my trusted friends Tig to raise money for Bristol Children’s Royal Hospital. Last Friday, £700 worth of toys and games were donated to the Hospital, a fantastic result!

Pile of gifts donated from funds generated by Ctrl Alt Donate

Pile of gifts donated from funds generated by Ctrl Alt Donate

If I rewind the clock days before the event on November 2nd 2013, I can remember me frantically trying to sort out internet access for the event. You’d think getting an internet connection was trivial but there’s a whole load of red tape to jump through with the university’s IT systems, making sure that computers were secure, security considerations, and so on and so on. It also didn’t help that there was an IT maintenance and shutdown weekend. It was looking unlikely to be able to get the provision, but days before the event, a breakthrough occurred, we had internet!

To see the toys finally appearing and being donated on Friday was a nice feeling, and to get a mention from Tig in the press release was really kind of him and I thank him for that.

But then this post on our Facebook group was made by Tig:

We need to do more for the hospital. What we’ve managed to do is huge but I had no idea just how much help they need. The quote that hurt me the most today was “what we do is still seen by many as being a luxury, rather than a key part of a child’s treatment”

What the event did was fantastic and raised a lot of money, there’s no doubt. However after hearing what Tig experienced on Friday, I think that just spurs the next Ctrl Alt Donate to be even bigger! Roll on Saturday 25 October.

July 6, 2014 at 3:42 pm | Blog | No comments

December 11, 2012 at 10:26 pm

In root on my dedi, I’m normally well behaved. Then I slipped up. Though a normal set of circumstances, I end up deleting *everything* in /usr/bin (the unix equivalent of deleting all executables in system32).

All I was doing was upgrading transmission on my server. To make this happen I needed to delete the old bin files off my server. Found them in /usr/bin, but instead of rm transmission-* I ended up doing rm *. Then you wonder why nothing works, oh wait I just deleted every core unix application on my dedicated server of course nothing will work.

So yeah, stupid me. How did I get out of this situation. Thankfully I know people running Arch x64, got in contact with him, he sent me his /usr/bin folder. Then just to make sure, found a script online to reinstall every single package. All 600 of them (apart from arch key manager, that rubbish always hangs when updating).

Disaster averted, lesson learnt, I’m an idiot.

December 11, 2012 at 10:26 pm | Blog | No comments

Next Page »