Tuesday, May 28, 2013

Network traffic & bandwidth monitoring with darkstat on FreeBSD

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.
Install darkstat:
# cd /usr/ports/net-mgmt/darkstat
# make config-recursive
# make install clean
# rehash

To enable darkstat at boot time add the following lines to /etc/rc.conf:
# vi /etc/rc.conf
darkstat_enable="YES"
darkstat_interface="em0"

Note: change the darkstat_interface to reflect your network interface (mine is em0).

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=""

Start darkstat:
# /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.

Reference:
http://linux-bsd-sharing.blogspot.ca/2008/10/howto-network-traffic-bandwidth.html

No comments: