Home
You are not currently signed in.

MIB Smithy

  1. Up to Table of Contents

Sending GET Requests

The SNMP Session's get subcommand is used to send SNMP GET requests to the configured agent for the session. The command may be used either in synchronous (wait for timeout or response before returning) or asynchronous (return immediately) mode, depending on whether or not the -callback parameter has been specified. When used in synchronous mode, the SDK will take care of instructing Tcl/Tk to handle idle events such as GUI updates, so synchronous mode is safe to use in a GUI environment.

Syntax:

% snmpcmd get ?option value ...? ?varBindList?

Where:

snmpcmd
is the name of session whose configuration identifies the agent to send the request to;
option value
are zero or more option+value pairs that may be present to override session configuration or other aspects of the request; and
varBindList
is an optional list of zero or more Variable Bindings to include in the request.

Returns:

  • In asynchronous mode: a unique identifier that can be used by the callback procedure to later correlate response and result information to the request.
  • In synchronous mode: a list of name+value pairs -- the same as those passed to the args parameter of a callback when used in asynchronous mode -- containing all of the response and result information for the request (See Callback Functions for details).

Request Options

-address address
Specifies the IP address or hostname to send the request to. This option overrides the default address configured for the session.
-alias name
Specifies the name an alias of preconfigured options that are to be subsituted in place of the alias in the get command.
-callback proc
Specifies the name of a Tcl procedure to be evaluated when a response is received or a timeout occurs. This procedure will be passed the unique identifier for the pending request and any result and response information received. If specified, the request will be performed in asynchronous mode, and synchronous mode otherwise.
-community string
Specifies the community string to use in the request if transmitting via SNMPv1 or SNMPv2c. This option overrides the default read community string configured for the session.
-ctxengineid string
Specifies the contextEngineID value to use for SNMPv3 messages. An empty string (default) indicates that the same value as msgAuthoritativeEngineID is to be used for contextEngineID.
-ctxname string
Specifies the contextName value to use for SNMPv3 messages.
-db name
Specifies the name of the SMI Database to use for any necessary lookups for data types or converting names to OIDs in the request. This option overrides the default SMI Database configured for the session.
-delay ms
Specifies a delay (in milliseconds) to wait before sending the SNMP message, which may be used to mitigate network congestion issues. This option overrides the default delay configured for the session.
-messageid integer
Specifies the Message ID to use in generating a transmitted SNMPv3 message. This option overrides the default Message ID that the SDK would otherwise automatically generate and encode in the message header.
-port port
Specifies the integer port number or service name to send the request to. This option overrides the default port configured for the session.
-requestid integer
Specifies the Request ID to use in generating the transmitted PDU, regardless of SNMP version. This option overrides the default Request ID that the SDK would otherwise automatically generate and encode in the PDU.
-retries count
Specifies the number of attempts to be made to retransmit the request if no response is received. This option overrides the default number of retries configured for the session.
-timeout ms
Specifies the integer timeout (in milliseconds) to wait before either retransmitting the message or signalling a timeout to the calling script (or callback), depending on the number of attempts made and the number of configured retries. This option overrides the default timeout configured for the session.
-version version
Specifies the SNMP version to use when sending the request. This option overrides the default SNMP version configured for the session. The valid values accepted are the same as those for the config command.

Example 1 - Synchronous GET Request on sysDescr.0 as relative OID

% set result [snmplib get sysDescr.0]
-mpd snmplib -address 127.0.0.1 -port 161 -version SNMPv1
-community public -pdutype response -requestid 0
-status noError -eindex 0 -varbinds
{{1.3.6.1.2.1.1.1.0 {OCTET STRING} {Generic SNMP Agent}}}

% array set params $result
% array get params -status
-status noError

Example 2 - Asynchronous GET Request on sysDescr.0 as relative OID

% set id [snmplib get -callback onResponseCmd sysDescr.0]
5104

Example 3 - Asynchronous GET Request on multiple absolute OIDs

% set id [snmplib get -callback onResponseCmd \
    [list 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.2.0]]
5105
  1. Up to Table of Contents