Example on Graphing Awstats with Ruby and Gruff
I spent a moment today testing the Gruff Graphing Library for Ruby to process Awstats data. With the library to handle the graph generated and powerful language, most of the lines of code went to parsing the dataset.
Awstats is a great web statistics software with useful data, and it is even better with graphs like this:
By the way, visits by Firefox has exceeded Internet Explorer this month! It’s the first time at lifehack.org.
Example of the awstats dataset
Because the whole file (i.e. awstats122006.www.lifehack.org.txt) is huge, I have stripped the browser section into a separate file. Here is an example of its format.
Source Code
The code is a linear script and I has not tried to polish it, but it serves to show its functionality. The code does the following things:
- Use hash to store browsers hits
- Open file and process line by line
- Use case statements to group browsers hits
- Create an object of Gruff and pass the hash to g.data()


