Proxy Ping vbscript

Version 1

    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.




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

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

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists ("C:\directory\file.txt")Then
                    Set objFile = objFSO.OpenTextFile("C:\directory\file.txt" ,8 )
                     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 )

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

    s2.vbs (1.2 KB) Download