sub init { my ($self) = shift; $self->setWanted($self->{args}->{docroot}."/logs/access.log*"); } sub run { my ($self) = shift; my $args = $self->{args}; # default method strings my $post_method = "POST"; my $get_method = "GET .*=(htt|ft|ph)p(:|%3[aA])(/|%2[fF])"; my $method_string = '\"('.$post_method.' |'.$get_method.')'; # redefine method string if it is given from the client if ( (defined $args->{method}) && ($#{$args->{method}} + 1 == 1) ) { if (grep lc($_) eq "post", @{$args->{method}}) { $method_string = '\"'.$post_method; } elsif (grep lc($_) eq "get", @{$args->{method}}) { $method_string = '\"('.$get_method.')'; } } # we fork several processes here to have the results faster. somehow grep takes a looooooooooooooong time to have a look over the logfiles. FIXME? foreach (keys %{$self->{files}}) { my $pid = fork(); # parent if ($pid) { $result->{$pid} = (); # child } elsif ($pid == 0) { my $cmd = '/bin/zgrep -E " '.$method_string.'.* HTTP/[0-9]\.[0-9]\" [23][0-9]{2}" '.$_." 2>/dev/null"; print `$cmd`; exit(0); } else { main::error("Could not fork: $!"); exit(1); } } foreach (keys %$result) { waitpid($_, 0); } return; }