#!/usr/bin/perl -w

######################################################################
##
## nil
##
## Created 6.11.2001 by Lasse A Vartiainen <lav@iki.fi>
##
## $Modified: Tue Nov  6 18:32:41 2001 by lav $
## @(#)$Id: $
## 
######################################################################

use Graphics::Plotter;

#--- Initialize ---
#--- Begin ---
#--- Main ---
$mons=("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec");
$years=("96|97|98|1999|2000|2001");

$count="01";
foreach $mon (split(/\|/,$mons)) {
    $conv{$mon}=$count;
    $count++;$count=sprintf("%02d",$count);
}

# parse raw log file to get right lines
while(<>) {
    if(/(help stat ($mons) *\d{2,4})/) {
	$com="$1";
	$com=~ s/help stat (\w\w\w) 9(\d)/help stat $1 199$2/;
	$com=~ s/help stat (\w+) (\d+)/$2-$conv{$1}/;
    }
    if(/([\.\_\d]+)\s*seconds/) {
	$sec="$1";
	$sec =~ s/[\_]//g;
    }
    if(/([\d\.\_]+)\s*player\-hours/) {
	$hour="$1";
	$hour =~ s/[\_]//g;
    }
    if(/max connected|average|packets|on that topic/) {
	undef $com;undef $hour;undef $sec;
    }
    if(defined($com)&&defined($sec)&&defined($hour)) {
	#print sprintf("$com -> $sec -> $hour\t= %03.01f\n",(3600*$hour/$sec));
	$y=(3600*$hour/$sec);
	$x=$com;$x=~ s/-//;
	print "$x,$y\n";
	
    }
    
}


exit;


# tintinrc file to get the stats


$count=0;
foreach $year (split(/\|/,$years)) {
    foreach $mon (split(/\|/,$mons)) {
	$count++;
	print "#var tmp$count help stat $mon $year\n";
    }
}
print "#alias {tmpdo} {echo Going to call: \${%%1};#sleep 4; \${%%1};look}\n";
print "#alias {tmpget} {inc tmpcount;tmpdo tmp\$tmpcount}\n";

exit;
#--- Functions ---



## Local Variables:
## mode: perl
## make-backup-files: t
## End:
