aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2005-10-03 18:40:59 +0000
committerWayne Davison <wayned@samba.org>2005-10-03 18:40:59 +0000
commitbf485d3d6bc3476610a59ca8c64ed38ac12c2eab (patch)
treea839f92a28c9ec7fc413824bdc58d27becf7ecb7 /support
parente90aab4982c4ce8b3f778cc072d677dd0dbb3dca (diff)
downloadandroid_external_rsync-bf485d3d6bc3476610a59ca8c64ed38ac12c2eab.tar.gz
android_external_rsync-bf485d3d6bc3476610a59ca8c64ed38ac12c2eab.tar.bz2
android_external_rsync-bf485d3d6bc3476610a59ca8c64ed38ac12c2eab.zip
A simple filter script to output messages from a single module.
Diffstat (limited to 'support')
-rwxr-xr-xsupport/logfilter28
1 files changed, 28 insertions, 0 deletions
diff --git a/support/logfilter b/support/logfilter
new file mode 100755
index 00000000..09de9561
--- /dev/null
+++ b/support/logfilter
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+# Output rsyncd log messages for a single module. The log file can be in
+# either syslog format or rsync's own log-file format.
+
+use strict;
+
+my $match = shift;
+die "Usage: logfilter MODULE_NAME [LOGFILE ...]\n" unless defined $match;
+
+my $syslog_prefix = '\w\w\w +\d+ \d\d:\d\d:\d\d \S+ rsyncd';
+my $rsyncd_prefix = '\d\d\d\d/\d\d/\d\d \d\d:\d\d:\d\d ';
+
+my %pids;
+
+while (<>) {
+ my($pid,$msg) = /^(?:$syslog_prefix|$rsyncd_prefix)\[(\d+)\]:? (.*)/o;
+ next unless defined $pid;
+ my($mod_spec) = $msg =~ /^rsync (?:on|to) (\S+) from /;
+ if (defined $mod_spec) {
+ if ($mod_spec =~ /^$match(\/\S*)?$/o) {
+ $pids{$pid} = 1;
+ } else {
+ delete $pids{$pid};
+ }
+ }
+ next unless $pids{$pid};
+ print $_;
+}