NetHogs: Bandwidth Stats by Process

Have you ever been messing around on your Ubuntu box, only to notice some sluggishness or some suspicious spikes in your internet connection, and wondered, “What the hell is using up all that bandwidth?” Or worse, “Have I been hacked?” If so, then NetHogs might be the program for you.

NetHogs

NetHogs is a lightweight Linux terminal-based tool that monitors bandwidth usage, then groups it by process, so you can see which PIDs are using the most bandwidth, and if necessary, kill them with System Monitor.

To install NetHogs on Ubuntu (tested on 9.10 Karmic), you can either use Synaptic or simply apt-get, like so:

sudo apt-get install nethogs

To run NetHogs, simply feed it the internet connection you wish to examine, and sit back.

sudo nethogs eth0

For more information and the full list of options, visit the NetHogs man page.

man nethogs

The Principia Process

Here’s the remastered final version of Andrew McCombs’ classic documentary “The Principia Process,” which chronicles the spring 2002 launch season, and the beginnings of Team Principia. Watch and enjoy.

Bootsplash Resolution in Kubuntu

One of the annoying little setup items on my list of things to do every time I reinstall Kubuntu is changing the bootsplash screen resolution from 800×600 to something more appropriate for my monitor, specifically, 1280×1024. Here’s how it’s done:

sudo nano /etc/usplash.conf

The file should be altered to read:

# Usplash configuration file
# These parameters will only apply after running update-initramfs.

xres=1280
yres=1024

The final step is to update initramfs, the initial RAM disk used by the kernel when Linux first boots up:

sudo update-initramfs -u

If you skip the last step, you will probably only see your new usplash resolution during shutdown and not when your computer boots up.

That’s it!

Python Web Search Agent

So there was this web page, nothing more than a text file in fact, which I was compelled to check regularly. I had ordered something online from a company whose web-store design was still in the dark ages, and their “method” of letting customers know whether or not their products had shipped was to periodically update a web-viewable text file with a public list of all the order numbers that had recently shipped. Very private and secure, I know.

No, no, they couldn’t possibly email this information to you — you had to check the page manually. And if your products were backordered, as mine were, you’d be checking often.

Well, that’s just stupid, I thought, and since I had a computer sitting right in front of me, I thought it might be a good idea to automate the process.

So I cobbled together a little Python script on my Ubuntu box, which uses the pycURL interface to grab the URL in question, parse it, search it for my order number, and then fire me off an email (using sendmail) if and when it finds anything.

I automated the script to run hourly using cron, like so:

crontab -e

and then included the following line in my crontab file:

# m h  dom mon dow   command
7 * * * * /path/to/searchagent.py

Seven minutes after the hour (for luck), every hour, every day.

On the hunch that this script might be useful to somebody else, I decided to post it here. Fair warning to all: this is a huge hack, and I’m sure it needs work. Also, there’s probably a better method that I’ve completely overlooked. Comments, corrections, and suggestions are welcome, as always.

Here’s the script:

Read more »