无法访问外部设备的MIB。
我有一个IP电源条,可以使用SNMP控制。我正在尝试使用Python脚本关闭和打开插座。我已在d:\mib中保存了新的mib,我正尝试将OID的on设置为0。我调用setCmd函数如下
errorIndication, errorStatus, errorIndex, varBinds = next(setCmd(SnmpEngine(),CommunityData('write_public'),UdpTransportTarget(('xx.xx.xx.xx', 161)),ContextData(),ObjectType(ObjectIdentity('1.3.6.1.4.1.13742.6.4.1.2.1.2.1.3',0).addAsn1MibSource('d:/mib'))))
我收到错误Traceback(最近的调用最后):
File "<pyshell#11>", line 1, in <module>
errorIndication, errorStatus, errorIndex, varBinds = next(setCmd(SnmpEngine(),CommunityData('write_public'),UdpTransportTarget(('xx.xxx.xx.x', 161)),ContextData(),ObjectType(ObjectIdentity('SNMPv2-MIB','1.3.6.1.4.1.13742.6.4.1.2.1.2.1.3',0).addAsn1MibSource('d:/mib'))))
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysnmp\hlapi\asyncore\sync\cmdgen.py", line 217, in setCmd
lookupMib=options.get('lookupMib', True)))
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysnmp\hlapi\asyncore\cmdgen.py", line 241, in setCmd
contextData.contextName, vbProcessor.makeVarBinds(snmpEngine, varBinds),
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysnmp\hlapi\varbinds.py", line 39, in makeVarBinds
__varBinds.append(varBind.resolveWithMib(mibViewController))
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysnmp\smi\rfc1902.py", line 847, in resolveWithMib
self.__args[0].resolveWithMib(mibViewController)
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysnmp\smi\rfc1902.py", line 368, in resolveWithMib
ifNotAdded=self.__asn1SourcesOptions.get('ifNotAdded')
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysnmp\smi\compiler.py", line 55, in addMibCompiler
compiler.addSources(*getReadersFromUrls(*kwargs.get('sources') or defaultSources))
File "C:\Users\mahemad\AppData\Local\Programs\Python\Python37\lib\site-packages\pysmi\reader\url.py", line 68, in getReadersFromUrls
raise error.PySmiError('Unsupported URL scheme %s' % sourceUrl)
pysmi.error.PySmiError: Unsupported URL scheme d:/mib
2条答案
按热度按时间nhhxz33t1#
首先,只要您使用裸OID和值(您似乎就是这样做的),SNMP就不需要MIBs。
如果要将该OID设置为值 0,则以下托管对象规范应生成您可能需要的SNMP SET PDU:
如果你想使用MIB,你应该添加Asn1MibSource方法,但是传递给它一个valid URL。
14ifxucb2#
必须指定设置的值的类型,我正在考虑如何添加mibs ...如果不添加mibs,它不会产生任何重大差异,它只是用于print语句。