Saturday, December 30, 2017

HowTo Monitor network traffic with vnStat on FreeBSD

HowTo Monitor network traffic with vnStat on FreeBSD


vnStat is a console-based network traffic monitor. It keeps a log of
hourly, daily and monthly network traffic for the selected interface(s).

Bellow youll find the needed steps for its installation and setup on FreeBSD 7.0:
  1. % su
  2. # cd /usr/ports/net/vnstat ; make install clean
  3. # rehash
  4. # ifconfig -a
  5. # vnstat -u -i rl0
  6. # cat /usr/local/share/doc/vnstat/vnstat-cron >> /etc/crontab
On steps 1 to 3 we basically became to the superuser, changed to the vnStats port directory, proceeded by compiling the port and rehashing the shell.

Step 4 purpose is to find out the system network interface(s) in use, which in my case is rl0.

Finally with step 6 weve activated the cron job to feed vnStats database following the ports supplied example.

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 for the selected interface in real time until interrupted:
  • % vnstat -l -i rl0
A nice list of switches can be viewed typing the following command:
  • % vnstat --help
And were done. ;)

Further documentation is available at http://humdi.net/vnstat/.

visit link download