Objects of session class

The instances of session class have the following methods:

open()

Create and return connected socket object to be used for communication with remote SNMP process.

send_and_receive(message)

Attempt to send SNMP message and receive SNMP response from remote SNMP process or time out in timeout seconds. Accept and return BER encoded SNMP message (as Python string).

For more information on building / parsing SNMP message, please, refer to the message class documentation.

send(message)

Attempt to send SNMP message to remote SNMP process. Accept BER encoded SNMP message (given as Python string).

receive()

Return BER encoded SNMP response message (as Python string) as received from remote SNMP process or time out in timeout seconds.

close()

Terminate SNMP session previously established with remote SNMP process.

Objects of session class have the following public instance variables:

port

Specify the UDP port of remote SNMP process. The port variable is of type integer.

The value of the port variable takes effect only if specified before open() method is invoked.

The default value for UDP port is 161.

iface

Specify the IP number of local interface SNMP engine is to bind to. All SNMP requests would be originated from the interfaces SNMP engine binds to.

The value of the iface variable takes effect only if specified before open() method is invoked.

The iface attribute should be a list of strings where each string should represent either FQDN or IP number of desired local interface.

The default value is None what means to bind to all the local interfaces and originate SNMP request from primary system interface.

XXX: current implementation binds ONLY to the first interface of the list.

timeout

Specify for how many seconds to wait for response from SNMP agent. The timeout attribute is of floating point type.

The default is 1.0 second.

retries

Specify the number of request re-transmissions. The retries attribute is of integer type.

The default is 3 retries.


ilya@glas.net