rsh.vbs - vbscript script by ActiveXperts Software
rsh.vbs runs a command on a UNIX/LINUX host.
Use rsh.vbs directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select rsh.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.
rsh.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 = CheckRSh( "unix03", "admin", "ls -l /dev", 10000, "floppy" ) ' WScript.Echo "Return value: [" & bResult & "]" ' WScript.Echo "SYSDATA: [" & SYSDATA & "]" ' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]" ' ////////////////////////////////////////////////////////////////////////////// Function CheckRSh( strHost, strUser, strCommand, numTimeOut, strPattern ) ' Description: ' Run a command on a remote UNIX/LINUX machine. Success or Failure is determined by ' the standard output of the RSH command. ' 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 - Specifies the remote host on which to run the command ' 2) strUser - Specifies ther user name to use on the remote host.If omitted, the user name ' if the Network Monitor service is used. ' 3) strCommand - Specifies the command to run ' 4) numTimeOut - Specifies how long (in milliseconds) to wait for the completion of the command ' 5) strPattern - Text pattern to search for in the standard output. ' Usage: ' CheckRSh( "<Hostname | IP>", "<user>", "<command>", <timeout (msecs)>, "<Text Pattern>" ) ' Sample: ' CheckRSh( "unix03", "admin", "ls -l /dev", 10000, "floppy" ) Dim objRsh CheckRSh = retvalUnknown ' Default return value, and will be shown as a yellow (uncertain) icon in the Manager SYSDATA = "" ' SYSDATA displayed in the 'Data' column in the Manager SYSEXPLANATION = "" ' SYSEXPLANATION displayed in the 'LastResponse' column in the Manager Set objRsh = CreateObject("AxNetwork.RSh") objRsh.Clear objRsh.Host = strHost objRsh.UserName = strUser objRsh.Command = strCommand objRsh.ScriptTimeOut = numTimeOut objRsh.Run If objRsh.LastError <> 0 Then CheckRSh = retvalUnknown SYSEXPLANATION = "Error #" & objRsh.LastError & ": " & objRsh.GetErrorDescription( objRsh.LastError ) Exit Function End If If( objRsh.StdErr <> "" AND objRsh.StdOut = "" ) Then CheckRSh = retvalUnknown SYSEXPLANATION = "Standard Error: " & Left( objRsh.StdErr, 200 ) ' Show first 200 chars of Standard Output Exit Function End If If( InStr( objRsh.StdOut, strPattern ) <> 0 ) Then CheckRSh = True SYSEXPLANATION = "Pattern matched in RSH Standard Output" Else CheckRSh = False SYSEXPLANATION = "Pattern not matched in RSH Standard Output" End If End Function