>>> errorIndication, errorStatus, errorIndex, varBinds = next(
... getCmd(SnmpEngine(),
... CommunityData('testing'),
... UdpTransportTarget(('127.0.0.1', 17020)),
... ContextData(),
... ObjectType(ObjectIdentity('FSS-COMMON-SMI', 'fssCommon', '100.1.1.0').addAsn1MibSource('http://rtx-swtl-git.xyz.net.local/projects/TYREPO/repos/xyz_base_yang_repo/browse/src/util/snmp/@mib@')))
... )
该路径是git repo路径。我缺少什么?
raise error.MibNotFoundError('%s compilation error(s): %s' % (modName, errs))
pysnmp.smi.error.MibNotFoundError: FSS-COMMON-SMI compilation error(s): Illegal character '<', 21913 characters left unparsed at this stage at MIB FSS-COMMON-SMI, line 1
如果我通过在本地手动处理mibs并使用mibdump.py编译它来执行相同的操作,那么它可以正常工作。
python /local/python/2.7.8/bin/mibdump.py ./FSS-SYSTEM.mib
.....
Try various filenames while searching for MIB module: yes
Created/updated MIBs: FSS-SYSTEM
Pre-compiled MIBs borrowed:
Up to date MIBs: FSS-COMMON-SMI, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
Missing source MIBs:
Ignored MIBs:
Failed MIBs:
#
如果将所有围兜从url路径复制到本地工作正常:
{abc@cins}$ ls /data//users/sbhattac/MIBS/XYZ/
FSS-COMMON-LOG.mib FSS-COMMON-SMI.mib FSS-COMMON-TC.mib FSS-SYSTEM.mib
如果在本地工作中复制相同的mib:
>>> from pysnmp.hlapi import *
>>> errorIndication, errorStatus, errorIndex, varBinds = next(
... getCmd(SnmpEngine(),
... CommunityData('testing'),
... UdpTransportTarget(('127.0.0.1', 17020)),
... ContextData(),
... ObjectType(ObjectIdentity('FSS-COMMON-SMI', 'fssCommon', '100.1.1.0').addAsn1MibSource('/data/users/sbhattac/MIBS/XYZ/', '/usr/share/snmp/')))
之前:
ls
IPV6-TC.py IPV6-TC.pyc
后:
{abc@cin}$ ls
FSS-COMMON-SMI.py FSS-COMMON-SMI.pyc IPV6-TC.py IPV6-TC.pyc
正如伊利亚所说:
{abc@cin}$ python /local/python/2.7.8/bin/mibdump.py --rebuild --mib-source http://rtx-swtl-git.xyz.net.local/projects/TYREPO/repos/xyz_base_yang_repo/browse/src/util/snmp/@mib@ --mib-source /usr/share/snmp/ FSS-SYSTEM
Source MIB repositories: /usr/share/snmp/, http://rtx-swtl-git.xyz.net.local/projects/TYREPO/repos/fujitsu_base_yang_repo/browse/src/util/snmp/@mib@
Borrow missing/failed MIBs from: http://mibs.snmplabs.com/pysnmp/notexts/@mib@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: /home/sbhattac/.pysnmp/mibs
MIBs excluded from code generation: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMP-FRAMEWORK-MIB, SNMP-TARGET-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM, TRANSPORT-ADDRESS-MIB
MIBs to compile: FSS-SYSTEM
Destination format: pysnmp
Parser grammar cache directory: not used
Also compile all relevant MIBs: yes
Rebuild MIBs regardless of age: yes
Do not create/update MIBs: no
Byte-compile Python modules: yes (optimization level 0)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Try various filenames while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs:
Missing source MIBs:
Ignored MIBs:
Failed MIBs: FSS-SYSTEM (Illegal character '<', 21893 characters left unparsed at this stage at MIB FSS-SYSTEM, line 1)
答案 0 :(得分:0)
感觉就像是MIB编译错误(FSS-COMMON-SMI)而不是搜索路径问题。请尝试mibdump.py
,如下所示:
$ mibdump.py --rebuild --mib-source http://rtx-swtl-git.xyz.net.local/projects/TYREPO/repos/xyz_base_yang_repo/browse/src/util/snmp/@mib@' --mib-source /usr/share/snmp/mibs FSS-SYSTEM
在你的mibdump.py
运行中,它没有重新编译FSS-COMMON-SMI
MIB,因为它以某种方式找到了以前编译的那个。
确保您拥有这些MIB的单一版本 - 可能会发生pysmi库使用不同结果的不同MIB,这让您感到困惑。您可以启用pysmi调试到mibdump.py
和/或在pysnmp中查看它从哪里获取MIB(例如mibdump.py --debug reader,searcher ...
)。 --help
显示更多调试选项。
答案 1 :(得分:0)
对于git repo原始文件路径需要提供浏览路径。喜欢 http://rtx-swtl-git.xyz.net.local/projects/TYREPO/repos/xyz_base_yang_repo/的原始强> / SRC / util的/ SNMP / MIB @ @