SNMP v3 introduces the concept of the Engine ID, a unique identifier for each SNMP agent
in the network.
Gufo SNMP automatically performs Engine ID discovery as needed.
However, you can retrieve the actual value for various purposes,
such as inventory management or performance optimization,
and use it to skip the discovery step later.
First, we need to create SnmpSession object which wraps the client's session.
The SnmpSession may be used as an instance directly or operated as context manager
using the with clause. When used as a context manager,
the client automatically closes all connections on the exit of context,
so its lifetime is defined explicitly.
SnmpSession constructor offers lots of configuration variables for fine-tuning. Refer to the
SnmpSession reference
for further details. In our example, we set the agent's address and create
SNMPv3 user with default settings.
Note
To perform Engine ID discovery, the only mandatory parameter is the username.
Authentication and privacy settings can be left at their default values.
Now, we print the collected Engine ID. Since it is of bytes type,
we convert the output to hexadecimal form, which is commonly used
in network equipment configuration.