(dst, oid="1", community="public")
| 288 | |
| 289 | |
| 290 | def snmpwalk(dst, oid="1", community="public"): |
| 291 | try: |
| 292 | while True: |
| 293 | r = sr1(IP(dst=dst) / UDP(sport=RandShort()) / SNMP(community=community, PDU=SNMPnext(varbindlist=[SNMPvarbind(oid=oid)])), timeout=2, chainCC=1, verbose=0, retry=2) # noqa: E501 |
| 294 | if r is None: |
| 295 | print("No answers") |
| 296 | break |
| 297 | if ICMP in r: |
| 298 | print(repr(r)) |
| 299 | break |
| 300 | print("%-40s: %r" % (r[SNMPvarbind].oid.val, r[SNMPvarbind].value)) |
| 301 | oid = r[SNMPvarbind].oid |
| 302 | |
| 303 | except KeyboardInterrupt: |
| 304 | pass |