Files and Directories
|
|
|
|
<? // read : http://unixhelp.ed.ac.uk/CGI/man-cgi?xferlog+5
// This script parses wu-ftp log file and show some stats sorted by username.
// Total bytes, bytes by day, incoming and outcoming totals
// Works better if you config your '/etc/logrotate.conf' to rotate at monthly basis.
// Tested only at Red-Hat box.
// By Omar Ballabio -- php@nave.net
$logfile = "/var/log/xferlog"; $handle = fopen ($logfile, "r");
while (!feof ($handle)) {
$buffer = fgets($handle, 4096);
$Tline = explode(" ",$buffer);
if(count($Tline)>1){
$FTPstat[$Tline[13]][total_bytes] += $Tline[7];
$FTPstat[$Tline[13]][direction][$Tline[11]] += $Tline[7];
$FTPstat[$Tline[13]][daily_bytes][$Tline[2]."-".$Tline[1]] += $Tline[7];
}
} fclose ($handle);
// Prints a simple array. Do some work to print this your way. echo "<div align=left><pre>";print_r($FTPstat);echo "</pre></div>"; ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|