A comprehensive Python SNMP library supporting v1/v2c/v3 with authentication and privacy protocols
84
Build a simple network device poller that retrieves system information from network devices using SNMPv1. The poller should query specific device metrics and handle common error scenarios.
Your implementation should:
The poller should accept the following parameters:
@generates
def poll_device(device_ip: str, community: str, timeout: int = 2) -> dict:
"""
Poll a network device using SNMPv1 to retrieve system information.
Args:
device_ip: IP address of the target device
community: SNMP community string for authentication
timeout: Timeout in seconds (default: 2)
Returns:
A dictionary containing:
- 'success': Boolean indicating if the poll succeeded
- 'data': Dictionary with keys 'sysDescr', 'sysUpTime', 'sysContact', 'sysName'
(only present if success is True)
- 'error': Error message string (only present if success is False)
Example success response:
{
'success': True,
'data': {
'sysDescr': 'Linux device 5.4.0',
'sysUpTime': '1234567',
'sysContact': 'admin@example.com',
'sysName': 'router-01'
}
}
Example error response:
{
'success': False,
'error': 'Authentication failed'
}
"""
passProvides SNMP protocol implementation for querying network devices.
@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