A comprehensive Python SNMP library supporting v1/v2c/v3 with authentication and privacy protocols
84
A command-line utility for monitoring SNMP agents on different network interfaces in a multi-homed system.
In multi-homed systems (systems with multiple network interfaces), you may need to send SNMP requests from specific network interfaces. This is common when:
Your task is to build a monitoring utility that can query SNMP agents while specifying which local network interface to use for sending requests.
The utility should accept the following command-line arguments:
--target: The SNMP agent address (IP or hostname)--community: The SNMP community string (default: "public")--local-addr: The local IP address/interface to bind to--oid: The OID to query (default: "1.3.6.1.2.1.1.1.0" - sysDescr)The utility should:
On success, output should be:
OID: <oid>
Value: <value>On error, output should be:
Error: <error description>When binding to local address "127.0.0.1" and querying localhost agent on port 1161, it successfully retrieves the sysDescr OID and displays the result @test
When an invalid local address is provided (e.g., "999.999.999.999"), it displays an appropriate error message @test
When the target agent is unreachable or times out, it displays a timeout error message @test
@generates
"""
Network interface monitor for SNMP queries on multi-homed systems.
"""
def query_snmp(target: str, community: str, local_addr: str, oid: str) -> tuple[str, str | None]:
"""
Query an SNMP agent using a specific local network interface.
Args:
target: SNMP agent address (IP:port or hostname:port)
community: SNMP community string
local_addr: Local IP address to bind to
oid: OID to query
Returns:
A tuple of (result_message, error_message).
If successful, result_message contains the formatted output and error_message is None.
If failed, result_message is None and error_message contains the error description.
"""
pass
def main():
"""
Main entry point for the command-line utility.
Parses arguments and calls query_snmp().
"""
pass
if __name__ == "__main__":
main()Provides SNMP protocol implementation with support for local interface binding.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-pysnmpevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10