简体   繁体   English

如何遍历带有名称而不是数字的SNMP / MIB树(snmp4j)

[英]How can I traverse SNMP/MIB tree with names and not the numbers (snmp4j)

I am tying to understand snmp; 我想了解snmp; I was able to run the example at http://www.shivasoft.in/blog/java/snmp/create-snmp-client-in-java-using-snmp4j/ to traverse the SNMP tree and get the following results 我可以在http://www.shivasoft.in/blog/java/snmp/create-snmp-client-in-java-using-snmp4j/上运行该示例,以遍历SNMP树并获得以下结果

    1.3.6.1.2.1.1.1.0 : OCTET STRING : Hardware: Intel64 Family  bla bla bla
    1.3.6.1.2.1.1.2.0 : OBJECT IDENTIFIER : 1.3.6.1.4.1.311.1.1.3.1.1
    1.3.6.1.2.1.1.3.0 : TimeTicks : 2 days, 0:56:16.59
    1.3.6.1.2.1.1.4.0 : OCTET STRING : 
    1.3.6.1.2.1.1.5.0 : OCTET STRING : KASHILI-LTP.internal.harmonia.com
    1.3.6.1.2.1.1.6.0 : OCTET STRING : 
    1.3.6.1.2.1.1.7.0 : Integer32 : 76

The numbers in format 1.3.6.1.xx are going to be the keys into hashmap; 1.3.6.1.xx格式的数字将成为哈希映射的关键; I want to make these numbers more user friendly. 我想使这些数字更加人性化。 How would I do that? 我该怎么做? May be I can pass MIB file to my java code(?). 可能是我可以将MIB文件传递给我的Java代码(?)。 I want the output where all the numbers 1.3.6.xx are replaced with actual names so that I know what they are (in Linux shell, I can get that effect by passing -m switch to snmpwalk) 我想要将所有数字1.3.6.xx替换为实际名称的输出,以便知道它们是什么(在Linux Shell中,我可以通过将-m switch传递到snmpwalk来获得效果)

The numeric OIDs always have a translation into names, defined in a MIB file, as you've already realized. 正如您已经意识到的那样,数字OID总是可以转换为名称,在MIB文件中定义。 The snmpwalk command (from net-snmp) is able to load MIB files and display the human-readable variable names. snmpwalk命令(来自net-snmp)能够加载MIB​​文件并显示人类可读的变量名。 If you walk some more equipment, however, you will soon discover that many machines use MIBs that even net-snmp doesn't know about. 但是,如果您多走一些设备,您很快就会发现许多机器使用的甚至是net-snmp都不知道的MIB。 You can download those MIB files and load them into net-snmp (see net-snmp documentation). 您可以下载这些MIB文件并将其加载到net-snmp中(请参阅net-snmp文档)。

Sadly, snmp4j does not support MIB loading in its free version. 遗憾的是,snmp4j在其免费版本中不支持MIB加载。 There seems to be a commercially available library from the same vendor, called SMIPro , which seems like it could do what you need. 似乎有来自同一供应商的商用库,称为SMIPro ,它似乎可以满足您的需求。 I haven't tried it, though. 我还没有尝试过。 They seem to have a trial license available if you want. 如果您愿意,他们似乎有可用的试用许可证。

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

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