Displaying bandwidth usage with Go

Programming Snapshot – Go Bandwidth Display

© Lead Image © xyzproject, 123RF.com

© Lead Image © xyzproject, 123RF.com

Article from Issue 284/2024
Author(s):

A Go program running on a Raspberry Pi grabs metrics from a pfSense firewall and displays them on a miniature display to help Mike Schilli keep an eye on his Internet connection's bandwidth usage.

Measuring the active throughput of an Internet connection is not entirely trivial, because nobody wants the measuring probe to slow down the data traffic. However, the router at the Internet access point has to view and forward all of the packets anyway, so why not let it also count them and provide the results via an API?

At home, I use a pfSense firewall on a fanless mini PC as my main router, which also runs some apps with access to the packet throughput (Figure 1). One of these apps is ntopng, which shows you in a browser which LAN client is currently communicating with which server on the Internet – among other things. Ntopng also offers an API with token authentication, which returns counters for the bits transferred in both directions.

I didn't want to rely on the tool just running on demand in a web browser, but on a separate Raspberry Pi, which I equipped with a $50 color display for continuous viewing pleasure (Figure 2). When I'm sitting at my desk, I can see out of the corner of my eye the number of bits zooming in or out every second. As a side effect, I can also see at a glance what's going on when someone shouts "the Internet is down again" from the other room.

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Google Chart

    The Google Chart API lets you draw custom graphs, charts, maps, and barcodes through a simple web interface.

  • Chip Shot

    We all know that the Fyne framework for Go can be used to create GUIs for the desktop, but you can also write games with it. Mike Schilli takes on a classic from the soccer field.

  • Hard Disk Dashboard

    To keep an eye on the remaining disk space during storage-intensive operations, you can check out this speedometer/odometer written in Go.

  • Straight to the Point

    With the Fyne framework, Go offers an easy-to-use graphical interface for all popular platforms. As a sample application, Mike uses an algorithm to draw arrows onto images.

  • Perl: Google Chart Instructions

    A CPAN module passes drawing instructions in object-oriented Perl to Google Chart, which draws visually attractive diagrams.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News