WALK command¶
- async pysnmp.hlapi.asyncio.walk_cmd(snmpEngine: Any, authData: Any, transportTarget: Any, contextData: Any, *varBinds: Any, **options: Any) AsyncGenerator[SnmpResponse, None]¶
Walk a subtree with GETNEXT, yielding one row at a time.
next_cmd()issues a single GETNEXT and hands back whatever the agent answered, which for a subtree is rarely what the caller wanted: the protocol is lexicographic over the whole MIB and will walk straight past the end of the subtree named. This reissues until the subtree runs out, and stops there.Being an async generator, it can be stopped early – leave the loop and no further request is made – and it does not hold the whole table in memory.
- Parameters:
snmpEngine (
SnmpEngine) – Class instance representing SNMP engine.authData (
CommunityDataorUsmUserData) – Class instance representing SNMP credentials.transportTarget (
UdpTransportTargetorUdp6TransportTarget) – Class instance representing transport type along with SNMP peer address.contextData (
ContextData) – Class instance representing SNMP ContextEngineId and ContextName values.*varBinds (
ObjectType) – One or more class instances naming the subtrees to walk.
- Other Parameters:
**options –
Walk options, on top of those
next_cmd()takes:lexicographicMode - carry on past the end of the subtree, to the end of the MIB. Default is False, which is the point of this call; next_cmd is the one that does not bound itself.
ignoreNonIncreasingOid - carry on when the agent answers with an OID no greater than the one asked for. Default is False, which ends the walk with the error. A non-increasing OID is a real and common agent defect, and would otherwise loop forever, which is why the engine reports it at all.
maxRows - stop after this many rows. Default is 0, no limit.
maxCalls - stop after this many requests. Default is 0, no limit.
- Yields:
errorIndication (str) – True value indicates SNMP engine error.
errorStatus (str) – True value indicates SNMP PDU error.
errorIndex (int) – Non-zero value refers to varBinds[errorIndex-1]
varBinds (tuple) – A sequence of
ObjectTypeclass instances representing MIB variables returned in this row.
Examples
>>> from pysnmp.hlapi.asyncio import * >>> >>> async def run(): ... async for (errorIndication, errorStatus, errorIndex, ... varBinds) in walk_cmd( ... SnmpEngine(), ... CommunityData('public'), ... UdpTransportTarget(('demo.pysnmp.com', 161)), ... ContextData(), ... ObjectType(ObjectIdentity('IF-MIB', 'ifTable')), ... ): ... print(errorIndication, errorStatus, errorIndex, varBinds) >>>