SNMP:使用bulk命令用python恢复整个MIBtree

2024-09-28 17:25:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我在android中有一个SNMP代理。 我正试图用这个python脚本恢复整个MIBTree:

from pysnmp.entity.rfc3413.oneliner import cmdgen  


cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, \
varBinds = cmdGen.bulkCmd(  
        cmdgen.CommunityData('public', mpModel=0),  
        cmdgen.UdpTransportTarget(('192.168.0.90', 32150)), 
        0, 
        25, 
        (1,3,6,1,4,1,12619,1,1)
    )

if errorIndication:
    print(errorIndication)
elif errorStatus:
    print('%s at %s' % (errorStatus.prettyPrint(),
                    errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
    for varBind in varBinds:
    print(' = '.join([repr(x) for x in varBind]))

如果使用oid(1,3,6,1,4,112619,1,1)作为根oid,则输出如下:

ObjectType(ObjectIdentity(ObjectName('1.3.6.1.4.1.12619.1.1.1.0')),OctetString('intel ICI101'))
ObjectType(ObjectIdentity(ObjectName('1.3.6.1.4.1.12619.1.1.2.0')),OctetString('4.4.4'))
ObjectType(ObjectIdentity(ObjectName('1.3.6.1.4.1.12619.1.1.3.0')), TimeTicks(10100333))
(ObjectIdentity(ObjectName('1.3.6.1.4.1.12619.1.2.1.0')), EndOfMibView())

它工作正常。问题是我想要整个MIB树,所以我想要使用根oid,即(1,3,6,1,4,112619,1)。但使用该OID的输出是:

OIDs are not increasing

我们如何才能做到这一点?你知道吗


Tags: inforoidprintobjecttypeerrorindicationcmdgenvarbinds