0
我正在嘗試創建SNMP4j代理,並且發現很難正確理解此過程。我成功創建了一個可以使用snmpwalk從命令行查詢的代理。我遇到的困難是理解我是如何更新存儲在我實現的MIB中的值的。如何正確更新SNMP4j代理MIB值
下圖顯示了相關的代碼我用來創建的MIB(我實現了主機資源-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的值)。似乎有一些kludge方式,但他們似乎不符合圖書館的寫作方式。
我所遇到多次提到利用/覆蓋的方法
- 準備
- 提交
- 撤消
- 清理
但是找不到在哪裏,這是做任何的例子。任何幫助將受到感謝。