Leon Ho

The water is calm.

Example on Graphing Awstats with Ruby and Gruff

with one comment

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:

Lifehack.org 2006-Dec Visits by Browsers Graph

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()

Written by Leon

December 30th, 2006 at 5:37 am

Posted in Programming

One Response to 'Example on Graphing Awstats with Ruby and Gruff'

Subscribe to comments with RSS or TrackBack to 'Example on Graphing Awstats with Ruby and Gruff'.

  1. hxi5lzkm4i3fskar

    Clare Lindsey

    12 Nov 08 at 11:15 pm

Leave a Reply