#!/afs/athena/contrib/perl/p

%month = ("Jan", 0,
	  "Feb", 31,
	  "Mar", 59,
	  "Apr", 90,
	  "May", 120,
	  "Jun", 151,
	  "Jul", 181,
	  "Aug", 212,
	  "Sep", 243,
	  "Oct", 273,
	  "Nov", 304,
	  "Dec", 334);

while(<>){
    ($mon, $day, $time, $g, $g, $machine,
     $method, $path, $version) = split;
#    print("$mon, $day of the year $year\n");
    ($hour, $minute, $sec) = split(/:/, $time);
    $date = $month{$mon}+$day;
    $host{$machine}++;
    (@dms) = split(/\./, $machine);
    if($dms[$#dms] == 0) {
	print("$dms[$#dms-1].$dms[$#dms], ") unless $domain2{$dms[$#dms-1].$dms[$#dms]};
	$domain2{$dms[$#dms-1].$dms[$#dms]}++;
	$domain{$dms[$#dms]}++;
}
    $hrequest[$hour]++;
    $request[$date]++;
    $path =~ s/\?.*//;
    $doc{$path}++;
    if($date != $odate){
#	$ticks = "-" x ($request[$odate]/10);
#	print("$mon $day>$ticks $request[$odate]\n");
	$weektot += $request[$odate];
	$week++;
	if($week == 7){
	    $ticks = "-" x ($weektot/600);
	    print("$mon $day>$ticks $weektot\n");
	    $week = 0; $weektot = 0;
	}
#	print("$date\n");
    }
    $odate = $date;
}

for $h (0..24) {
    $ticks = "-" x ($hrequest[$h]/1000);
    print("$h >$ticks $hrequest[$h]\n");
}

@dox = sort bydoc keys %doc;
for $top (0..150) {
    print("$top-->$dox[$top] ($doc{$dox[$top]})\n");
}

@doms = sort bydms keys %host;
for $top (0..150){
    print("$top-->$doms[$top] ($host{$doms[$top]})\n");
}

for $domain (keys %domain){
    print("Domain: $domain\n");
}

sub bydms { $host{$b}  <=> $host{$a} }
sub bydoc { $doc{$b} <=> $doc{$a} }
