[Proftpd-user] xferstats for newer Perl
jayjwa <[email protected]>
| Newsgroups | gmane.network.proftpd.user |
|---|---|
| Message-ID | <[email protected]> |
While I realize that "xferstats.holger-preiss" is a utility that comes in the Proftpd "contrib" directory and is unsupported by the Proftpd team, it comes in the sources and has been unusable for awhile now with newer Perl versions. As it stands, the copy included up to and with proftpd-1.3.6rc2 and possibly beyond (not tested) will produce the following output with Perl5 (v5.22.1): root@atr2 /var/log # xferstats Type of arg 1 to keys must be hash (not constant item) at /usr/sbin/xferstats line 212, near "systemfiles)" Type of arg 1 to keys must be hash (not constant item) at /usr/sbin/xferstats line 213, near "xferbytes)" Type of arg 1 to keys must be hash (not constant item) at /usr/sbin/xferstats line 247, near "xferbytes) " Type of arg 1 to keys must be hash (not constant item) at /usr/sbin/xferstats line 282, near "groupfiles) " Type of arg 1 to keys must be hash (not constant item) at /usr/sbin/xferstats line 314, near "domainfiles) " Type of arg 1 to keys must be hash (not constant item) at /usr/sbin/xferstats line 356, near "xfertbytes) " Execution of /usr/sbin/xferstats aborted due to compilation errors. After looking online for about 30 minutes, I found that the Debian people have patched it. The patch isn't easy to find, and I had to dig it out of the proftpd-dfsg_1.3.5b-1.debian.tar.xz archive. Here it is, so people that build from source can find it easier: Description: Fixing output display of xferstats Author: Francesco Paolo Lovergine <[email protected]> Forwarded: not needed Index: proftpd-dfsg/contrib/xferstats.holger-preiss =================================================================== --- proftpd-dfsg.orig/contrib/xferstats.holger-preiss 2014-01-30 13:42:22.000000000 +0100 +++ proftpd-dfsg/contrib/xferstats.holger-preiss 2014-01-30 13:45:32.000000000 +0100 @@ -45,6 +45,8 @@ # -added option A which compares the addresses end with a given pattern # -added option i and o which reports either incoming or outgoing traffic only +use Getopt::Std; + @mydom = split(/\./, `dnsdomainname`); $mydom2 = pop(@mydom); chop($mydom2); $mydom1 = pop(@mydom); @@ -66,8 +68,7 @@ $opt_t = 1; $opt_l = 3; -require 'getopts.pl'; -&Getopts('f:rahdD:l:s:A:iotu:e'); +getopts('f:rahdD:l:s:A:iotu:e'); if ($opt_r) { $real = 1;} if ($opt_a) { $anon = 1;} @@ -209,8 +210,8 @@ } close LOG; -@syslist = keys(systemfiles); -@dates = sort datecompare keys(xferbytes); +@syslist = keys(%systemfiles); +@dates = sort datecompare keys(%xferbytes); if ($xferfiles == 0) {die "There was no data to process.\n";} @@ -244,7 +245,7 @@ # sort daily traffic by bytes sendt #foreach $date ( sort datecompare keys(nbytes) ) { -foreach $date ( sort datecompare keys(xferbytes) ) { +foreach $date ( sort datecompare keys(%xferbytes) ) { $nfiles = $xferfiles{$date}; $nbytes = $xferbytes{$date}; @@ -263,14 +264,14 @@ Total Transfers from each Archive Section (By bytes) - ---- Percent Of ---- - Archive Section Files Sent Bytes Sent Files Sent Bytes Sent -------------------------- ---------- ----------- ---------- ---------- + ---- Percent Of ---- + Archive Section Files Sent Bytes Sent Files Sent Bytes Sent +------------------------- ---------- ------------- ---------- ---------- . format line2 = -@<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>> @>>>>>>>>>> @>>>>>>> @>>>>>>> -$section, $files, $bytes, $pctfiles, $pctbytes +@<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>> @>>>>>>>>>>>> @>>>>>>> @>>>>>>> +$section, $files, $bytes, $pctfiles, $pctbytes . $| = 1; @@ -279,7 +280,7 @@ $~ = line2; # sort total transfer for each archive by # files transfered -foreach $section ( sort bytecompare keys(groupfiles) ) { +foreach $section ( sort bytecompare keys(%groupfiles) ) { $files = $groupfiles{$section}; $bytes = $groupbytes{$section}; @@ -311,7 +312,7 @@ $~ = line3; # sort amount per domain by files -foreach $domain ( sort domnamcompare keys(domainfiles) ) { +foreach $domain ( sort domnamcompare keys(%domainfiles) ) { $files = $domainfiles{$domain}; $bytes = $domainbytes{$domain}; @@ -353,7 +354,7 @@ $~ = line8; # sort hourly transmission by sent bytes -foreach $time ( sort keys(xfertbytes) ) { +foreach $time ( sort keys(%xfertbytes) ) { $nfiles = $xfertfiles{$time}; $nbytes = $xfertbytes{$time}; ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ ProFTPD Users List <[email protected]> Unsubscribe problems? http://www.proftpd.org/list-unsub.html