Shortcut Menu

Skip

Main Navigation

Choose your language


ActiveXperts Network Monitor ships with a large collection of VBScript scripts and PowerShell scripts to monitor and manage a network.

Use ActiveXperts Netork Monitor to monitor your virtualization servers, domains, computers and devices. It runs on a single Windows server, without agents required on the monitored systems. It has many built-in checks and also allows administrators to create custom checks using PowerShell, VBScript, WMI and SSH.


Telnet.vbs - Use Telnet to check availability of IP services, this check is included in ActiveXperts Network Monitor

ActiveXperts Network Monitor ships with a powerful set of pre-defined checks. Each individual check has a static number of configuration items. To monitor other items, or to combine monitoring items, you can make use of custom VBScript checks.

Most of the built-in checks have a VBScript equivalent, implemented as a Function in a VBScript (.vbs) file. Out-of-the-box, each VBScript function monitors the same items as the built-in check. Feel free to modify a function. The VBScript check can be customized by editing the VBScript function.

To add a new VBScript-based SMTP monitoring check, do the following:

  • On the 'Monitor menu', click 'New Monitoring Check (VBScript)'. The 'VBScript Check' dialog box appears;
  • In the 'File selection box', select 'Telnet.vbs';
  • In the 'Function selection box', select 'CheckTelnet';
  • In the 'Function parameters group box' enter the required parameters. You can also load a working sample first by clicking on the 'Load a sample, click here' link.

To customize the above monitoring check, click on the 'Edit button' next to the 'File selection box'. Notepad will be launched. You can now make changes to the VBScript function(s).

Network Monitor ships with a few customized telnet checks:

Screenshot of a VBScript Telnet check

Telnet.vbs script source code

' ///////////////////////////////////////////////////////////////////////////////
' // ActiveXperts Network Monitor  - VBScript based checks
' // © ActiveXperts Software B.V.
' //
' // For more information about ActiveXperts Network Monitor and VBScript, please
' // visit the online ActiveXperts Network Monitor VBScript Guidelines at:
' //    http://www.activexperts.com/support/network-monitor/online/vbscript/
' // 
' ///////////////////////////////////////////////////////////////////////////////
'  

Option Explicit
Const  retvalUnknown = 1
Dim    SYSDATA, SYSEXPLANATION  ' Used by Network Monitor, don't change the names


' //////////////////////////////////////////////////////////////////////////////
' // To test a function outside Network Monitor (e.g. using CSCRIPT from the
' // command line), remove the comment character (') in the following 5 lines:
' Dim bResult
' bResult = CheckTelnet( "telnet.activexperts-labs.com", 23, "library", "mypasswd", "", "Search your library" )
' WScript.Echo "Return value: [" & bResult & "]"
' WScript.Echo "SYSDATA: [" & SYSDATA & "]"
' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]"
' ////////////////////////////////////////////////////////////////////////////////////////


Function CheckTelnet( strServer, numPort, strCommand1, strCommand2, strCommand3, strReceive )

' Description: 
'     Establish a telnet session to a POP3 mail server and validate its response
'     POP3 servers always reply a '+OK' message when ready to establish a session
'     This function uses the Network Component, an ActiveXperts product.
'     Network Component is automatically licensed when ActiveXperts Network Monitor is purchased
'     For more information about Network Component, see: www.activexperts.com/network-component
' Parameters:
'     1) strServer - a telnet server to connect to
'     2) numPort - the port to connect to
'     3) strCommand1 - the first command to send to the telnet server
'     4) strCommand2 - the second command to send to the telnet server
'     5) strCommand3 - the third command to send to the telnet server
'     6) strReceive - the string you should receive
' Usage:
'     CheckTelnet( "", Port, "Command1", "Command2", "Command3", "Receive string" )
' Sample:
'     CheckTelnet( "telnet.activexperts-labs.com", 23, "library", "mypasswd", "", "Search your library" )

    Dim objTcp, strAllResponses

    CheckTelnet           = 1   ' Default return value
    SYSDATA               = ""  ' Not used by this function
    SYSEXPLANATION        = ""  ' Set initial value

    Set objTcp = CreateObject("ActiveXperts.Tcp")
    objTcp.Protocol       = 2 ' 1 means: raw, 2 means: telnet (see also Network Component manual)

    objTcp.Connect strServer, numPort
    If( objTcp.LastError <> 0 Or objTcp.ConnectionState <> 3 ) Then
        CheckTelnet       = False
        SYSEXPLANATION    = "Unable to connect to [" & strServer & "]"
        objTcp.Disconnect ' can be called even when there's no connection
        Exit Function
    End If

    objTcp.Sleep( 2000 ) ' Allow some time

    tcprecv objTcp, strAllResponses 

    tcpsend objTcp, strCommand1
    tcprecv objTcp, strAllResponses

    tcpsend objTcp, strCommand2
    tcprecv objTcp, strAllResponses

    tcpsend objTcp, strCommand3
    tcprecv objTcp, strAllResponses

    If( InStr( UCase( strAllResponses ), UCase( strReceive )  ) <> 0 ) Then
      CheckTelnet         = True
    Else
        CheckTelnet       = False
    End If
    SYSEXPLANATION      = "Response=[" & strAllResponses & "]"

    objTcp.Disconnect    

End Function



' //////////////////////////////////////////////////////////////////////////////
' //
' // Private Functions
' //   NOTE: Private functions are used by the above functions, and will not
' //         be called directly by the ActiveXperts Network Monitor Service.
' //         Private function names start with a lower case character and will
' //         not be listed in the Network Monitor's function browser.
' //
' //////////////////////////////////////////////////////////////////////////////

Sub tcpsend( objTcp, strCommand )
    If( strCommand <> "" ) Then
      objTcp.SendString( strCommand )
    End If
End Sub


' //////////////////////////////////////////////////////////////////////////////

Sub tcprecv( objTcp, BYREF strAllResponses )
    Dim bHasData, strResponse 

    bHasData = objTcp.HasData

    While( bHasData )
      strResponse = objTcp.ReceiveString()
      bHasData = objTcp.HasData

      If( strAllResponses <> "" ) Then
        strAllResponses = strAllResponses & ".." ' .. to indicate a newline
      End If
      strAllResponses = strAllResponses & strResponse
    WEnd
End Sub