scripts/mir-setup: new scripts:
[mir.git] / scripts / mir-setup / strip-ips-from-apache-error-log
diff --git a/scripts/mir-setup/strip-ips-from-apache-error-log b/scripts/mir-setup/strip-ips-from-apache-error-log
new file mode 100755 (executable)
index 0000000..f605a40
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w    
+
+# From http://docs.indymedia.org/view/Sysadmin/ApacheLogsWithoutIPs
+# 10 April 2005
+
+# Cleaned up -zak 2005-04-10
+
+use strict;
+
+# check we're called with exactly one argument, our output file name    
+if ( @ARGV != 1 ) {die "I need exactly one argument <output file>";}
+
+my $out=$ARGV[0];
+
+open (OUT,">> $out") or die "Failed to open $out for writing: $! \n";
+
+# turn on buffer autoflush so tail -f error.log works    
+# (rather than waiting till file handle is closed    
+my $outf = select(OUT);
+$|=1;
+select($outf);
+
+
+# Strip IP's and replace with 0.0.0.0    
+while (<STDIN>) {
+    s/\[client.*\]/\[client 0.0.0.0\]/;
+    print OUT;
+}
+close (OUT);