en cz  

Version 1.1 released.


Version 1.0 released.

Sometimes it is good to know, how the network is used, how many bytes were received and how many bytes were sent. Therefore, here is Network Traffic Analyzer, which can create simple network usage statistics.

Such statistics can tell you, how good your network connection really is (who cares about what the Internet provider says ;-)), when was the network down, which time is the best time for downloading large packages of data etc. etc. Or with this software you can just better imagine, how many traffic can your home computer generate.

This software runs well on Linux (version 2.2 or higher), but maybe it can run on other platforms too. Please let me know if you are more experienced with it. This software is a package of a few simple Perl scripts which generate static HTML files and some pictures using the GD library.

I was searching the Internet for a simple tool to know the network traffic, but nothing was simple enough. The best stats were generated by MRTG, but this software wanted SNMP running, which was not my wish. So I tried to create a really simple script, which can not do as many things as MRTG does, but in the most simpliest way it generates some traffic stats.

Main advantages of NTA:

  • very low disk space usage
  • just Perl language and GD library needed, nothing else, no daemons etc.
  • no root account needed
  • big (and commented) configuration file
  • simplicity in most everywhere

This software can be distributed and modified freely under the terms of GPL license.

Software requirements (most of Linux distributions contain proper packages, so probably you don't need to install everything manually):

Installation is simple, just unpack the downloaded file - one directory will be created. You can move this directory on your system whenever you want to (of course it may depend on your permissions). It is strongly recommended not to move any files from this directory away to another locations. In an example bellow the final destination directory is /usr/local/nta:

# tar xzf nta-x.y.tar.gz
# mv nta-x.y /usr/local/nta/

Before the program is being executed for the first time, you should edit the config.pl file - the only configuration file for this simple software. Use your favorite text editor for this. First of all you have to define network devices which should the software look at (you should be able to list all of available devices via the ifconfig command). You can assign names to any device:

   'eth0' => 'Main Internet connection',
   'eth1' => 'Local subnet',
   'lo' => 'Loopback device'

Usually your home computer has only one network device, so it is O.K. to have just one device configured. The rest of the config.pl file is a big %config variable. You don't need to see all of it right now, but please take a good care about line output_dir, where you must specify an existing directory with write permissions. You can edit the other lines too, they are well commented, so it should not be a problem for anybody to change configuration of whatever he wants.

The main script nta.pl needs to be executed every 5 minutes to create correct stats. Use cron daemon to do it, for example via the crontab -e command. I strongly recommend you not to do it as root, use a non-privileged account for this action. Put this line to the crontab file:

*/5 * * * * (cd /full/path/to/nta/ && ./nta.pl)

On my very old computer (Pentium 166 MHz MMX, 192M RAM, with a really lot of processes running) I've tried to create full stats of last 24 hours, 7 days, 4 weeks and 6 months. The script was running for about 9 seconds.

It is also recommended to check if everything works fine before crontab editing. Just step into the nta directory and run the nta script manually:

$ cd /full/path/to/nta/
$ ./nta.pl

If you can't see any output, everything works fine. Otherways you should get an error message. Check the output in the output directory specified in config.pl file.

The software stores its data in a few files. You should have about 20kB free disk space per graph per network device.

Select version:

Direct link:

You can see a demo stats of a computer acting as a masquerading firewall machine. The are two network devices in it - one being connected to the internet (via an ISP) and second being connected to a switch with other workstations connected to it.

Demo map

Click this link to view full stats demo in a new browser window.

There are no known bugs at this moment. In case you find some, please let me know at mccohy@kyberdigi.cz.


Version 1.1

  • added output_prefix: user can define if he wants fully detailed stats (count in bytes) or nice values (KB, MB, GB etc.)


Version 1.0

  • initial version

Antoine Megans reported that Linux kernel version 2.0 does not provide special file /proc/net/dev, where NTA reads tha data about transferred bytes. There is no known workaround, so please upgrade.

The program reads the /proc/net/dev file. If you want to check for another data, you can create your own file (you can let it be created periodically), but it has to have the same format as the original /proc/net/dev. The most important is device identificator (string before first colon) and then the first and ninth numerical value (bytes in and bytes out). Other numerical values are being ignored and can be set to zero. Edit the config.pl file, search for the proc_netdev keyword and point it to your own file.