Monitoring WebSite State

Const EVENT_SUCCESS=0
Const EVENT_ERROR=1
Const EVENT_WARNING=2
Const EVENT_INFORMATION=4
Const EVENT_AUDIT_SUCCESS=8
Const EVENT_AUDIT_FAILURE=16

Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("web.txt", ForReading)

i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
loop

For Each objItem in objDictionary
strLine = objDictionary.Item(objItem)

send_request(strLine)


Next

function send_request(url)
set http_request = CreateObject( "Msxml2.XMLHTTP")
'http_request.setRequestHeader "Content-Type","text/html;charset=gb2312"
http_request.open "GET ", url, false
sub_echo=""
code="0"
fname=Replace(Replace(Replace(Replace(url,"/","_"),"","_"),":","_"),".","_")
On Error Resume Next
http_request.send(null)
If Err.Number <> 0 Then
sub_echo="Unavailable"
If Not objFSO.Fileexists(fName) Then
Call EventLogingError(url,sub_echo,code)
Set f1= objFSO.Createtextfile(fName, true)
End If
Err.Clear
Else
If http_request.statusText="OK" Then
If objFSO.Fileexists(fName) Then
sub_echo="OK"
code=http_request.Status
Call EventLogingSuccess(url,sub_echo,code)
set f2 = objFSO.getfile(fName)
f2.delete
End If
Else
sub_echo="BAD"
code=http_request.Status
If Not objFSO.Fileexists(fName) Then
Call EventLogingError(url,sub_echo,code)
Set f1= objFSO.Createtextfile(fName, true)
End If
End If
End If

set http_request=nothing
end function

Function EventLogingError(url,textstate,code)
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_ERROR, _
"Error: There URL OF "&url&" Current State is "&textstate&" With Return Code "&code&" !"
End Function


Function EventLogingSuccess(url,textstate,code)
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
"Success: There URL OF "&url&" Current State is "&textstate&" With Return Code "&code&" !"
End Function

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12262773/viewspace-1048922/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12262773/viewspace-1048922/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值