0
我似乎無法使用pysnmp獲取SNMP。
與python2和3相同的結果。
設備使用SNMP v2。Python PySNMP:無法獲取OID
SNMPv2-SMI::enterprises.5597.30.0.2.2 = No Such Object currently exists
at this OID
SNMPv2-SMI::enterprises.5597.30.0.2.4 = No Such Object currently exists
at this OID
雖然snmpwalk的正常工作:
snmpwalk -v1 -cpublic 10.0.1.8 1.3.6.1.4.1.5597.30.0.2.2
iso.3.6.1.4.1.5597.30.0.2.2.0 = INTEGER: 1
這是我的代碼:
from pysnmp.entity.rfc3413.oneliner import cmdgen
import time
SNMP_HOST = '10.0.1.8'
SNMP_PORT = 161
SNMP_COMMUNITY = 'public'
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData(SNMP_COMMUNITY),
cmdgen.UdpTransportTarget((SNMP_HOST, SNMP_PORT)),
'1.3.6.1.4.1.5597.30.0.2.2',
'1.3.6.1.4.1.5597.30.0.2.4'
)
# Check for errors and print out results
if errorIndication:
print(errorIndication)
else:
if errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex)-1] or '?'
)
)
else:
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
謝謝,現在我似乎回到了價值。有一個)在ObjectType(...)後缺少 – HyperDevil