Friday, June 17, 2011

Monitor Traffic Usage Using darkstat

Sometimes, we wanted to monitor our network traffic usage daily or even hourly. There are a lot of tools out there and most of them are based on RRD Tools, which is a great application, but it adds more maintenance as there are more packages to install in order to satisfy the requirements.

What i need is a simple application that shows the traffic usage and i need it displayed on a web based interface so i can monitor it anywhere as long as there's a browser and Internet connection without having to login to that machine and following the log files.

I searched a bit and doing trial and error and finally i made up my mind that i picked darkstat. It's simple, no hassle, and it solves my needs.

INSTALLATION
  1. Download the latest version from their official website (3.0.714 at this moment)
  2. Download the SlackBuild script for darkstat
  3. Extract the SlackBuild script
  4. Edit the VERSION line to match the version you downloaded
  5. Switch to root and execute the SlackBuild script. The final package will be placed on /tmp (by default)
  6. Install the package using installpkg
  7. Finish the installation procedureYahoo

CONFIGURATION
There's not much to configure actually. You can start darkstat by issuing darkstat -i ethX (replace X with your ethernet device)

By default, it will bind to port 667, so you can have a look on the stats by browsing to http://youripaddress:667

If you want to bind it to other port, just add -p portnumber parameter, for example darkstat -i eth0 -p 4444

There are some filtering in darkstat, but in most cases, you want to have a look on all traffic, so we skip this step. If you need more information about filtering the output, check the man page for darkstat.

This application doesn't add itself to the crontab or even at startup files, so if you wanted to run this application everytime your machine is booted, you can add this line to /etc/rc.d/rc.local:
# Start DarkStat Monitoring Tool
/usr/sbin/darkstat -i eth0 -p 4444
That's it!!! So simple and you can even finish this tutorial in less than 5 minutes Russian Emot