#!/usr/local/bin/perl # # Collect transfer totals # V1.0 pl 00 - 31 Dec 1996 # # # Written by # Jouko Valta (jopi@x2ftp.oulu.fi) # # # Revision History # V1.0 pl 00 - 31 dec 1996 # Initial revision # # Future # Implemented Move file with CD-ROM database updating # $Usage = " file\n\n"; $FIND = "/bin/find \. -type f -print | /bin/cut -c3-"; $TestMode = 0; $Verbose = 0; # ----------------------------------------------------------------------------- # set path $home=$ENV{HOME} || die "No HOME, are you homeless?\n"; $user=`/usr/ucb/whoami` || die "You don't exist.\n"; chop $user; $cwd = `/bin/pwd`; chop $cwd; ### process any FOO=bar switches eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift; ### Command line options while ($_ = $ARGV[0], /^-/) { shift; last if /^--$/; if (/^-t/) { ++$TestMode; next; } if (/^-h/) { print $Usage; exit 2; } if (/^-/) { die "Unsupported argument near $_\n Stopped"; } } $txtfile = $ARGV[0]; (!$txtfile) && die $Usage; if (!open (info, $txtfile)) { die "Can't open input file '$txtfile'. Stopped"; } # Process file printf "\nThis report is summary for FTP transfers.\n"; printf "Transfer Totals include the '/pub/msdos/programming' section only.\n"; printf "All other sections are filtered out for this report.\n"; printf "\n Week Files per Week Bytes per Week Files per Day Bytes per Day\n\n"; line: while () { # $Verbose && print $_; # View processing... chop; if (/(\d+)week(\d+).log:TOTALS FOR SUMMARY PERIOD\s+(.+)/) { $Year = $1; $Week = $2; $Date = $3; } if (/TOTALS FOR SUMMARY PERIOD\s+(.+)/) { $Date = $1; } if (/Files Transmitted During Summary Period\s+(\d+)/) { $WeekFiles{$Week} = $1; $WeekFilesTot += $1; } if (/Bytes Transmitted During Summary Period\s+(\d+)/) { $WeekBytes{$Week} = $1; $WeekBytesTot += $1; } if (/Average Files Transmitted Daily\s+(\d+)/) { $DayFiles{$Week} = $1; $DayFilesTot += $1; } if (/Average Bytes Transmitted Daily\s+(\d+)/) { $DayBytes{$Week} = $1; $DayBytesTot += $1; printf (" %2d week %2d\t%8.0f\t%11.0f\t%10.0f\t%10.0f\n", $Year, $Week, $WeekFiles{$Week}, $WeekBytes{$Week}, $DayFiles{$Week}, $DayBytes{$Week} ); } } # while printf ("\n %2d total\t%8.0f %14.0f\t%10.0f %14.0f\n\n", $Year, $WeekFilesTot, $WeekBytesTot, $DayFilesTot, $DayBytesTot ); close info;