-
-
Notifications
You must be signed in to change notification settings - Fork 220
Open
Description
# pip install pysnmp pysnmp-mibs
import asyncio
from pysnmp.hlapi.v3arch.asyncio import *
async def walk(host, port, community):
return next_cmd(
SnmpEngine(),
CommunityData(community, mpModel=1),
await UdpTransportTarget.create((host, port)),
ContextData(),
ObjectType(ObjectIdentity('IF-MIB', 'ifIndex')),
ObjectType(ObjectIdentity('IF-MIB', 'ifDescr')),
ObjectType(ObjectIdentity('IF-MIB', 'ifType')),
ObjectType(ObjectIdentity('IF-MIB', 'ifSpeed'))
)
async def main():
errorIndication, errorStatus, errorIndex, varBind = await walk('asr.loc', 161, 'PUB')
print(''.join([x.prettyPrint()+'\n' for x in varBind]))
errorIndication, errorStatus, errorIndex, varBind = await walk('asr.loc', 161, 'PUB')
print(''.join([x.prettyPrint()+'\n' for x in varBind]))
errorIndication, errorStatus, errorIndex, varBind = await walk('asr.loc', 161, 'PUB')
print(''.join([x.prettyPrint()+'\n' for x in varBind]))
if __name__ == '__main__':
asyncio.run(main())
pass
Result loop
IF-MIB::ifIndex.1 = 1
IF-MIB::ifDescr.1 = GigabitEthernet0/0/0
IF-MIB::ifType.1 = ethernetCsmacd
IF-MIB::ifSpeed.1 = 1000000000
IF-MIB::ifIndex.1 = 1
IF-MIB::ifDescr.1 = GigabitEthernet0/0/0
IF-MIB::ifType.1 = ethernetCsmacd
IF-MIB::ifSpeed.1 = 1000000000
IF-MIB::ifIndex.1 = 1
IF-MIB::ifDescr.1 = GigabitEthernet0/0/0
IF-MIB::ifType.1 = ethernetCsmacd
IF-MIB::ifSpeed.1 = 1000000000
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels