千家信息网

vbscript如何实现logparser的ISA2004 Web流量报告

发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,这篇文章给大家分享的是有关vbscript如何实现logparser的ISA2004 Web流量报告的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。我的很多客户希望能够每天或
千家信息网最后更新 2026年11月03日vbscript如何实现logparser的ISA2004 Web流量报告

这篇文章给大家分享的是有关vbscript如何实现logparser的ISA2004 Web流量报告的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。


我的很多客户希望能够每天或每周得到一份员工浏览Web情况的报告,例如所访问的站点以及流量等等,他们都使用ISA2004作为web proxy。由于ISA2004自带的report不能满足他们的要求,所以我写了这个脚本,用来生成报告。使用前请先阅读readme.txt

复制代码 代码如下:


'ISA 2004 Web Log Query Tool
'Created by mwpq
'Version 1.0
'Date 2007.9.18


On Error Resume Next

Dim startdate, enddate
Dim topweb, topuser,usertop, usertopweb

'Configuration part of the script
'==================================================================
startdate = 1 ' the newest log files to be queried. 1 means one day ago
interday = 7 ' the oldest log files is startdate + interday
' For example startdate =1, interday =7 means script will query log files between 8 days ago and yesterday's.

topweb="Top 20" ' List Top 20 Websites visited. Just change 20 to other No to get what you want like "top 21" will list top 21 websites.
topuser="Top 10" ' List Top 10 users and their total usage.
Usertop = "Top 20" ' List Top 20 Users with their top websites, depend on uesrtopweb. set to "" to list all users web usage
usertopweb = "Top 10"
sMailTo = "mwpq@yahoo.com" 'Send email repor to
sMailFrom = "admin@yourdomain.com 'Email comes from
sMailSub = "ISA Web Traffic Report" 'Email Title
sSMTPServer = "youremailserver" 'Email server
strMessage = "Please see attachment for the ISA Web Traffic Report." 'Email txt body.
satt = "C:\Program Files\Microsoft ISA Server\ISALogs\report.htm" 'Email attachment path. The report.htm will be created under ISA's log folder.

'===================================================================



Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing", _
cdoSendUsingPort = 2, _
cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"

'Create the html reprot and write the html header
'=================================================================================================================
Const BEGIN_TABLE = "

"
Const END_TABLE = "
"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(".\report.htm") Then
oFSO.Deletefile(".\report.htm")
End If
If oFSO.FileExists(".\tempsum.w3c") Then
oFSO.Deletefile(".\tempsum.w3c")
End If
Set oFile = oFSO.OpenTextFile(".\report.htm", ForWriting, True, true)

'Write the HTML head to file suit for IE viewer.
oFile.writeline ("" & vbcrlf & _
"" & vbcrlf & _
" ISA Web Usage Reports" & VbCrLf & _
"" & VbCrLf & _
"" & VbCrLf & _
"" & VbCrLf)

oFile.writeline "

ISA Web Traffic Report - From "&date-startdate-interday&" to "&date-startdate
oFile.writeline "

"
'=================================================================================================================
'End of create html report header part


'build the log file name list
spath = ""

while interday >= 0

dtmDate = date - startdate - interday

'Convert the current Date to UTC
'=================================================================================================================
strDay = Day(dtmDate)
If Len(strDay) < 2 Then
strDay = "0" & strDay
End If
strMonth = Month(dtmDate)
If Len(strMonth) < 2 Then
strMonth = "0" & strMonth
End If
strYear = Year(dtmDate)

sdate = strYear & strMonth & strDay
'=================================================================================================================

stemp2 = "'"&"ISALOG_"&sdate&"_WEB_* "&"'"
spath = spath & stemp2

if interday - startday > 0 then
spath = spath&", "
end if

interday = interday - 1
wend





'Create a temp sumary file
set objLogParser = CreateObject("MSUtil.LogQuery")
Set objInputFormat = _
CreateObject("MSUtil.LogQuery.W3CInputFormat")
SET w3cOutputFormat = WScript.CreateObject("MSUtil.LogQuery.W3COutputFormat")
w3cOutputFormat.filemode = 1 ' Set file to overwrite mode
strQuery = "SELECT cs-username, r-host, Sum(add(cs-bytes,sc-bytes)) as SRdata into 'tempsum.w3c' FROM "&spath&" where sc-Network = 'External' group by cs-username,r-host order by SRdata DESC"
objLogParser.Executebatch strQuery, objInputFormat,w3cOutputFormat

