traceroute.vbs - vbscript script by ActiveXperts Software
traceroute.vbs tracks the route of packets from one IP to another.
Use traceroute.vbs directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select traceroute.vbs. Configure the required parameter, or press 'Load a working sample'.
In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.
traceroute.vbs script code
' ///////////////////////////////////////////////////////////////////////////////
' // ActiveXperts Network Monitor - VBScript based checks
' // For more information about ActiveXperts Network Monitor and VBScript, visit
' // http://www.activexperts.com/support/network-monitor/online/vbscript/
' ///////////////////////////////////////////////////////////////////////////////
Option Explicit
' Declaration of global variables
Dim SYSDATA, SYSEXPLANATION ' SYSDATA is displayed in the 'Data' column in the Manager; SYSEXPLANATION in the 'LastResponse' column
' Constants - return values
Const retvalUnknown = 1 ' ActiveXperts Network Monitor functions should always return True (-1, Success), False (0, Error) or retvalUnknown (1, Uncertain)
' // To test a function outside Network Monitor (e.g. using CSCRIPT from the
' // command line), remove the comment character (') in the following lines:
' Dim bResult
' bResult = CheckTftp( "10.1.1.100", "/music/song001.mp3" )
' WScript.Echo "Return value: [" & bResult & "]"
' WScript.Echo "SYSDATA: [" & SYSDATA & "]"
' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]"
Function CheckRoute( strHost, nMaxHops, nMaxResponseTime )
' Description:
' Tracks the route packets taken from an IP network on their way to a given host.
' This function uses ActiveXperts Network Component.
' ActiveXperts Network Component is automatically licensed when ActiveXperts Network Monitor is purchased
' For more information about ActiveXperts Network Component, see: www.activexperts.com/network-component
' Parameters:
' 1) strHost - Host name or IP address or target
' 2) nMaxHops - Maximum number of hops to search for target
' 3) nMaxResponseTime - Wait timeout milliseconds for each reply
' Usage:
' CheckRoute( "<Hostname | IP>", <MaximumHops> , <MaximumResponseTimeMsecs> )
' Sample:
' CheckRoute( "www.activexperts.com", 30, 500 )
Dim objHop, objTraceRt, strResponseTime, strHopName, nHops
CheckRoute = retvalUnknown ' Default return value
SYSDATA = "0"
SYSEXPLANATION = ""
nHops = 0
Set objTraceRt = CreateObject( "AxNetwork.TraceRoute" )
' Enable logging for troubleshooting purposes
' objTraceRt.LogFile = "C:\Temp\TraceRt.txt"
' Resolve Host Names. It takes a bit longer, but makes sense to have hostnames instead of IP addresses
objTraceRt.ResolveHostName = True
objTraceRt.MaxHops = nMaxHops
objTraceRt.Timeout = nMaxResponseTime
Set objHop = objTraceRt.FindFirstHop( strHost )
If( objTraceRt.LastError <> 0 ) Then
CheckRoute = False
SYSDATA = nHops
SYSEXPLANATION = "Route to [" & strHost & "] not found; result=[" & objTraceRt.LastError & ": " & objTraceRt.GetErrorDescription( objTraceRt.LastError ) & "]"
Exit Function
End If
Do
If( objHop.Host <> "" ) Then
strHopName = objHop.Host
Else
strHopName = objHop.IP
End If
nHops = nHops + 1
If( objHop.ResponseTime > nMaxResponseTime ) Then
CheckRoute = False
SYSDATA = nHops
SYSEXPLANATION = "Hop [" & strHopName & "] response timeout [" & nMaxResponseTime & "ms] exceeded, time=[" & objHop.ResponseTime & "ms]"
Exit Function
End If
Set objHop = objTraceRt.FindNextHop
Loop Until objTraceRt.LastError <> 0
CheckRoute = True
SYSDATA = nHops
SYSEXPLANATION = "TraceRoute succeeded, all [" & nHops & "] hops replied within [" & objTraceRt.Timeout & "ms]"
End Function
