scripts/mir-setup: new scripts:
[mir.git] / scripts / mir-setup / strip-ips-from-apache-error-log
1 #!/usr/bin/perl -w    
2
3 # From http://docs.indymedia.org/view/Sysadmin/ApacheLogsWithoutIPs
4 # 10 April 2005
5
6 # Cleaned up -zak 2005-04-10
7
8 use strict;
9
10 # check we're called with exactly one argument, our output file name    
11 if ( @ARGV != 1 ) {die "I need exactly one argument <output file>";}
12
13 my $out=$ARGV[0];
14
15 open (OUT,">> $out") or die "Failed to open $out for writing: $! \n";
16
17 # turn on buffer autoflush so tail -f error.log works    
18 # (rather than waiting till file handle is closed    
19 my $outf = select(OUT);
20 $|=1;
21 select($outf);
22
23
24 # Strip IP's and replace with 0.0.0.0    
25 while (<STDIN>) {
26     s/\[client.*\]/\[client 0.0.0.0\]/;
27     print OUT;
28 }
29 close (OUT);