'check tempsum.w3c existed
Set oFSO1 = CreateObject("Scripting.FileSystemObject")
If oFSO1.FileExists(".\tempsum.w3c") Then
oFSO1 = nothing
else
oFSO1=nothing
wscript.echo "Sorry cannot find some of the log files to query! Script Quit."
wscript.quit
End If


'Generate report based on temp file.

'================================================================================
'Generate top web sites.
fl=0
oFile.writeline (BEGIN_TABLE & VbCrLf)
mWHeading topweb&" Websites"
mWBRow
mWTitle "Site Name"
mWTitle "Traffic (MB)"
mWERow

set objLogParser10 = CreateObject("MSUtil.LogQuery")
Set objInputFormat10 = _
CreateObject("MSUtil.LogQuery.W3CInputFormat")
'objInputFormat.recurse = 2

strQuery10 = "SELECT "&topweb&" r-host, sum(SRdata) as TSRData FROM 'tempsum.w3c' group by r-host order by TSRdata DESC"
Set objRecordSet10 = objLogParser10.Execute(strQuery10, objInputFormat10)
Do While Not objRecordSet10.AtEnd
Set objRecord10 = objRecordSet10.GetRecord

if fl = 0 then

mWBRow
mWDetail2 objRecord10.GetValue("r-host")
mwDetail2 FormatNumber(objRecord10.GetValue("TSRdata")/1048576,2)
mWERow
fl=1
else
mWBRow
mWDetail1 objRecord10.GetValue("r-host")
mwDetail1 FormatNumber(objRecord10.GetValue("TSRdata")/1048576,2)
mWERow
fl=0
end if


'wscript.echo "uri"& objRecord2.GetValue("r-host") & "---" & objRecord2.GetValue("SRdata")

objRecordSet10.MoveNext
Loop
spacer(12)
oFile.writeline (END_TABLE & VbCrLf)

'================================================================================

'================================================================================
'Generate top user list.
fl=0
oFile.writeline (BEGIN_TABLE & VbCrLf)
mWHeading topuser&" Users list"
mWBRow
mWTitle "logon Name"
mWTitle "Traffic (MB)"
mWERow

set objLogParser11 = CreateObject("MSUtil.LogQuery")
Set objInputFormat11 = _
CreateObject("MSUtil.LogQuery.W3CInputFormat")
'objInputFormat.recurse = 2

strQuery11 = "SELECT "&topuser&" cs-username, Sum(SRdata) as TSRdata FROM 'tempsum.w3c' group by cs-username order by TSRdata DESC"
Set objRecordSet11 = objLogParser11.Execute(strQuery11, objInputFormat11)
Do While Not objRecordSet11.AtEnd
Set objRecord11 = objRecordSet11.GetRecord

if fl=0 then
mWBRow
mWDetail2 objRecord11.GetValue("cs-username")
mwDetail2 FormatNumber(objRecord11.GetValue("TSRdata")/1048576,2)
mWERow
fl =1
else
mWBRow
mWDetail1 objRecord11.GetValue("cs-username")
mwDetail1 FormatNumber(objRecord11.GetValue("TSRdata")/1048576,2)
mWERow
fl =0
end if
'wscript.echo "uri"& objRecord2.GetValue("r-host") & "---" & objRecord2.GetValue("SRdata")

objRecordSet11.MoveNext
Loop
spacer(12)
oFile.writeline (END_TABLE & VbCrLf)

'================================================================================


set objLogParser1 = CreateObject("MSUtil.LogQuery")
Set objInputFormat1 = _
CreateObject("MSUtil.LogQuery.W3CInputFormat")

strQuery1 = "SELECT "&usertop&" cs-username, Sum(SRdata) as TSRdata FROM 'tempsum.w3c' group by cs-username order by TSRdata DESC"

Set objRecordSet1 = objLogParser1.Execute(strQuery1, objInputFormat1)
oFile.writeline (BEGIN_TABLE & VbCrLf)
mWHeading usertop&" Users' Web Traffic "

Do While Not objRecordSet1.AtEnd
Set objRecord1 = objRecordSet1.GetRecord
strUsername = objRecord1.GetValue("cs-username")
stt = "'"&strUsername&"'"


mWBRow
mWTitle strUsername &" ------ Total Web Traffic: " & FormatNumber(objRecord1.GetValue("TSRdata")/1048576,2)&" MB"
mWTitle "Traffic (MB)"
mWERow

'Wscript.echo ""
'wscript.echo stt &" >>> data: " & objRecord1.GetValue("TSRdata")

