在網上找了很多IIS日志分析工具,功能實在太有限,有的僅能分析百度、谷歌等搜索引擎爬蟲的來訪次數,遠遠達不到我們的用戶的需求。作為一個小站長,有的時候也要分析一下自己站點的廣告點擊情況,靜態頁面的還好說,下載類的業務就不好統計了。耗時一晚上寫出來本工具分享給大家。
'=============================================================
'= 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
到此這篇關于vbs寫的IIS日志分析工具的文章就介紹到這了,更多相關vbs IIS日志分析內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!