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.
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:
| Interface | Rx | Tx | Total |
|---|---|---|---|
| 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 |
Speak your mind
Allowed HTML tags are a, blockquote, em, code, li, ol, p, pre, strong, ul. Links to other comments in the form “[IV]” or “[4]” are detected automatically.