This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Proxy Ping vbscript

Here is a proxy ping we are using to check status from servers that communicate with vendor networks we dont have access to.  It helps assure we can see if the network is up.  Additionally I poll response times and write them to a file.  I wanted to graph them but I searched on that and don't think Orion can do that yet.

 

command line is file.vbs source_ip dest_ip

You need to modify the directory and filename to what you want.  I had this working with a 3rd varibale for the filename but couldnt get the Orion server to take it.  Maybe a limitation on command line variables?  The file must exist (minimal error checking).  It writes date and time to line as well.  Hope someone finds use for this.  I plan to work on rolling the files daily so they dont get too large.

 

Scott

 

If WScript.Arguments.Count = 2 Then
 strComputer = WScript.Arguments.Item(0)
 PingAddress = WScript.Arguments.Item(1)

Else
 Wscript.Echo "Usage: Ping.vbs source_ip target_ip"
 Wscript.Quit
End If



Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists ("C:\directory\file.txt")Then
                Set objFile = objFSO.OpenTextFile("C:\directory\file.txt" ,8 )
                Else
                 objFSO.CreateTextFile("C:\directory\file.txt")
                 Set objFile = objFSO.OpenTextFile("C:\directory\file.txt",8)
                End If

Set objWMIService = GetObject(_
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set colPings = objWMIService.ExecQuery _
    ("Select * From Win32_PingStatus where Address = '"& PingAddress &"'")

For Each objStatus in colPings
    If IsNull(objStatus.StatusCode) _
        or objStatus.StatusCode<>0 Then
        WScript.Echo "Statistic: 1 "
WScript.Quit( 1 )

    Else
        Wscript.Echo "Statistic: 0 "
                objFile.WriteLine objStatus.ResponseTime & "ms" & vbTab & Date & vbTab & Time
                objFile.Close
WScript.Quit( 0 )
    End If
Next

s2.vbs