Skip to content

gufo.snmp.snmpd

snmpd context manager.

Snmpd

Bases: object

snmpd context manager for testing.

The context manager running snmpd instance for testing purposes. Requires Net-SNMP to be installed.

Parameters:

Name Type Description Default
path str

snmpd path.

'/usr/sbin/snmpd'
address str

Address to listen.

'127.0.0.1'
port int

Port to listen.

10161
community str

SNMP v1/v2c community.

'public'
location str

sysLocation value.

'Test'
contact str

sysContact value.

'test <test@example.com>'
engine_id Optional[str]

Optional explicit engine id for SNMPv3. Use generated value if not set.

None
users Optional[List[User]]

Optional list of SNMPv3 users.

None
start_timeout float

Maximum time to wait for snmpd to start.

5.0
verbose bool

Verbose output.

False
log_packets bool

Log SNMP requests and responses, available only with verbose option.

False

Attributes:

Name Type Description
version Optional[str]

Net-SNMP version.

engine_id

SNMPv3 engine id.

Note

Using the ports below 1024 usually requires the root priveleges.

Example
with Snmpd():
    # Any Gufo SNMP code
Example
async with Snmpd():
    # Any Gufo SNMP code

__aenter__() async

Asynchronous context manager entry.

__aexit__(exc_type, exc_val, exc_tb) async

Asynchronous context manager exit.

__enter__()

Context manager entry.

__exit__(exc_type, exc_val, exc_tb)

Context manager exit.

get_config()

Generate snmpd config.

Returns:

Type Description
str

snmpd configuration.