- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试用 Java 实现 SNMP 代理。我使用 snmp4j 库 ( http://www.snmp4j.org/ )。目前,我的代理在 localhost/4700 上工作。由于以下请求,我尝试发送 snmpget 请求:
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1
但我只得到类似“此 OID 当前不存在此类实例”之类的信息这是我的问题:我不知道如何创建一个。我尝试向我的 MOTable 添加行,但它似乎不起作用。
这是我的类(class)实现 MOGRoup 的总结
public class MyMIB
//--AgentGen BEGIN=_EXTENDS
//--AgentGen END
implements MOGroup
//--AgentGen BEGIN=_IMPLEMENTS
//--AgentGen END
{
.
.
.
public static final OID oidTableEntry =
new OID(new int[] { 1,3,6,1,4,1,1,99,5,4,1,3,1 });
.
.
.
private void createTableEntry(MOFactory moFactory) {
// Index definition
.
.
.
// Table model
tableEntryModel =
moFactory.createTableModel(oidTableEntry,
tableEntryIndex,
tableEntryColumns);
((MOMutableTableModel)tableEntryModel).setRowFactory(
new TableEntryRowFactory());
tableEntry =
moFactory.createTable(oidTableEntry,
tableEntryIndex,
tableEntryColumns,
tableEntryModel);
//Adding rows
ArrayList<Integer> oidMon1List= new ArrayList<Integer>();
oidRow1List = this.getListFromArray(oidTableEntry.getValue());
oidRow1List.add(1);
ArrayList<Integer> oidMon2List= new ArrayList<Integer>();
oidRow2List = this.getListFromArray(oidTableEntry.getValue());
oidRow2List.add(2);
DefaultMOMutableTableModel model =
(DefaultMOMutableTableModel)tableEntry.getModel();
synchronized(model){
model.addRow(
model.createRow(
new OID(getArrayFromList(oidRow1List)),
new Variable[]{
new Integer32(123)
}));
model.addRow(
model.createRow(
new OID(getArrayFromList(oidRow2List)),
new Variable[]{
new Integer32(456)
}));
}
}
但是下面的请求仍然不起作用。
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1.0
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1.1
我一定不明白如何正确地创建行。你能解释一下我应该怎么做吗?
非常感谢!
稍微精确一点:我将这些行添加到我的程序中:
System.out.println("Get row count: " +tableEntryModel.getRowCount());
//first row
System.out.println("TEST1: " +model.getRow(new OID(new int[] {1,3,6,1,4,1,1,99,5,4,1,3,1,1})).getValue(0));
System.out.println("TEST2: " +tableEntry.getValue(new OID(new int[] {1,3,6,1,4,1,1,99,5,4,1,3,1,1,0})));
第一个返回:2(如预期)
第二个返回:123(符合预期)
第三个返回:null...这里,我不明白为什么!
最佳答案
我会说,代码和请求不匹配。我猜是代码的问题,因为在 SNMP4J-Agent 中,表单元格的实例 OID 由
<tableEntryOID>.<columnSubID>.<rowIndexOID>
因此,如果您的表对象具有 OID 1.3.6.1.4.1.1.99.5.4.1.3.1 并且您希望第一列中的第一个实例具有 ID 1,那么您必须创建/添加行:
model.addRow(
model.createRow(
new OID(1), new Variable[]{ new Integer32(123) }));
然后可以用
检索这个单元格snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1.1
关于java - Java 中的 SNMP 代理 : How adding new rows in MOTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12193882/
我正在尝试通过 SNMP 发送陷阱消息。 网上的例子提到了'sysUpTime'值的设置,但都没有说明。在这种情况下 sysUpTime 的作用是什么? 谢谢! 最佳答案 sysUpTime 是: T
我正在使用一些 SNMP 陷阱来监视应用程序。现在我被告知,如果陷阱中的属性顺序与 MIB 中定义的不同,某些监控系统可能会出现问题。由于 OID 的复杂性可以很容易地用于对属性进行重新排序,我对此感
我想使用 net-snmp 为 PowerPC 板实现 SNMP 代理。 以前它是使用 SMASH 实现的。 SMASH 有一个解析器 它可以读取 MIB 并生成 C 代码(空白函数实现) 我该如何开
在我的网络中,我想扫描启用 snmp 的设备。那么是否有任何单行 snmp 命令,以获取特定 IP 地址范围(如 172.26.1.1 到 172.26.1.255)中启用 snmp 的设备列表。 我
如何使用 C 或 C++ 和 net-snmp 模块接收陷阱。我需要示例代码,但示例位于 http://www.net-snmp.org/使用系统调用但不使用 API 方法。 最佳答案 net-snm
所以我还在学习SNMP,请放轻松。我正在使用 snmp4j,不仅是库,而且我已经加载了源代码,如果它满足我的需要,我不反对修改源代码。我已经编写了一个代理和一个测试客户端。我想要做的是能够检查来自测试
我正在尝试使用 SNMP 从 Brother MCF-9465CDN 获取碳粉量,以便最终使用 Munin 将它们绘制在图表中。我没有得到墨水量。 虽然我对 SNMP 有点陌生,但我认为我正在尝试的应
在我开始之前,我意识到这里已经有一些与 SNMP 相关的问题,但似乎没有多少人得到回答——这可能意味着我问错了地方,但我现在不知道还能去哪里. 这几天我一直在尽我所能阅读有关 SNMP 的内容,但我发
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
在我开始之前,我意识到这里已经有一些与 SNMP 相关的问题,但似乎没有多少人得到回答——这可能意味着我问错了地方,但我现在不知道还能去哪里. 这几天我一直在尽我所能阅读有关 SNMP 的内容,但我发
我可以快速完成 snmp 安装,它工作正常。 在我目前正在研究并尝试修改源的代理模块之一中。我遇到了一个问题,我需要通过代理删除用户。 坚持完成这个: 就像 net-snmp-create-v3-us
去年在我看来,找到一个网页,其中有使用 SNMP 设置工作中心 5755 公共(public)地址簿(姓名、电子邮件)的示例。 现在我的 google-fu 有点生锈了,你能帮帮我吗? 是否有标准化的
如果我试图找到安装了 openWRT 的 Linksys WRT54G 的路由表,我需要哪个 MIB? 最佳答案 那应该是 MIB II。 SNMP 对象 ID (OID) 是 .1.3.6.1.2.
我对 SNMP 有一点了解,但还不够。我需要开发一个可以读取标准 SNMP MIB 并读取/写入各种属性的应用程序。网络端没问题,但实际的 MIB 以及它们可能包含的确切内容对我来说是一种黑色艺术。
我是 SNMP 新手。我必须培养一个经理。我一直在寻找如何为经理编程。我遇到过 WinSNMP、SNMP++ 和 Net-SNMP。 Net-SNMP 的优点是它可以转换来自 MIB 的陷阱内容(它可
在软件定义的网络中,有些东西我仍然没有得到:在传统网络中,我们使用 CLI 或 NETCONF 或者 SNMP 来配置设备,在 SDN 中,我们使用 Openflow 来这样做,但是检索信息呢? 之前
在软件定义的网络中,有些东西我仍然没有得到:在传统网络中,我们使用 CLI 或 NETCONF 或者 SNMP 来配置设备,在 SDN 中,我们使用 Openflow 来这样做,但是检索信息呢? 之前
我正在尝试使用 snmp4j 模拟 SNMP 代理。 我正在尝试向代理注册 MO。 下面是代码片段: static final OID mo1= new OID("1.3.6.1.4.1.1234.1
我希望在 Java 中使用 SNMP 为项目设置监控。我环顾四周,发现了一些软件包:JBossSNMPAdapter和SNMP4J-Agent。我不确定这两者之间有什么区别。 最佳答案 SNMP4j-
我是一名优秀的程序员,十分优秀!