ITPub博客

首页 > 应用开发 > IT综合 > Monitoring WebSite State

Monitoring WebSite State

原创 IT综合 作者:chlf2008 时间:2011-04-20 15:43:37 0 删除 编辑

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博客 ” ,链接:https://blog.itpub.net/12262773/viewspace-1048922/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    6
  • 访问量
    6083