Monday, October 20, 2008

HowTo: Network traffic & bandwidth monitoring with darkstat on FreeBSD

My old Celeron 266 Mhz runs a couple of network related services, namely MLDonkey and FTP.

With the goal of monitoring network and bandwidth traffic I used vnStat. vnStat is small and efficent console based application however I wanted something that could serve the statistic over HTTP and this is where darkstat fills the bill.

Darstat captures network traffic, calculates statistics about usage, and serves reports over HTTP.

Darstat provides the following features:
  • Traffic graphs, reports per host, shows ports for each host.
  • Embedded web-server with deflate compression.
  • Asynchronous reverse DNS resolution using a child process.
  • Small. Portable. Single-threaded. Efficient. Uncomplicated.
Follow the bellow steps to install darkstat on FreeBSD 7.0:
  • % su
  • # cd /usr/ports/net-mgmt/darkstat
  • # make install clean
  • # rehash
To enable darkstat at boot time add the following lines to /etc/rc.conf:
darkstat_enable="YES"
darkstat_interface="rl0"
Change the darkstat_interface to reflect your network interface (mine is rl0).

Bellow you'll find a set of optional configurations flags that can be added to /etc/rc.conf:
darkstat_dir="/var/run/darkstat"
darkstat_pidname="darkstat.pid"
darkstat_dropuser="nobody"
darkstat_flags=""
Now that we have darkstat installed and configured let's start it:
  • # /usr/local/etc/rc.d/darkstat start
To check darkstat daemon status:
  • # /usr/local/etc/rc.d/darkstat status
By default darkstat serves graphs to http://localhost:667, so fire up your browser and point to the location. If you are planning (like me) on accessing to the graphs for another location add port 667 to your router Port Forwarding settings.

Hope you enjoy darkstat. I find it extremely useful and refreshing.

Resources:
http://dmr.ath.cx/net/darkstat/
man darkstat

No comments: