无法用于外部设备的MIB。
我有一个IP电源条,可以使用SNMP进行控制。我正在尝试使用Python脚本关闭和打开电源。我在d:\ mib中保存了新的mib 我试图将OID设置为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'))))
我遇到错误 追溯(最近一次通话):
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
答案 0 :(得分:0)
首先,只要您使用裸OID和值(这就是您要做的),就不需要SNMP的MIB 。
如果要将OID设置为值 0 ,则以下受管对象规范应生成您可能需要的SNMP SET PDU:
ObjectType(ObjectIdentity('1.3.6.1.4.1.13742.6.4.1.2.1.2.1.3'), 0)
如果要使用MIB,则应使用addAsn1MibSource方法,但应将其传递给valid URL。