The ifusage project. This started because I wanted to summary statistics of my router's outgoing interface. An alternative was the mrtg project, but my log files were already in a different format. In fact, they were the parsed output of ifconfig.

theory of operation

cronjob running every 5 minutes appends the parsed output of ifconfig into a log file and runs the ifusage generator program. The gd library is used for graphing. A sample output set can be found here.

log file format

The log file is an >> appended file of parsed ifconfig output. The original parser can be found here. I've modified it a bit to correct a small parameter passing oversight, and to output only the values I wanted, but the parser really is overkill. It's a simple job to write another parser just for the bits I want, but that one was available, and did the job.

Each line of the log file has 3 elements:
time (32 bit integer), rx bytes, tx bytes

(Note that rx bytes and tx bytes are cumulative totals. 32 bit integer rollover wraparound is supported, but rx bytes and tx bytes may be 64 bit integers. None of these numbers should be negative.)

The ifusage generator program reads in the log file and generates a web page with supporting graphics.

ifusage command line arguments

2 only so far, and it has to be in order:

  1. the log file (or expects input from stdin if no log file is given)
  2. the output path (or defaults to the current working directly './' if no output path is given)

output files generated

the ifusage program generates an index.html file with references to {minutes|hours|days|weeks|months}.png for the graphs, and {minutes|hours|days|weeks|months}_im.html for separated html files with imagemaps to provide detailed information on each graph.

project files

This project is at the usable stage. It may work for you. I run a slackware 9.1 system and it's fine for me (the makefile given is for my system). With makefile tweaks to library and include file paths, it should run on any other linux system (I've compiled on debian too) with the gd library installed. Original development was with MSVC 6, so it compiles on win32 too, but again, the gd library needs to be available.

the files

if_usage.cpp - main generator program

int64type.h int64type.cpp - support files for 64 bit integers

stats.h - c++ template class for statistics support

makefile - my make file that works for slackware 9.1

sample log file - my modified ifconfig parser (perl program)

ifusage_1.0_i386.deb (i386 binary-only) debian package

example shell script to run the ifusage program set