This object is used to send SNMP requests to a remote device.

Initialize or Initialize2 must be called prior to any other members.

CoreAsp.SnmpRqst uses a three step process:

  1. Calls Initialize or Initialize2 to initialize the object against a particular device.
  2. Sets optional parameters such as timeout value, port, etc.
  3. Performs any number of Get , GetNext , GetMultiple or Set operations against a device. Those operations return an ComSnmpResponse object that contains the status of the operation and the value either directly (use Failed/GetValue/GetOid ) or as a list of SNMP variable binding returned as XML data (use GetPayload ).

Method

Description

Returns

Initialize ( nDeviceID )

Initializes the SnmpRqst object for the device with the device ID specified in nDeviceID . If a device is not configured with a valid SNMP credential, the operation will fail.

  • nDeviceID . A positive integer corresponding to the device ID of a device configured in WhatsUp Gold.

<TIP> In Active Script Monitor and Script Performance Monitors, the device ID of the device to which the monitor is assigned can be obtained from the Context object: Context.GetProperty("DeviceID")

ComResult object

Initialize2 ( sDeviceAddress, nCredentialID )

Initializes the SnmpRqst object by creating a connection to a device using the IP address of a device and a credential stored in WhatsUp Gold. This method can be used to initialize SnmpRqst for a device that is not configured in WhatsUp Gold as long as the credentials for the device are configured in the credential library.

  • sDeviceAddress . The address or hostname of the device to be queried.
  • nCredentialID . A positive integer corresponding to the credential ID of a credential configured in WhatsUp Gold.

ComResult object

SetTimeoutMs ( nTimeoutInMilliSec )

Sets the timeout value in milliseconds. If not specified, the timeout defaults to 2000 milliseconds.

  • nTimeoutInMilliSec . A positive integer representing the number of milliseconds after which unresolved requests should be terminated.
    Note: NoteText: This method returns a value if the method fails and requires an object variable to capture this value. For example: varComResult = SnmpRqst.SetTimeoutMs(5000) ; where varComResult is a ComResult object.

ComResult object

SetNumRetries ( nNumberRetries )

Sets the number of times to retry a request that has timed out. If not specified, failed requests are retried one time.

  • nNumberRetries . A positive integer representing the number of times to retry timed out requests.

<TIP> To send only one SNMP packet per request, set nNumberRetries to 0 (zero).

ComResult object

SetPort ( nPort )

Sets the TCP/IP port to be used by SnmpRqst . If not specified, port 161 is used.

  • nPort . A positive integer between 1 and 65535 corresponding to the port to be used.

ComResult object

Get ( sOid )

Issues an SNMP Get command to retrieve the value of the specified object.

  • sOid . A string containing a valid OID.

ComSnmpResponse object

GetNext ( sOid )

Issues an SNMP GetNext command to retrieve the value of the object that follows the specified object in lexicographic order.

  • sOid . A string containing a valid OID.

ComSnmpResponse object

GetMultiple ( sListOfOids )

Issues an SNMP Get command for each of the objects specified. GetMultiple sends all commands in a single SNMP protocol data unit, so it is more efficient than issuing multiple Get commands independently.

  • sListOfOids . A comma-separated list of valid OIDs.

ComSnmpResponse object

Set ( sOid, sType, sValue )

Issues an SNMP Set command to set an OID value on a device.

  • sOid . A string containing a valid OID for the object for which you want to set the value.
  • sType . A single character corresponding to the type of value to set.

    i = integer

    u = unsigned integer

    s = string

    x = hexadecimal string

    d = decimal string

    n = NULL object

    o = object ID

    t = timeticks

    a = IPv4 address

    b = bits

  • sValue . A string containing the value to set.

ComSnmpResponse object

Note: NoteText: The Set function will not work unless the MIB object and the community string for the device have the Read Write access right.