sustat是一个专门用来分析Serv-U生成的log file的工具,其功能强大,而且效率很高,但是因为是完全基于命令行操作的,所以易用性方面不够,对于一些初级用户尤显困难。下面我将简单介绍一下sustat的使用方法,对它的使用参数加以注释,及介绍一些效率提高方法。
示例一:统计各个帐号的使用情况,包括登陆次数,下载/上传文件数和数据量,所占百分比等等。这个也是sustat的默认功能(不带任何参数即可)。
引用:
sustat \"redjnu\\redjnu050401.log\"
注:红色部分为sustat的主程序,蓝色部分为欲统计的Serv-U log file,我们一般设定log file 每天自动生成,所以日志文件一般以日期命名。此出即统计2005年4月1日的
FTP信息。下同。
得到的结果类似下面,包括总的文件下载/上传次数和各个不同帐号的登陆次数,下载/上传文件数和文件量。
Stats from 01Apr05 00:00:09 to 01Apr05 23:59:58
Users downloaded 1179 files = 146738.39 MB
uploaded 13 files = 2013.99 MB
User Conx Dfile DMB D% UFile UMB U%
______________________________________________________________________________
1: TV_ADV 645 491 73111.45 49.82% 0 0.00 0.00%
2: TV 415 348 55100.52 37.55% 0 0.00 0.00%
3: OP_DREAMSKY 9 23 4226.60 2.88% 1 0.00 0.00%
4: MUSIC 84 73 3528.58 2.40% 0 0.00 0.00%
5: JIMEY 5 13 2956.31 2.01% 3 539.58 26.79%
6: TV_JNU 318 47 2757.36 1.88% 0 0.00 0.00%
7: GHOUL 18 14 2728.60 1.86% 7 1357.93 67.42%
8: TW 2 17 2147.03 1.46% 0 0.00 0.00%
9: TV_VIP 7 2 153.66 0.10% 0 0.00 0.00%
10: Anonymous 461 151 28.31 0.02% 0 0.00 0.00%
11: TV_LIST 28 0 0.00 0.00% 0 0.00 0.00%
12: OP_K100 1 0 0.00 0.00% 1 59.83 2.97%
13: OP_EDISON 3 0 0.00 0.00% 1 56.64 2.81%
______________________________________________________________________________
示例二:统计文件下载次数。sustat \"
redjnu\\redjnu050401.log\"
-f 10 后面的绿色字为 -f 数字10,这里可以设定一个数字,表示输出列表的头n名,设为0则输出全部结果。结果类似下面所示(这里我只列出头10位的数据):
________________________________________________________________________________
Sorted downloaded file list from 01Apr05 00:00:09 to 01Apr05 23:59:58
________________________________________________________________________________
1: 118 x f:\\anonymous\\400g连续剧个人ftp分流+存储计划 .txt
2: 28 x f:\\ftproot\\连续剧\\[2005.03.14][tvb][御用闲人][粤语][dvd-rmvb][20集]\\御用闲人14-tvrip-52play.rmvb
3: 24 x f:\\ftproot\\连续剧\\[2005.03.14][tvb][御用闲人][粤语][dvd-rmvb][20集]\\御用闲人13-tvrip-52play.rmvb
4: 20 x f:\\ftproot\\连续剧\\[2005.03.30][tvb][新同居关系][粤语][dvd-rmvb][13集]\\新同居关系01.rmvb
5: 14 x f:\\anonymous\\暨南学生网系列ftp帐号(3月3日更新).txt
6: 13 x f:\\ftproot\\连续剧\\[2005.03.30][tvb][新同居关系][粤语][dvd-rmvb][13集]\\新同居关系02.rmvb
7: 11 x f:\\anonymous\\如何下载ftp上的
资源.htm
8: 8 x f:\\ftproot\\连续剧\\[2005.03.30][tvb][新同居关系][粤语][dvd-rmvb][13集]\\新同居关系03.rmvb
9: 7 x f:\\ftproot\\连续剧\\[2005.03.30][tvb][新同居关系][粤语][dvd-rmvb][13集]\\新同居关系04.rmvb
10: 7 x f:\\ftproot\\连续剧\\[2005.03.08][韩国][浪漫满屋][韩语中文字幕][dvd-rmvb][16集]\\浪漫满屋04.rmvb
示例三:统计目录下载排行。又细分为两种情况,一种是按照目录里面文件被下载的次数排行,另一种是按照目录里面被下载的数据量排行。
sustat \"
redjnu\\redjnu050401.log\"
-d 10 按文件下载次数排行。参数小写d,同样数字10表示只列出头10名。
sustat \"
redjnu\\redjnu050401.log\"
-D 10 按文件下载数据量排行。参数大些D,同样数字10表示只列出头10名。
对于像连续剧这类资源,按目录进行统计更加容易反映文件的受欢迎程度。输出结果类似:
________________________________________________________________________________
Sorted dir list by file count from 01Apr05 00:00:09 to 01Apr05 23:59:58
________________________________________________________________________________
1: 156 files in dir e:\\ftproot\\tv2\\[2005.02.18][韩国][大长今][韩语中文][dvd-rmvb][54集]
2: 145 files in dir f:\\anonymous
3: 98 files in dir f:\\ftproot\\连续剧\\[2005.03.14][tvb][御用闲人][粤语][dvd-rmvb][20集]
4: 91 files in dir f:\\ftproot\\连续剧\\[2005.03.11][国产][铁齿铜牙纪晓岚3][国语][vcd-rmvb][48集]
5: 84 files in dir f:\\ftproot\\连续剧\\[2005.03.30][tvb][新同居关系][粤语][dvd-rmvb][13集]
________________________________________________________________________________
_______________________________________________________________________________
Sorted dir list by downloaded size from 01Apr05 00:00:09 to 01Apr05 23:59:58
_______________________________________________________________________________
1: 22032.36 MB for dir e:\\ftproot\\tv2\\[2005.02.18][韩国][大长今][韩语中文][dvd-rmvb][54集]
2: 16360.31 MB for dir f:\\ftproot\\连续剧\\[2005.03.08][韩国][浪漫满屋][韩语中文字幕][dvd-rmvb][16集]
3: 13767.66 MB for dir f:\\ftproot\\连续剧\\[2005.03.14][tvb][御用闲人][粤语][dvd-rmvb][20集]
4: 12257.79 MB for dir f:\\ftproot\\连续剧\\[2005.03.30][tvb][新同居关系][粤语][dvd-rmvb][13集]
5: 11322.49 MB for dir f:\\ftproot\\连续剧\\[2005.03.11][国产][铁齿铜牙纪晓岚3][国语][vcd-rmvb][48集]
________________________________________________________________________________
示例四:统计IP访问情况。可对独立IP的登陆次数,或者下载数据量,或上传数据量进行排序,也可以计算出访问的独立IP数,注意这个统计对
系统资源占用较大,并且需要花一定时间(如果你的log file很大的话),这一步统计比以上任何一步需要的时间都要多。
sustat \"
redjnu\\redjnu050401.log\"
-hsustat \"
redjnu\\redjnu050401.log\"
-H小写h表示以下载量排序,大些H表示以登陆次数进行排序。输出结果类似:
Hostname Conx Dfile DMB D% UFile UMB U%
________________________________________________________________________________________________
1: 219.222.19.59 3 49 6543.31 4.46% 0 0.00 0.00%
2: 222.200.53.74 12 29 5686.56 3.88% 0 0.00 0.00%
3: 222.200.52.27 5 20 5083.28 3.46% 0 0.00 0.00%
4: 219.222.22.71 9 23 4226.60 2.88% 1 0.00 0.00%
5: 202.116.28.9 246 25 4087.46 2.79% 0 0.00 0.00%
6: 218.192.30.84 3 18 3538.53 2.41% 0 0.00 0.00%
7: 222.200.53.169 161 16 3165.18 2.16% 0 0.00 0.00%
8: 219.222.20.30 5 13 2956.31 2.01% 3 539.58 26.79%
9: 222.200.37.113 13 20 2925.44 1.99% 0 0.00 0.00%
10: 222.200.46.204 5 18 2925.04 1.99% 0 0.00 0.00%
好了,一般常用的参数主要也就这几个,而我们需要实现的功能也基本达到了。问题是,以上命令怎么用,在哪里输入,怎么得到输出结果。如果你熟悉命令行操作的话,你可以通过打开命令行模式,再切换到sustat所在目录,然后输入以上命令,得到结果,但是每次都这样做实在是太烦了,还要记一大堆命令。我有更加简便的效率提升方法,使用批处理文件。
首先将sustat的主程序和需要分析的log file准备好,主程序包括sustat.exe和cygwin1.dll两个文件,解压即可使用。下面我们在程序目录下面新建两个目录,一个叫redjnu,用来存放log file,另外一个叫report,用来存放输出结果。log file的路经如redjnu\\redjnu050401.log这样。然后新建一个文本文档,在里面输入如下内容:
引用:
@echo off
echo 生成基本统计报告...
sustat \"redjnu\\redjnu050401.log\" >> report\\redjnu050401.txt
echo 基本统计报告完成.
echo 生成按文件下载次数的统计报告...
sustat \"redjnu\\redjnu050401.log\" -f 0 >> report\\redjnu050401.txt
echo 按文件下载次数统计报告完成.
echo 生成下载目录统计报告(按文件数)...
sustat \"redjnu\\redjnu050401.log\" -d 0 >> report\\redjnu050401.txt
echo 下载目录统计报告完成.
echo 生成下载目录统计报告(按下载量)...
sustat \"redjnu\\redjnu050401.log\" -D 0 >> report\\redjnu050401.txt
echo 下载目录统计报告完成.
echo 生成IP统计报告...
sustat \"redjnu\\redjnu050401.log\" -h >> report\\redjnu050401.txt
echo IP统计报告完成.
echo 所有统计已经完成。请查看输出文件.
然后将文件保存为ftplog.bat 注意扩展名是bat类型,表示可执行批处理文件。上面的蓝色部分表示需要分析的log file的路经,紫色的部分表示输出报告的文件。上面的方法是对同一个log file执行四个不同的分析统计任务,然后将结果输出到同一个文件上,你可以在里面添加更多的命令用来同时分析更多的任务。然后双击一下该批处理文件,屏幕会闪现出几个字,然后很快就会消失,你再去report目录就可以看到报告已经生成了。
由于本人对bat批处理程序的编写的认识极其有限,所以上面的部分写得有点罗嗦,事实上通过bat批处理的编程功能完全可以写出更加简洁更加自动化的功能。当然这是另外的问题了。
本人一直都在寻找统计FTP下载情况的方法,但是我们用的Serv-U自身并不带有这个功能,只能通过log file的分析进行统计,我在Serv-U的官方主页上面看到有介绍几个专门分析log file的工具,其中也有windows模式运行的,但是不是效率太低就是功能达不到我的要求。sustat虽然在用户界面方面不足,但是功能却是很强大的,而且效率也很高。希望日后有人能够将他的界面完善。
最后附上包括sustat主程序以及一个示例log file,一个完整的输出报告,以及我上面所介绍的批处理文件的压缩包,仅供试用。
Ghoul @ FunShow暨南风
2005.04.06
附:sustat官方说明文档(所有命令参数的说明)
都是很简单的英文,我就不翻译了,我的英语也够烂的了-.-!
sustat V2.00
NAME
sustat - display statistics for the Serv-U Ftp Server
DESCRIPTION
This manual page documents the sustat command which analyse the logfile
of the Serv-U Ftp Server and output an ASCII report.
Statistics can be on users,files,directories or hosts.
SYNOPSIS
sustat logfile
[-s <start> or today[+|-<n>]]
[-e <end> or today[+|-<n>]]
[-d|-D <number_of_dirs>]
[-f <nb_of_files>]
[-h|-H]
[-l <user>]
[-r <user>]
[-o <user>]
[-x <exclude file>]
[-u]
[-a]
[-t]
[-m <memory size>]
[-debug]
[-warn]
[-v]
DESCRIPTION
This manual page documents the sustat command which analyse the logfile
of the Serv-U Ftp Server and output an ASCII report.
OPTIONS
logfile: path name of the Serv-U logfile to analyse.
-s <start>: Start Date of Analyse, in format YYYYMMDD
if none is given, then Analyse starts in the 1st line
of the logfile.
You can also provide a date relative to today
for example you can provide today or today-1 (ie yesterday)
-e <end>: End Date of Analyse, in format YYYMMDD
if none is given, then analyse ends in the last line
of the logfile.
You can also provide a date relative to today
for example you can provide today or today-1 (ie yesterday)
-f <n>: if specified, the report will not be on users but on files.
This will output the list of the n most downloaded files.
if you specify 0 as n then all files will be displayed.
-d <n>: if specified, the report will not be on users but on directories.
This will output the list of the n most downloaded directories
using number of files downloaded by directory
if you specify 0 as n then all directories will be displayed.
-D <n>: if specified, the report will not be on users but on directories.
This will output the list of the n most downloaded directories
using number of bytes downloaded by directory
if you specify 0 as n then all directories will be displayed.
-h: if specified, the report will not be on users but hosts.
This will output the list of all connected hosts
sorting them using download volume.
(if you want to sort using upload volume add -u option)
-H: if specified, the report will not be on users but hosts.
This will output the list of all connected hosts
sorting them using number of logins.
-u: if specified, the sort order for statistics will be
uploaded volumes instead of downloaded volumes.
-a: By default, Sustat ignores aborted transfers (upload and downloads)
If specified, Sustat will count bytes of aborted transfers.
-t: By default, Sustat does not show connections times.
If specified, Sustat show them in format HH:MM:SS
-l <user>: if specified, the report will not be on users but on the connections
list of the specified user. If specify all as user then
the connection list of all the users will be displayed.
-r <user>: if specified, the report will not be on users but on the
rejected connexions list of the specified user. If specify all as
user then the connexion list of all the users will be displayed.
-o <user>: if specified, Sustat will output all log lines related to the specified user.
This is useful to generate a logfile for a specific user.
-x <file>: If specified, then all usernames listed in the file
<file> will be ignored for statistics.
The format of excludefile is simply one username by line.
-m <n>: By default, Sustat allocate in memory 10,000 reports entries.
Thus reports are limited to 10,000 entries.
If you process a huge logfile which generate a report larger
than 10,000 entries, specify a larger value with this option.
Keep in mind that each entry takes 680 bytes in memory.
Thus, invoking sustat with -m 20000 will allocate 13 MB in memory.
-debug: Enable debugger
-warn: Enable warnings for invalid entries in logfile
-v: Display version and copyright information and exits
-u,-f,-d,-D cannot be given together.
Nota: if you provide @ as logfile name then
\"c:\\Program files\\Serv-U\\servu.log\" will be used as logfile.
Nota2: many of you asked me an option to write the output on a file
this is useless since you can redirect the output using > with DOS.
Just add: > filename on the end of the command line.
EXAMPLES:
To sort users regarding download volumes:
sustat \"c:\\Program files\\Serv-U\\servu.log\"
To sort users regarding upload volumes:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -u
To sort users by download volumes for year 1998:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s 19980101 -e 19983112
To sort users by download volumes ignoring root and anonymous:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -x c:\\temp\\exclude.lst
where file exclude.lst contains 2 lines:
root
anonymous
To sort users by upload volumes until end of year 1998:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -e 19983112 -u
To sort users regarding download volumes until yesterday:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -e today-1
To sort users by upload volume starting 30 days ago until 10 days ag
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s today-30 -e today-10 -u
To sort users regarding download volumes for today only
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s today -e today
To output the list of the 20 most downloaded files:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -f 20
To output the list of the 20 most downloaded files starting at month Aug 1998:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -f 20 -s 19980801
To output the list of the 25 most downloaded directories (using files count)
sustat \"c:\\Program files\\Serv-U\\servu.log\" -d 25
To output the list of the 15 most downloaded directories (using bytes count)
sustat \"c:\\Program files\\Serv-U\\servu.log\" -D 15
To output the list of all hosts ever connected to us (using download volumes)
sustat \"c:\\Program files\\Serv-U\\servu.log\" -h
To output the list of all hosts connected to us in 1999 (using upload volumes)
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s 19990101 -h -u
To output the list of all hosts connected to us in 1999 (using nb of logins)
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s 19990101 -H
To Output the list of all the connexions of the user JOHNDOE during the month of October 1999:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s 19991001 -e 19991031 -l JOHNDOE
To Output the list of all the rejected the connexions since October 1st:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s 19991001 -r all
To Output the log lines for user JOHN since October 1st:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -s 19991001 -o JOHN
To sort users by download volumes including aborted transfers:
sustat \"c:\\Program files\\Serv-U\\servu.log\" -a
To sort users by download volumes including aborted transfers and showing conections times
sustat \"c:\\Program files\\Serv-U\\servu.log\" -a -t
To sort users by upload volumes from Sept 1st 2000 until yesterday including
aborted transfers and showing connection times but excluding user admin
using standard Serv-U logfile:
sustat @ -s 20000901 -e today-1 -u -a -t -x file
where file is an ascii file with 1 line containing: admin
LIMITATIONS/BUGS:
With -m option, Reports size are no more limited in any way.
Memory size needed by this program is around 6,5 MB.
No bugs known.
LEGAL STUFF:
sustat is a freeware program. The package may not be altered
in any way and cannot be used for commercial purposes without the
prior written permission of the author. The copyright message should
be preserved.
No responsibility or liability will be accepted for any damage that
may appear to have resulted from use of this program. All use is at
your own risk. The software is provided \"as is\" without any warranty
implied or otherwise to the fitness or accuracy of the software and
documentation. The documentation is believed to be correct but the
author reserves the right to update the software and/or documentation
without notice.
AUTHOR:
Salim GASMI
Mail: salim@gasmi.net
WWW :
Irc : Dr_Unix