X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/c78779cce3c557109f70710ea0455ba658895edd..bd685982389b78a158921b7839bdeca501338d19:/support/rsyncstats diff --git a/support/rsyncstats b/support/rsyncstats index f172f60e..e770b9dd 100755 --- a/support/rsyncstats +++ b/support/rsyncstats @@ -1,16 +1,18 @@ #!/usr/bin/perl # # This script parses the default logfile format produced by rsync when running -# as a daemon with transfer logging enabled. It is derived from the xferstats -# script that comes with wuftpd. See the usage message at the bottom for the -# options it takes. +# as a daemon with transfer logging enabled. It also parses a slightly tweaked +# version of the default format where %o has been replaced with %i. +# +# This script is derived from the xferstats script that comes with wuftpd. See +# the usage message at the bottom for the options it takes. # # Andrew Tridgell, October 1998 use Getopt::Long; # You may wish to edit the next line to customize for your default log file. -$usage_file = "/var/adm/rsyncd.log"; +$usage_file = "/var/log/rsyncd.log"; # Edit the following lines for default report settings. # Entries defined here will be over-ridden by the command line. @@ -50,10 +52,29 @@ if ($only_section) { line: while () { - ($day,$time,$pid,$op,$host,$ip,$module,$user,$bytes,$file) = split(' ', $_, 10); - next unless defined $file; - - next if $op ne 'send' && $op ne 'recv'; +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 '; + + next unless ($day,$time,$op,$host,$module,$file,$bytes) + = m{^ + ( \w\w\w\s+\d+ | \d+/\d\d/\d\d ) \s+ # day + (\d\d:\d\d:\d\d) \s+ # time + [^[]* \[\d+\]:? \s+ # pid (ignored) + (send|recv|[<>]f\S+) \s+ # op (%o or %i) + (\S+) \s+ # host + \[\d+\.\d+\.\d+\.\d+\] \s+ # IP (ignored) + (\S+) \s+ # module + \(\S*\) \s+ # user (ignored) + (.*) \s+ # file name + (\d+) # file length in bytes + $ }x; + + # TODO actually divide the data by into send/recv categories + if ($op =~ /^>/) { + $op = 'send'; + } elsif ($op =~ /^