Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pysnmp: No Such Name Error (No Such Object currently exists at this OID) #397

Open
mason3k opened this issue Apr 2, 2021 · 1 comment
Open

Comments

@mason3k
Copy link

mason3k commented Apr 2, 2021

I am trying to get IF-MIB values via pysnmp, and am getting a No Such Object currently exists at this OID. I'm using code very similar to the example code, however, so I'm not sure what's going wrong. Can anyone see the issue? 1.3.6.1.2.1.2.2.1.6 is supposed to get the IF address (http://oid-info.com/get/1.3.6.1.2.1.2.2.1.6)

from pysnmp.hlapi import *
from pysnmp.smi import builder, view

# snmp.live.gambitcommunications.com
# demo.snmplabs.com
# snmpsim.try.thola.io
# localhost
MIB_VIEW_CONTROLLER = view.MibViewController(builder.MibBuilder())

g = getCmd(SnmpEngine(),
    CommunityData('public'),
    UdpTransportTarget(('127.0.0.1', 161)),
    ContextData(),
    ObjectType(ObjectIdentity('1.3.6.1.2.1.2.2.1.6')),
    lookupNames=True, lookupValues=True)

errorIndication, errorStatus, errorIndex, varBinds = next(g)

if errorIndication:
    print(errorIndication)

elif errorStatus:
    print('%s at %s' % (errorStatus.prettyPrint(),
                        errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))

else:
    print("hello")
    for varBind in varBinds:
        print(type(varBind))
        print(' = '.join([x.prettyPrint() for x in varBind]))
@lextm
Copy link

lextm commented Jan 19, 2023

If you read more about SNMP, you should know 1.3.6.1.2.1.2.2.1.6 is a column of the ifTable. Thus, the actual object must be queried via 1.3.6.1.2.1.2.2.1.6+<table index>, such as 1.3.6.1.2.1.2.2.1.6.1 (where the index is 1).

Or alternatively, you should use other methods to perform SNMP WALK operations. That's nextCmd/bulkCmd in old releases or walkCmd/bulkWalkCmd in the latest release.

Read #429 for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants