Mathematics, philosophy, code, travel and everything in between. More about me…

I write about

English | Czech
Choose your language. I write in English, but I translate many of my articles to Czech as well. Zvolte si jazyk. Píšu anglicky, ale řadu svých článků překládám i do češtiny.

Handy Bandwidth Monitor & a Small Patch For It

bwm-ng is my favorite bandwidth monitor. It can display transfer rates on network interfaces, it doesn’t require superuser privileges, and it can produce output in various formats. So far I have been using its interactive output for live monitoring and CSV output for parsing in scripts. The other week I found a use for its HTML output as well. Unfortunately, the produced code turned out to be rather invalid.

bwm-ng interactive output Interactive output of bwm-ng.

The HTML Patch

HTML tables generated by bwm-ng were missing the </table> closing tags. Additionally, there were a few opening tags instead of closing ones. As a result, the tables were completely broken in web browsers. My tiny five-line patch fixes the invalid HTML and adds a drop of semantics (column headers). The table output by bwm-ng -o html now looks like this:

lo: 0.00 KB/s 0.00 KB/s 0.00 KB/s
eth0: 389.15 KB/s 9.01 KB/s 398.16 KB/s
eth2: 0.00 KB/s 0.00 KB/s 0.00 KB/s
eth1: 0.25 KB/s 1.11 KB/s 1.37 KB/s
total: 388.64 KB/s 10.10 KB/s 398.74 KB/s
March 28, MMIX — Linux.