Wednesday, September 17, 2008

HowTo: Monitor network traffic with vnStat on Gentoo

Following an install of vnStat on FreeBSD I took the opportunity and had it installed also in my 1.3 Ghz Pentium-M laptop running Gentoo Hardened. This laptop serves my p2p needs namely runs MLDonkey, SSH, Samba and NFS making it the perfect machine to monitor network traffic on.

Let's proceed with the steps needed to install vnStat from portage:
  • $ su
  • # emerge vnstat
Now let's find out the system network interface(s) in use, which in my case is eth0.
  • # ifconfig -a
To create vnStat's database we run:
  • # vnstat -u -i eth0
Finally, to activate the cron job to feed vnStat's database uncomment lines 7 through 9 on /etc/cron.hourly/vnstat as instructed by the file itself.

A nice list of switches can be viewed typing the following command:
  • $ vnstat --help
To display the default statistics:
  • $ vnstat
To display daily traffic statistics use the -d switch:
  • $ vnstat -d
Monthly traffic statistics can be viewed with the -m switch:
  • $ vnstat -m
To display current transfer rate in real time until interrupted:
  • $ vnstat -l
Further info on vnStat can be obtained in the project's homepage and in my previous post regarding vnStat on FreeBSD.

No comments: