| < Prev | Back to Table of Contents | Next > |
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.
% snmpcmd get ?option value ...?
?varBindList?
..where snmpcmd is the name of session
whose configuration identifies the agent to send the request to,
varBindList is an optional list of zero or
more Variable Bindings to include
in the request, and a series of
option/value pairs
may be present to override some configuration parameters or other
aspects of the request.
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).
| Option | Description |
|---|---|
-callback |
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. |
-db |
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. |
-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. |
-address |
Specifies the IP address or hostname to send the request to. This option overrides the default address configured for the session. |
-port |
Specifies the integer port number to send the request to. This option overrides the default port configured for the session. |
-timeout |
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. |
-retries |
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. |
-community |
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. |
-requestid |
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. |
-messageid |
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. |
% 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
% set id [snmplib get -callback onResponseCmd sysDescr.0] 5104
% 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
| < Prev | Back to Table of Contents | Next > |