etingof / pysnmp

Python SNMP library
http://snmplabs.com/pysnmp/
BSD 2-Clause "Simplified" License
568 stars 188 forks source link

Get no result of getCmd #443

Closed justinwubo closed 1 year ago

justinwubo commented 1 year ago

I can get the correct system up time of running snmpget, but the code of getCmd returns no result.

Linux command:

#snmpget -v 3 -n pancha -u snmpTester -l noAuthNoPriv 10.80.215.8 "1.3.6.1.2.1.1.3.0"
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (697945) 1:56:19.45

Python execution:

python3 snmp_test.py 
['SNMPv2-MIB::sysUpTime.0', '']

Python code:

from pysnmp.hlapi import *

def snmp_get(ip, oid, n=0):
          userData = UsmUserData( 
          'snmpTester'
         )

          g = getCmd(SnmpEngine(),  
          userData, 
          UdpTransportTarget((ip, 161), timeout=1, retries=0), 
          ContextData(), 
          ObjectType(ObjectIdentity(oid)) 
          )

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

          if errorIndication:
              if n < 3:
                  n += 1
                  #time.sleep(0.5)
                  print(ip, oid, 'Retry snmp_get')
                  return snmp_get(ip, oid, n)
              return 'error'
          else:
              return [x.prettyPrint() for x in varBinds[0]]

print(snmp_get('10.80.215.8', '1.3.6.1.2.1.1.3.0'))
lextm commented 1 year ago

You can enable PySNMP debugging if you read this section http://www.pysnmp.com/pysnmp/examples/#using-these-examples

The verbose logging can easily tell what's up.

justinwubo commented 1 year ago

You can enable PySNMP debugging if you read this section http://www.pysnmp.com/pysnmp/examples/#using-these-examples

The verbose logging can easily tell what's up.

Thanks! It helps and comes some errors with the code "debug.setLogger(debug.Debug('dsp', 'msgproc', 'secmod'))". But I still cannot figure out what the problem is.