set objLogParser2 = CreateObject("MSUtil.LogQuery")
Set objInputFormat2 = _
CreateObject("MSUtil.LogQuery.W3CInputFormat")
'objInputFormat.recurse = 2
fl=0
strQuery2 = "SELECT "&usertopweb&" r-host, SRdata FROM 'tempsum.w3c' where cs-username =" &stt&" group by r-host,SRdata"
Set objRecordSet2 = objLogParser2.Execute(strQuery2, objInputFormat2)
Do While Not objRecordSet2.AtEnd
Set objRecord2 = objRecordSet2.GetRecord
if fl=0 then
mWBRow
mWDetail2 objRecord2.GetValue("r-host")
mwDetail2 FormatNumber(objRecord2.GetValue("SRdata")/1048576,2)

mWERow
fl=1
else
mWBRow
mWDetail1 objRecord2.GetValue("r-host")
mwDetail1 FormatNumber(objRecord2.GetValue("SRdata")/1048576,2)

mWERow
fl=0
end if

'wscript.echo "uri"& objRecord2.GetValue("r-host") & "---" & objRecord2.GetValue("SRdata")

objRecordSet2.MoveNext
Loop
objRecordSet1.MoveNext
spacer(12)

Loop

oFile.writeline (END_TABLE & VbCrLf)

' Write the html end to report.
oFile.WriteLine ("")
oFile.WriteLine ("")
oFile.Close


'Methods to create html(title and table) part
'=================================================================================================================
Private Sub mWHeading(sHeading)
oFile.writeline ( _
" " & vbCrLf & _
" " & sHeading &""& vbCrLf & _
" " & VbCrLf)

End Sub

Private Sub mWTitle(sContent)

oFile.writeline ( _
" " & sContent & "" & VbCrLf)
End Sub

Private Sub mWDetail1(sContent)
oFile.writeline ( _
" " & sContent & "" & VbCrLf)
End Sub

Private Sub mWDetail2(sContent)
oFile.writeline ( _
" " & sContent & "" & VbCrLf)
End Sub

Private Sub mWAlert1(sContent)
oFile.writeline ( _
" " & sContent & "" & VbCrLf)
End Sub

Private Sub mWAlert2(sContent)
oFile.writeline ( _
" " & sContent & "" & VbCrLf)
End Sub

Private Sub mWBRow
oFile.writeline ( " " & VbCrLf)
End Sub

Private Sub mWERow
oFile.writeline ( " " & VbCrLf)
End Sub
Private Sub spacer(iHeight)

oFile.writeline ( _
" " & VbCrLf)

End Sub

'=================================================================================================================
'End of create html method


'Send email


Dim iMsg, iConf, Flds

'// Create the CDO connections.
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

'// SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort

'// Set the SMTP server address here.
.Item(cdoSMTPServer) = sSMTPServer
.Update
End With

'// Set the message properties.
With iMsg
Set .Configuration = iConf
.To = sMailTo
.From = sMailFrom
.Subject = sMailSub
.TextBody = strMessage
End With

'iMsg.HTMLBody = sMailMessage
'// Send the message.


iMsg.AddAttachment satt

iMsg.Send ' send the message.
Set iMsg = Nothing
Set iConf = Nothing

感谢各位的阅读!关于"vbscript如何实现logparser的ISA2004 Web流量报告"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

报告 流量 代码 内容 更多 篇文章 不错 实用 员工 客户 情况 文章 看吧 知识 站点 脚本 参考 帮助 有关 浏览 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 手冲咖啡和咖啡机区别 北京互联网科技有限公司 互联网科技金融公司 为想互联网科技 壹账通互联网科技 顺网科技2021年互联网排名 中国最先进互联网科技公司 富国互联网科技创新基金 互联网科技公司需要的职位 小米互联网科技园设置 互联网和黑科技的看法 黑科技闪耀互联网之光 佛山市拉法互联网科技有限公司 中和天地互联网科技有限公司 恒生互联网科技业指数调整周期 科技互联网海报 雨阳互联网卡科技有限公司 北京军民互联网科技公司 优雇互联网科技有限公司 株洲百竞科技的互联网营销顾问 广东万易互联网科技有限公司惠州分公司 互联网科技论文 银优互联网科技有限公司 万达互联网科技 千方科技属于互联网企业吗 开一家科技互联网公司需要多少钱 世界互联网领先科技成果获奖 下一代互联网重大应用科技园 互联网硬科技公司 国产互联网科技公司
0