使用 SNMP4j 和 Java 的多个 SNMP 代理
我正在尝试创建一个 snmp 代理模拟器应用程序,它将创建多个具有唯一 IP 地址和端口的虚拟代理。我正在尝试使用 snmp4jagent。但我有一些例外,你能帮我吗?
我将 BaseAgent 类扩展为我自己的类,然后创建该类的多个实例。但我无法一次启动多个代理,即。如果一个代理的状态正在运行,我无法在不停止正在运行的代理的情况下启动另一个代理(代码太重,所以我在这里不指定任何代码)启动代理的代码是
public void start() throws IOException
{
init();
addShutdownHook();
getServer().addContext(new OctetString("public"));
finishInit();
run();
sendColdStartNotification();
}
然后我注册托管对象。
代码参考: http://shivasoft.in/ blog/java/snmp/creating-snmp-agent-server-in-java-using-snmp4j/
提前感谢
Pramod
I'm trying to create a snmp agent simulator application, that will create multiple virtual agents with unique ip address and port. I'm trying to use snmp4jagent. But i've some exceptions can you help me ?
I extend BaseAgent class to my own class then create Multiple Instance of that class. But I cannot start More than one agent at a time ie. if One agent's status is running i cannot start another agent without stopping the running agent (Code is too heavy So i don't specify any code here) code for starting an agent is
public void start() throws IOException
{
init();
addShutdownHook();
getServer().addContext(new OctetString("public"));
finishInit();
run();
sendColdStartNotification();
}
then i register Managed objects .
Code reference :
http://shivasoft.in/blog/java/snmp/creating-snmp-agent-server-in-java-using-snmp4j/
Thanks in advance
Pramod
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它确实有效(经测试)。也许您没有为不同的实例分配不同的 IP 地址。将其添加到您的类中:
您可能必须将使用的 IP 地址添加到您的 NIC 中。 Linux 示例:
如果您仍然无法启动第二个代理,还请提供异常消息和堆栈跟踪。
It actually does work (as tested). Maybe you did not assign different IP addresses to your different instances. Add this to your class:
You probably have to add the used ip addresses to your NIC. Example for Linux:
Please also provide exception messages and stacktraces if you still can't start asecond agent.