2023-05-26 09:55:55,634 pysnmp: processIncomingMsg: cached msgUserName snmpTester info by securityStateReference 3701147
2023-05-26 09:55:55,634 pysnmp: prepareDataElements: SM succeeded
2023-05-26 09:55:55,634 pysnmp: prepareDataElements: using sendPduHandle 2948671 for msgID 8450726
2023-05-26 09:55:55,634 pysnmp: StatusInformation: {'errorIndication': ReportPduReceived('1.3.6.1.2.1.11.32.0'), 'oid': <ObjectName value object, tagSet <TagSet object, tags 0:0:6>, payload [1.3.6.1.2.1.11.32.0]>, 'val': <Counter32 value object, tagSet <TagSet object, tags 64:0:1>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>, payload [2]>, 'sendPduHandle': 2948671}
2023-05-26 09:55:55,634 pysnmp: receiveMessage: MP failed, statusInformation {'errorIndication': ReportPduReceived('1.3.6.1.2.1.11.32.0'), 'oid': <ObjectName value object, tagSet <TagSet object, tags 0:0:6>, payload [1.3.6.1.2.1.11.32.0]>, 'val': <Counter32 value object, tagSet <TagSet object, tags 64:0:1>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>, payload [2]>, 'sendPduHandle': 2948671}, forcing a retry
2023-05-26 09:55:55,638 pysnmp: __expireRequest: req cachedParams {'messageProcessingModel': <SnmpMessageProcessingModel value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>, <ValueRangeConstraint object, consts 0, 2147483647>>, payload [3]>, 'sendPduHandle': 2948671, 'timeout': 2.0, 'cbFun': <bound method CommandGenerator.processResponsePdu of <pysnmp.entity.rfc3413.cmdgen.GetCommandGenerator object at 0x7ff83907b4e0>>, 'cbCtx': (1714232325, <bound method GetCommandGenerator.processResponseVarBinds of <pysnmp.entity.rfc3413.cmdgen.GetCommandGenerator object at 0x7ff83907b4e0>>, (<function getCmd.<locals>.__cbFun at 0x7ff838f4d048>, (True, <function getCmd.<locals>.cbFun at 0x7ff839073f28>, {}))), 'transportDomain': <TDomain value object, tagSet <TagSet object, tags 0:0:6>, payload [1.3.6.1.6.1.1]>, 'transportAddress': ('10.80.215.8', 161), 'securityModel': <SnmpSecurityModel value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>, <ValueRangeConstraint object, consts 0, 2147483647>, <ValueRangeConstraint object, consts 1, 2147483647>>, payload [3]>, 'securityName': <SnmpAdminString value object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 0, 255>>, encoding utf-8, payload [snmpTester]>, 'securityLevel': <SnmpSecurityLevel value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>, <SingleValueConstraint object, consts 1, 2, 3>>, namedValues <NamedValues object, enums noAuthNoPriv=1, authNoPriv=2, authPriv=3>, payload [noAuthNoPriv]>, 'contextEngineId': <SnmpEngineID value object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 5, 32>>, encoding iso-8859-1, payload [pangustor]>, 'contextName': <SnmpAdminString value object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 0, 255>>, encoding utf-8, payload []>, 'pduVersion': 1, 'PDU': <GetRequestPDU value object, tagSet=<TagSet object, tags 128:32:0>, subtypeSpec=<ConstraintsIntersection object>, componentType=<NamedTypes object, types <NamedType object, type request-id=<Integer32 schema object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>>>, <NamedType object, type error-status=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, namedValues <NamedValues object, enums noError=0, tooBig=1, noSuchName=...Writable=17, inconsistentName=18>>>, <NamedType object, type error-index=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, <Integer value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>, payload [2147483647]>>>>>, <NamedType object, type variable-bindings=<VarBindList schema object, tagSet=<TagSet object, tags 0:32:16>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, <Integer value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>, payload [2147483647]>>>, componentType=<VarBind schema object, tagSet=<TagSet object, tags 0:32:16>, subtypeSpec=<ConstraintsIntersection object>, componentType=<NamedTypes object, types <NamedType object, type name=<ObjectName schema object, tagSet <TagSet object, tags 0:0:6>>>, <NamedType object, type =<_BindValue schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type value=<ObjectSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type simple=<SimpleSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type integer-value=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>>>, <NamedType object, type string-value=<OctetString schema object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, encoding iso-8859-1>>, <NamedType object, type objectID-value=<ObjectIdentifier schema object, tagSet <TagSet object, tags 0:0:6>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type application-wide=<ApplicationSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type ipAddress-value=<IpAddress schema object, tagSet <TagSet object, tags 64:0:0>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 4, 4>>, encoding iso-8859-1>>, <NamedType object, type counter-value=<Counter32 schema object, tagSet <TagSet object, tags 64:0:1>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type timeticks-value=<TimeTicks schema object, tagSet <TagSet object, tags 64:0:3>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type arbitrary-value=<Opaque schema object, tagSet <TagSet object, tags 64:0:4>, encoding iso-8859-1>>, <NamedType object, type big-counter-value=<Counter64 schema object, tagSet <TagSet object, tags 64:0:6>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 18446744073709551615>>>>, <NamedType object, type gauge32-value=<Gauge32 schema object, tagSet <TagSet object, tags 64:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type unSpecified=<Null value object, tagSet <TagSet object, tags 0:0:5>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload []>>, <NamedType object, type noSuchObject=<NoSuchObject value object, tagSet <TagSet object, tags 128:0:0>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Object c...ists at this OID]>>, <NamedType object, type noSuchInstance=<NoSuchInstance value object, tagSet <TagSet object, tags 128:0:1>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Instance...ists at this OID]>>, <NamedType object, type endOfMibView=<EndOfMibView value object, tagSet <TagSet object, tags 128:0:2>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No more variable...in this MIB View]>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>, payload [<Integer32 value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>, payload [5321913]>, <Integer value object, tagSet <TagSet object, tags 0:0:2>, namedValues <NamedValues object, enums noError=0, tooBig=1, noSuchName=...Writable=17, inconsistentName=18>, payload [noError]>, <Integer value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, <Integer value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>, payload [2147483647]>>>, payload [0]>, <VarBindList value object, tagSet=<TagSet object, tags 0:32:16>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, <Integer value object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>, payload [2147483647]>>>, componentType=<VarBind schema object, tagSet=<TagSet object, tags 0:32:16>, subtypeSpec=<ConstraintsIntersection object>, componentType=<NamedTypes object, types <NamedType object, type name=<ObjectName schema object, tagSet <TagSet object, tags 0:0:6>>>, <NamedType object, type =<_BindValue schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type value=<ObjectSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type simple=<SimpleSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type integer-value=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>>>, <NamedType object, type string-value=<OctetString schema object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, encoding iso-8859-1>>, <NamedType object, type objectID-value=<ObjectIdentifier schema object, tagSet <TagSet object, tags 0:0:6>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type application-wide=<ApplicationSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type ipAddress-value=<IpAddress schema object, tagSet <TagSet object, tags 64:0:0>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 4, 4>>, encoding iso-8859-1>>, <NamedType object, type counter-value=<Counter32 schema object, tagSet <TagSet object, tags 64:0:1>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type timeticks-value=<TimeTicks schema object, tagSet <TagSet object, tags 64:0:3>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type arbitrary-value=<Opaque schema object, tagSet <TagSet object, tags 64:0:4>, encoding iso-8859-1>>, <NamedType object, type big-counter-value=<Counter64 schema object, tagSet <TagSet object, tags 64:0:6>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 18446744073709551615>>>>, <NamedType object, type gauge32-value=<Gauge32 schema object, tagSet <TagSet object, tags 64:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type unSpecified=<Null value object, tagSet <TagSet object, tags 0:0:5>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload []>>, <NamedType object, type noSuchObject=<NoSuchObject value object, tagSet <TagSet object, tags 128:0:0>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Object c...ists at this OID]>>, <NamedType object, type noSuchInstance=<NoSuchInstance value object, tagSet <TagSet object, tags 128:0:1>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Instance...ists at this OID]>>, <NamedType object, type endOfMibView=<EndOfMibView value object, tagSet <TagSet object, tags 128:0:2>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No more variable...in this MIB View]>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>>, sizeSpec=<ConstraintsIntersection object>, payload [<VarBind value object, tagSet=<TagSet object, tags 0:32:16>, subtypeSpec=<ConstraintsIntersection object>, componentType=<NamedTypes object, types <NamedType object, type name=<ObjectName schema object, tagSet <TagSet object, tags 0:0:6>>>, <NamedType object, type =<_BindValue schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type value=<ObjectSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type simple=<SimpleSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type integer-value=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>>>, <NamedType object, type string-value=<OctetString schema object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, encoding iso-8859-1>>, <NamedType object, type objectID-value=<ObjectIdentifier schema object, tagSet <TagSet object, tags 0:0:6>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type application-wide=<ApplicationSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type ipAddress-value=<IpAddress schema object, tagSet <TagSet object, tags 64:0:0>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 4, 4>>, encoding iso-8859-1>>, <NamedType object, type counter-value=<Counter32 schema object, tagSet <TagSet object, tags 64:0:1>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type timeticks-value=<TimeTicks schema object, tagSet <TagSet object, tags 64:0:3>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type arbitrary-value=<Opaque schema object, tagSet <TagSet object, tags 64:0:4>, encoding iso-8859-1>>, <NamedType object, type big-counter-value=<Counter64 schema object, tagSet <TagSet object, tags 64:0:6>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 18446744073709551615>>>>, <NamedType object, type gauge32-value=<Gauge32 schema object, tagSet <TagSet object, tags 64:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type unSpecified=<Null value object, tagSet <TagSet object, tags 0:0:5>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload []>>, <NamedType object, type noSuchObject=<NoSuchObject value object, tagSet <TagSet object, tags 128:0:0>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Object c...ists at this OID]>>, <NamedType object, type noSuchInstance=<NoSuchInstance value object, tagSet <TagSet object, tags 128:0:1>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Instance...ists at this OID]>>, <NamedType object, type endOfMibView=<EndOfMibView value object, tagSet <TagSet object, tags 128:0:2>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No more variable...in this MIB View]>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>, payload [<ObjectName value object, tagSet <TagSet object, tags 0:0:6>, payload [1.3.6.1.2.1.1.3.0]>, <_BindValue value object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type value=<ObjectSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type simple=<SimpleSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type integer-value=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts -2147483648, 2147483647>>>>, <NamedType object, type string-value=<OctetString schema object, tagSet <TagSet object, tags 0:0:4>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>>, encoding iso-8859-1>>, <NamedType object, type objectID-value=<ObjectIdentifier schema object, tagSet <TagSet object, tags 0:0:6>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type application-wide=<ApplicationSyntax schema object, tagSet=<TagSet object, untagged>, subtypeSpec=<ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 1, 1>>, componentType=<NamedTypes object, types <NamedType object, type ipAddress-value=<IpAddress schema object, tagSet <TagSet object, tags 64:0:0>, subtypeSpec <ConstraintsIntersection object, consts <ValueSizeConstraint object, consts 0, 65535>, <ValueSizeConstraint object, consts 4, 4>>, encoding iso-8859-1>>, <NamedType object, type counter-value=<Counter32 schema object, tagSet <TagSet object, tags 64:0:1>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type timeticks-value=<TimeTicks schema object, tagSet <TagSet object, tags 64:0:3>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>, <NamedType object, type arbitrary-value=<Opaque schema object, tagSet <TagSet object, tags 64:0:4>, encoding iso-8859-1>>, <NamedType object, type big-counter-value=<Counter64 schema object, tagSet <TagSet object, tags 64:0:6>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 18446744073709551615>>>>, <NamedType object, type gauge32-value=<Gauge32 schema object, tagSet <TagSet object, tags 64:0:2>, subtypeSpec <ConstraintsIntersection object, consts <ValueRangeConstraint object, consts 0, 4294967295>>>>>, sizeSpec=<ConstraintsIntersection object>>>>, sizeSpec=<ConstraintsIntersection object>>>, <NamedType object, type unSpecified=<Null value object, tagSet <TagSet object, tags 0:0:5>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload []>>, <NamedType object, type noSuchObject=<NoSuchObject value object, tagSet <TagSet object, tags 128:0:0>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Object c...ists at this OID]>>, <NamedType object, type noSuchInstance=<NoSuchInstance value object, tagSet <TagSet object, tags 128:0:1>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No Such Instance...ists at this OID]>>, <NamedType object, type endOfMibView=<EndOfMibView value object, tagSet <TagSet object, tags 128:0:2>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload [No more variable...in this MIB View]>>>, sizeSpec=<ConstraintsIntersection object>, payload [<NoValue object>, <Null value object, tagSet <TagSet object, tags 0:0:5>, subtypeSpec <ConstraintsIntersection object, consts <SingleValueConstraint object, consts b''>>, encoding iso-8859-1, payload []>, <NoValue object>, <NoValue object>, <NoValue object>]>]>]>]>}
error
justinwubo commented 1 year ago

The oid I passed is '1.3.6.1.2.1.1.3.0', but why the pdu received is '1.3.6.1.2.1.11.32.0'?

justinwubo commented 1 year ago

I figured out what the problem is. The root cause was introduced by 'ContextData('mycontext')'. Pysnmp treat 'mycontext' as the context ID, while I want it as the context name.

So after change it to 'ContextData(contextName='mycontext'). The error was gone:)

@lextm the debug info really helps!