From: Wayne Davison Date: Mon, 3 Oct 2005 18:40:59 +0000 (+0000) Subject: A simple filter script to output messages from a single module. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/bf485d3d6bc3476610a59ca8c64ed38ac12c2eab A simple filter script to output messages from a single module. --- 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 $_; +}