【发布时间】:2017-06-05 13:48:37
【问题描述】:
我正在尝试创建一个 SNMP4j 代理,但发现很难正确理解该过程。我已经成功创建了一个可以使用 snmpwalk 从命令行查询的代理。我遇到的困难是理解我应该如何更新存储在我实现的 MIB 中的值。
以下显示了我用于创建 MIB 的相关代码(我实现了 Host-Resources-MIB)
agent = new Agent("0.0.0.0/" + port);
agent.start();
agent.unregisterManagedObject(agent.getSnmpv2MIB());
modules = new Modules(DefaultMOFactory.getInstance());
HrSWRunEntryRow thisRow = modules.getHostResourcesMib().getHrSWRunEntry()
.createRow(oidHrSWRunEntry);
final OID ashEnterpriseMIB = new OID(".1.3.6.1.4.1.49266.0");
thisRow.setHrSWRunIndex(new Integer32(1));
thisRow.setHrSWRunName(new OctetString("RunnableAgent"));
thisRow.setHrSWRunID(ashEnterpriseMIB);
thisRow.setHrSWRunPath(new OctetString("All is good in the world")); // Max 128 characters
thisRow.setHrSWRunParameters(new OctetString("Everything is working")); // Max 128 characters
thisRow.setHrSWRunType(new Integer32(HrSWRunTypeEnum.application));
thisRow.setHrSWRunStatus(new Integer32(HrSWRunStatusEnum.running));
modules.getHostResourcesMib().getHrSWRunEntry().addRow(thisRow);
agent.registerManagedObject(modules.getHostResourcesMib());
这似乎足以创建一个可运行的代理。我不明白我要如何更改存储在 MIB 中的值(例如,我如何更改 HrSWRunStatus 的值)。似乎有一些杂乱无章的方式,但它们似乎不适合图书馆的编写方式。
我遇到过很多关于使用/覆盖方法的参考
- 准备
- 提交
- 撤消
- 清理
但找不到执行此操作的任何示例。任何帮助将不胜感激。
【问题讨论】:
标签: java network-programming snmp snmp4j