#!/usr/pkg/bin/perl # Author : Stefan Schumacher stefan[at]net-tex.de # License : BSD # Version : 0.01pre-alpha ;-) # Purpose : a *very* primitive hack to analyze the xferlog of my FTP Server # greps through the file to get the lines regarding the NetBSD - directory # and accumulates the downloaded bytes ## # grep for path to netbsd and for 'seconds' to get downloaded files into array my @xferdump = `cat xferlog | grep -i '/pub/netbsd' | grep -i 'seconds' > xanalyse`; ## # same procedure, but count lines to get number of files my $filecnt = `cat xferlog | grep -i '/pub/netbsd' | grep -i 'seconds' | wc -l`; ## # get anonymus logins my $anonlogin = `cat xferlog | grep -i 'ANONYMOUS FTP LOGIN FROM' | wc -l`; open MYHANDLE, 'xanalyse' or die; my @fileInLines = ; while(){ my $split1 = (split /=/,$_)[1]; my $split2 = (split / /,$split1)[1]; $allbytes += $split2; } `rm xanalyse`; chomp($anonlogin); print "anonymous logins \t $anonlogin \n"; chomp($filecnt); print "downloaded files \t $filecnt \n"; chomp($allbytes); print "downloaded bytes \t $allbytes \n"; $allkbytes=$allbytes/1024; print "downloaded Kbytes \t $allkbytes\n"; $allmbytes=$allkbytes/1024; print "downloaded Mbytes \t $allmbytes\n"; $allgbytes=$allmbytes/1024; print "downloaded Gbytes \t $allgbytes\n";