View Single Post

  #3 (permalink)  
Old 05-07-2008
inetquestion
 
Posts: n/a
Default Re: apache - how to monitor HTTP response codes

Following perl script gives ratio of 404s to all other traffic.




#!/usr/bin/perl

if (my $filename = shift @ARGV) {
open(DATA, "< $filename") || die ("Could not open file: $filename");
*STDIN = *DATA;
}

while (<STDIN>) {
chomp ($_);
if (/.* 404 [0-9]*$/) {
$http404+=1;
}
$entriesTotal+=1;
}

$ratio=$http404*100/$entriesTotal;
printf "%2.6f\n",$ratio;