MIB Smithy

  1. Up to Table of Contents

Opening SNMP Sessions

The new subcommand is used to create new SNMP Sessions. Each session, including the master database, can be used to create new sessions, initialized with default configuration values or with specified values. Each session is generally associated with the combination of a single SNMP agent and access parameters.

New sessions do not automatically transmit any messages to the agent to verify that access parameters are correct. The session will be created successfully even if the access parameters are incorrect or there isn't an SNMP agent at the given address -- it is the responsibility of the script to "poll" the agent, if necessary, to verify the configuration.


  • % snmpcmd new ?option value ...?
  • % snmpcmd new list


is the name of the session (such as snmplib for the master session);
option value
are zero or more option+value pairs, same as those supported by the config and cget commands, which may be present to configure the session at creation time; and
provides an alternate form where all of the option+value pairs are given in a single argument, allowing many properties to be configured from a list variable or from the output of configure with no arguments. This makes it easy to clone sessions.


  • Name of the created session, which can be later used to send SNMP requests to the configured agent or to close the session.

Session Defaults

The following defaults are assigned to newly created sessions where no value is specified at creation time:

Common Defaults

Description Property Default
SMI Database -db smilib
Delay -delay 0 (no delay between sent messages)
Local Address -localaddress {} (will listen for traps on all interfaces)
Local Port -localport 162 (will listen for traps on this port)
Log Channel -logchannel {} (packet logging disabled)
Log Command -logcommand {} (packet logging disabled)
Remote IP Address -remoteaddress
Remote Port -remoteport 161
Retries -retries 3 (Total of 4 transmits/20 seconds before timeout)
Use straps/nmtrapd -straps 1 (will try to use straps/nmtrapd for traps if port 162)
Request Timeout -timeout 5000 (milliseconds)
SNMP Version -version SNMPv1
Message Window -window 0 (no limit on number of pending requests)

SNMPv1/v2c Defaults

Description Property Default
Read Community -readcommunity public
Write Community -writecommunity private

SNMPv3 Defaults

Description Property Default
SNMPv3 Auth Password -authpass {} (no password - authentication disabled)
SNMPv3 Auth Protocol -authproto HMAC-MD5-96
Context Engine ID -ctxengineid {} (will use same value as msgAuthoritativeEngineID)
Context Name -ctxname {}
Remote Engine ID -engineid {} (will be obtained via discovery)
Local snmpEngineBoots* -localboots 1 (for receiving SNMPv3 informs)
Local snmpEngineID* -localengid 80:00:3e:55:05:XX:XX:XX:??:??:??:?? (XX = Product ID, ?? = random)
Local snmpEngineTime* -localtime 0 (for receiving SNMPv3 informs--updates automatically)
SNMPv3 Priv Password -privpass {} (no password - privacy disabled)
SNMPv3 Priv Protocol -privproto DES/CBC
SNMPv3 User Name -username {} (not set/zero-length)
* Note: by default, each session is given a unique and partially random snmpEngineID value, but sessions can be configured to the same value (in which case they will share the same snmpEngineBoots and snmpEngineTime values). It is the user's responsibility to save/restore these values to/from non-volatile storage if desired.

Example 1 - Creating a default session:

% set sess [snmplib new]

Example 2 - Creating an SNMPv3 auth/priv session :

% set sess [snmplib new -version SNMPv3 -username "test user" \
    -authpass "auth password" -privpass "priv password"]

Example 3 - Cloning an SNMP Session

% set sess_copy [$sess new [$sess configure]]
  1. Up to Table of Contents