miscellaneous.vbs - vbscript script by ActiveXperts Software
miscellaneous.vbs miscellaneous routines.
Use miscellaneous.vbs directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select miscellaneous.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.
miscellaneous.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 = ShowDebugger( "c:\file.log" )
' WScript.Echo "Return value: [" & bResult & "]"
' WScript.Echo "SYSDATA: [" & SYSDATA & "]"
' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]"
Function ShowDebugger( strDebugFile )
' Description:
' Print debug information to a log file while the Network Monitor Engine interpreter runs the script.
' Parameters:
' 1) strDebugFile - the name of the debug output file. The path of the file must be a valid path.
' If the file does not exists, the file will be created.
' Usage:
' ShowDebugger( "<Debug File>" )
' Sample:
' ShowDebugger( "c:\network-monitor.log" )
Dim objDebugger
Set objDebugger = CreateObject( "ActiveXperts.VbDebugger" )
objDebugger.DebugFile = strDebugFile
objDebugger.Enabled = True
objDebugger.ClearDebugFile ' Clear the file is desired
objDebugger.WriteLine "Debug file cleared at " & Date() & " " & Time()
objDebugger.WriteLine "Write information to the debug file"
objDebugger.Sleep 1000 ' Let the script wait for 3 seconds
objDebugger.WriteLine "ShowDebugger function ready at " & Date() & " " & Time()
Set objDebugger = Nothing
ShowDebugger = True
SYSEXPLANATION = "ShowDebugger function completed"
End Function
' //////////////////////////////////////////////////////////////////////////////
Function RandomResult( nMax )
' Description:
' This function returns True or False at random. Use this function for testing purposes
' A random number [1..10] is generated. If this number is less or equal than nMax, the
' result is True, otherwise the result is False
' Parameters:
' 1) nMax - a maximum between 1 and 10
' Usage:
' RandomResult( <nMax> )
' Sample:
' RandomResult( 5 )
Dim n
' Set seed
Randomize Second(Time)
' Assign a random in range [1..10]
n = CInt( ( 10 * Rnd() ) + 0.5 )
SYSDATA = n
SYSEXPLANATION = "Random number in range [1..10]: [" & n & "]"
If( n <= nMax ) Then
RandomResult = True
Else
RandomResult = False
End If
End Function
