pysnmp转换(.my)到(.py)问题。为什么总是要我安装包?

时间:2017-09-18 13:09:04

标签: python failed-installation pysnmp

我正在使用Linux v.16

我成功安装了pysnmp软件包。我正在尝试将.my转换为.py,但我遇到错误:

1  使用此命令:smidump -f python custom-mib.my | libsmi2pysnmp>custom-mib.py

输出结果为:

smidump: module 'custom-mib' contains errors, expect flawed output
smidump: aborting due to severe parsing errors
smidump: use the -k option to force continuation
The program 'libsmi2pysnmp' is currently not installed.
            You can install it by typing: apt install python-pysnmp4

(该软件包已经安装。为了确保,当我应用命令apt install python-pysnmp4时,结果为" python-pysnmp4 is already the newest version"

2 当我使用命令build-pysnmp-mib -o custom-mib.py custom-mib.my时, 我面临同样的错误,说要安装相同的软件包。

1 个答案:

答案 0 :(得分:1)

你在运行什么pysnmp版本?它已超过4.3.x(包括),您不需要手动进行任何MIB转换 - 它是pysnmp / pysmi包相互作用的全部being done automatically。您在查询中只是pass pysnmp MIB name - 它应该可以完成其余的工作。

如果您无法升级到最新的pysnmp版本,则可以使用pysmi软件包中的mibdump工具代替(长时间过时)smidump / build-pysnmp-mib / {。}}工具集将.my转换为.py和pass those .py MIBs到您原来的pysnmp实例。

以下是一个示例libsmi2pysnmp工具调用,它将mibdump.py转换为pysnmp类:

IF-MIB

除非您更改默认目标目录,否则编译后的MIB将以$ pip install pysmi ... $ mibdump.py --mib-source /my/mib/dir \ --mib-source http://mibs.snmplabs.com/asn1/@mib@ \ --destination-format pysnmp \ IF-MIB Source MIB repositories: /my/mib/dir, http://mibs.snmplabs.com/asn1/@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/user/.pysnmp/mibs MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, 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: IF-MIB Destination format: pysnmp Parser grammar cache directory: not used Also compile all relevant MIBs: yes Rebuild MIBs regardless of age: no Dry run mode: no Create/update MIBs: yes Byte-compile Python modules: yes (optimization level no) Ignore compilation errors: no Generate OID->MIB index: no Generate texts in MIBs: no Keep original texts layout: no Try various file names while searching for MIB module: yes Created/updated MIBs: IANAifType-MIB, IF-MIB Pre-compiled MIBs borrowed: Up to date MIBs: SNMPv2-CONF, SNMPv2-MIB, SNMPv2-SMI, SNMPv2-TC Missing source MIBs: Ignored MIBs: Failed MIBs: 结尾。