Network monitoring tool

March 5th, 2009

Today I wanted to monitor the network usage on my Linux box. Compared to what most bandwidth monitoring tools do I wanted to monitor the bandwidth per process - usually most Linux tools tools just monitor the bandwidth per interface. And I realized that is actually a very rare thing on a Linux system to monitor the network per process.

But suddenly I remembered an article I read some time ago about a network monitoring tool that calculated the bandwidth usage per process. It looked something like top but for network usage and per process. It wasn't however very easy to find again and it took a rather long time before I eventually found it again. So for future references I decided to write a blog entry about it.

The tool is called NetHogs and is available for installation in any ordinary Linux system by default.

Hint: Press 'm' to toggle the unit.

Stupid thieves?

June 11th, 2008

I put my bicycle on a rather public place over the day yesterday. I was a bit surprised to see that one of my locks was missing when I returned. Luckily I had two locks on my bike, one wire lock used to fasten the bike against some solid object and one ordinary back wheel lock. The wire lock was cut off and was laying on the ground next to the bike. I would love to have seen the thieves face when the realized that there where two locks after cutting off the first :)

The bike, except for the lock, was unharmed with no damages and still works fine. Now I just have to buy a new lock...

Subversion version conflict

March 2nd, 2008

I reinstalled my server this weekend. I felt like my old 20 GB Maxtor hard drive had done it job and it was time for an upgrade. The label said it was constructed in October 2001 so that is at least seven and a half years. I purchased two new 160 GB hard drives and configured software RAID1 (mirror). It works like a charm, and now my data is more safe than ever ! ... at least that is what I try to tell myself.

However, I previously ran Debian unstable and now I figured it would be more reasonable to run Debian stable (etch) instead. This caused some problems with subversion and apache. I run mod_dav_svn in apache with SSL for secure data transfer for all my subversion access. And since Debian stable has a lower version of subversion than unstable my subversion repositories was not fully compatible.

The apache log threw out a lot of errors for each commit:
[Sat Mar 01 23:39:22 2008] [error] [client 192.168.1.109] Could not create activity /svn/(the_repo)/!svn/act/8b8e0c43-322c-470b-9c65-25a848f3db49. [500, #0]
[Sat Mar 01 23:39:22 2008] [error] [client 192.168.1.109] could not close dbm files. [500, #89026]
[Sat Mar 01 23:39:22 2008] [error] [client 192.168.1.109] Can't close activity db: Error string not specified yet [500, #89026]

And then similar errors when I removed the repo/dav directory (It thought it would be recreated):

[Sun Mar 02 18:31:27 2008] [error] [client 192.168.1.109] Could not create activity /svn/(the_repo)/!svn/act/40d2c87d-b10e-43e0-ba33-51990522c17d. [500, #0]
[Sun Mar 02 18:31:27 2008] [error] [client 192.168.1.109] could not open dbm files. [500, #120002]
[Sun Mar 02 18:31:27 2008] [error] [client 192.168.1.109] Can't open activity db: APR does not understand this error code [500, #120002]

It took me a while to figure out that the dav directory must exist inside the repository but that the activity file should be removed. So the solution was to simply only remove the activity file and now it works again.

Yeah, and as you might imagine... one of my hard drives died the other day :( I guess that is what motivated the upgrade. Even if I had thought about the upgrade for the server for a long time I never took myself the time to make the upgrade before. A hard drive crash every now and then is probably good for data security :)

Laptop update

January 27th, 2008

I did a fresh reinstall of Ubuntu on my laptop today, now it runs Gnome after 2-3 years of reliable KDE usage :) If I remember correctly I installed an early release of Breezy Badger on it because the kernel in Hoary Hedgehog didn't have good support for my S-ATA controller. It has worked like a charm ever since, so it's not that it didn't work any more it was more like a fun thing to see how the installer behaves now. In addition, I'm running KDE 4 on my desktop at home now so I want at least one computer with Gnome on it.

So, for the real purpose of this post... It does not seems to be so easy to customize the locale settings in Gnome as it could be. I really want to use English as the language on the computer but having dates etc in Swedish. Unfortunately this has to be configure in a text file in the home directory so its not that easy for newcomers. Anyway, adding the following lines to ~/.gnomerc solves the problem.


export LC_TIME=sv_SE.UTF-8
export LC_CTYPE=sv_SE.UTF-8
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8

New location

September 1st, 2007

New location as in new home. Yes, really, I have moved to a new appartment in Gothenburg. Now I live on the other side of the river. What about that? ;)

Pegasos, X and Ubuntu Feisty

April 22nd, 2007

Well, yet again X do not work on the Pegasos due to pciscan issues. Unmounting /sys is a simple, but ugly, workaround. An other but still ugly solution is to recompile xorg and force it to use /proc for pciscan, which I did.

The repository is the same as for edgy but edgy replaced with feisty. Note the trailing / after binary is IMPORTANT.



Add that line to your /etc/apt/sources.list file and make a system update and X should start again (that is apt-get update and then apt-get dist-upgrade).

It is also good to install my public key so the packages can be verified for correctness.

Install it by running:
wget -O- http://kozz.org/files/keys/kozz-pubkey.gpg | sudo apt-key add -


Sources can be downloaded with:

Protection against ssh bruteforce attacks

April 15th, 2007

Everyone that has set up a ssh server on a computer connected to the Internet has probably their log full of random attempts from foreign hosts with failed login attempts. Even if the probability that they will succeed is close to zero it would feel to good to have an automated way to block hosts that have failed a few times to the ssh server.

Personally for my own computer at home I never felt that it was such a big problem that I took myself time to find a solution for it. But when we had a LOT of bruteforce attacks to the ssh server at work it felt worth doing something about the potential security hole. I googled it for a while and finally found DenyHosts (http://denyhosts.sourceforge.net/), a very simple program that parses /var/log/auth.log in a Debian system or /var/log/messages in a Gentoo system and adds rules to /etc/hosts.deny when a host has too many failed attepts to login to the server. Really simple but still so useful.

DenyHosts is available in the package system for both Debian and Gentoo, both works fine. Actually, I have installed DenyHosts on more or less every computer I have now :). Every now and then I get mail from the server saying it has blocked yet another host from log in. Have so far 16 hosts blocked in about just 2-3 days. Why don't you give it a try?

Diff is a wonderful tool

November 7th, 2006

We all just love diff, don't we?

The following line just made my day :)


diff -qr PNphpBB2.old PNphpBB2 | grep "^Only in" | grep -v "\.svn"


It list all removed/added files/folders between two directories. Simple, but still so powerful.

Tip of the day

July 13th, 2006

As Firefox 2 Beta is hot news right now I wanted to make a note about the best extension to Firefox 1.0 - 1.5 there is imho - Tab Mix Plus. I wonder how anyone can survive without it :)

Pegasos and Ubuntu Dapper

April 26th, 2006

I have though about writing about Pegasos and Ubuntu Dapper for a while... but nothing happened :)

Today someone asked me about how to use Ubuntu Dapper on the Pegasos so there is probably need for some information about it.

I wrote a post about it over at PPCZone, http://www.ppczone.org/forums/viewtopic.php?p=2761#2761

Hope it works, works for me :)