‘=============================================================’=Copyright (c) 2010 猫七(QQ:77068320)=’=All rights reserverd.=’=============================================================’=IIS日志分析系统 v_1.10.0828=’=使用说明:http://www.miaoqiyuan.cn/p/iis-log-tools=’=作者博客:http://www.miaoqiyuan.cn=’=版权声明:本代码供站长免费使用,传播请保留版权信息=’=============================================================’=程序简介:在网上找了很多IIS日志分析工具,功能简单,只能=’=分析爬虫来访次数。有时候我们小站长也想分析下广告点击情况=’=,这时候市面上的IIS统计工具就无能为力了。耗时一晚上写出来=’=分享给大家,同时申请落伍,请大家帮顶。=’=申请地址:http://www.im286.com/thread-5021543-1-1.html=’=============================================================’=文件:log.vbs =’=功能:IIS日志分析,懂程序的朋友可扩展,功能不可限量=’=============================================================dbpath=”D:\log” ‘日志文件所在目录
tblna=”test.txt” ‘日志文件名,如果修改请同时修改 Schema.ini 中相关节点
function getuag(str)
if instr(str,”+MSIE+7.0;”)>0 then
getuag=”Internet Explore 7.0″
elseif instr(str,”+MSIE+8.0;”)>0 then
getuag=”Internet Explore 8.0″
elseif instr(str,”+MSIE+6.0;”)>0 then
getuag=”Internet Explore 6.0″
elseif instr(str,”MSIE”)>0 then
getuag=”Internet Explore(Other)”
elseif instr(str,”curl”)>0 then
getuag=”CUrl”
else
getuag=str
end if
end function
wscript.echo string(60,”=”)
wscript.echo ” IIS日志分析工具 By 苗启源(MiaoQiyuan.cn)”
wscript.echo string(60,”=”)
set conn=createobject(“ADODB.Connection”)
conn.open “provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & dbpath & “;Extended Properties=””text;HDR=YES;FMT=Delimited;”””
set rs=createobject(“ADODB.Recordset”)
‘统计 链接访问次数
statime=timer()
rs.open “select [cs-uri-stem],count([c-ip]) from [” & tblna & “] group by [cs-uri-stem]”,conn,1,1
ga=rs.getrows()
rs.close
wscript.echo “=访问次数=|=独立访客=|=访问路径=”
wscript.echo string(60,”-“)
for i=0 to ubound(ga,2)
rsid=rsid + 1
tme=ga(1,i)
uri=ga(0,i)
‘不支持 COUNT DISTINCT 郁闷,使用笨拙的方法
rs.open “select DISTINCT [c-ip] from [” & tblna & “] where [cs-uri-stem]='” & uri & “‘”,conn,1,1
aip=rs.recordcount
rs.close
wscript.echo string(10 – len(tme),” “) & tme & ” | ” & string(8 – len(aip),” “) & aip & ” | ” & uri
next
wscript.echo string(60,”-“)
wscript.echo ” 统计:” & rsid & “条记录 查询用时:” & formatnumber((timer() – statime) * 1000,3) & “毫秒”
wscript.echo string(60,”-“) & vbCrlf
‘统计 访问详情
for i=0 to ubound(ga,2)
rsid=0
uri=ga(0,i)
wscript.echo string(60,”=”)
wscript.echo ” 访问详情:” & uri
wscript.echo string(60,”=”)
statime=timer()
wscript.echo “=编号=|=IP地址=|=浏览器类型=”
rs.open “select DISTINCT [c-ip],[cs(User-Agent)] from [” & tblna & “] where [cs-uri-stem]='” & uri & “‘”,conn,1,1
do while not rs.eof
rsid=rsid + 1
‘IP 自动变成了数字,还没有找到解决方法
cip=rs(0)
uag=getuag(rs(1))
wscript.echo string(8 – len(rsid),” “) & rsid & ” | ” & string(8 – len(cip),” “) & cip & ” | ” & uag
rs.movenext
loop
rs.close
wscript.echo string(60,”-“)
wscript.echo ” 统计:” & rsid & “条记录 查询用时:” & formatnumber((timer() – statime) * 1000,3) & “毫秒”
wscript.echo string(60,”-“) & vbCrlf
next