简体   繁体   English

如何使用 mibdump.py 生成不同名称的 pysnmp MIB?

[英]How to generate pysnmp MIB with different name using mibdump.py?

I am trying to generate the custom MIB to pysnmp MIB using mibdump.py utility.我正在尝试使用 mibdump.py 实用程序生成自定义 MIB 到 pysnmp MIB。 I have MIB's with different names MY-CUSTOM-MIB, EXAMPLE-MIB.我有不同名称的 MIB,如 MY-CUSTOM-MIB、EXAMPLE-MIB。 When i am trying to generate the pysnmp MIB for these MIBs, it is always generating the PYSNMP MIBS with name as MY-MIB.py.当我尝试为这些 MIB 生成 pysnmp MIB 时,它总是生成名为 MY-MIB.py 的 PYSNMP MIBS。

mibdump.py --destination-format=pysnmp --destination-directory=`pwd` ./MY-CUSTOM-MIB
mibdump.py --destination-format=pysnmp --destination-directory=`pwd` ./EXAMPLE-MIB

Output:
   MY-MIB.py

Expecting Output as
  EXAMPLE-MIB.py
  MY-CUSTOM-MIB.py

Could any throw some ideas to generate MIB with actual name rather than MY-MIB.任何人都可以抛出一些想法来生成具有实际名称而不是 MY-MIB 的 MIB。

The name mibdump uses for output file name is taken literally from MIB module definition, which is inside the MIB file. mibdump用于输出文件名的名称从字面上取自 MIB 模块定义,它位于 MIB 文件中。

That makes sense, for example, if other MIBs want to import your MIB as a dependency, they can only do that by canonical MIB name because that's the only thing present in the IMPORT statement.这是有道理的,例如,如果其他 MIB 想要将您的 MIB 作为依赖项导入,他们只能通过规范 MIB 名称来执行此操作,因为这是 IMPORT 语句中唯一存在的内容。

If you place MY-MIB into a file named EXAMPLE-MIB.txt , some additional map would be required to find your non-canonically named MIB by its canonical name.如果您将MY-MIB放入名为EXAMPLE-MIB.txt的文件中,则需要一些额外的映射才能通过其规范名称找到非规范命名的MIB。 Perhaps some SNMP implementations might have such mapping facilities, but some do not.也许一些 SNMP 实现可能有这样的映射设施,但有些没有。

That makes me think that it's best to have exactly the same name for the MIB module and MIB file.这让我认为最好为 MIB 模块和 MIB 文件使用完全相同的名称。

However, it's indeed possible (and quite easy, it seems) to teach mibdump to reuse the original file name where the MIB is read from.但是,确实可以(而且似乎很容易)教mibdump重用从中读取 MIB 的原始文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM