本文整理汇总了Java中org.snmp4j.Snmp.addCommandResponder方法的典型用法代码示例。如果您正苦于以下问题:Java Snmp.addCommandResponder方法的具体用法?Java Snmp.addCommandResponder怎么用?Java Snmp.addCommandResponder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.snmp4j.Snmp
的用法示例。
在下文中一共展示了Snmp.addCommandResponder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startUp
import org.snmp4j.Snmp; //导入方法依赖的package包/类
@Override
public void startUp() throws IOException {
log.info("Snmp Trap Receiver Start");
log.info("listened on " + Configure.getInstance().getUdpTrapIpPort());
ThreadPool pool = ThreadPool.create(Const.THREAD_POOL_NAME, Const.AGENT_THREAD_NUM);
MultiThreadedMessageDispatcher dispatcher = new MultiThreadedMessageDispatcher(pool, new MessageDispatcherImpl());
Address listenAddress = GenericAddress.parse(Configure.getInstance().getUdpTrapIpPort());
TransportMapping transport = new DefaultUdpTransportMapping((UdpAddress) listenAddress);
// ����SNMP������ʹ�俪ʼ����
Snmp snmp = new Snmp(dispatcher, transport);
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
snmp.listen();
snmp.addCommandResponder(new CommandResponderImpl());
}
示例2: testTrapReceiverWithoutOpenNMS
import org.snmp4j.Snmp; //导入方法依赖的package包/类
public void testTrapReceiverWithoutOpenNMS() throws Exception {
System.out.println("SNMP4J: Register for Traps");
trapCount = 0;
Snmp snmp = new Snmp(new DefaultUdpTransportMapping(new UdpAddress(9162)));
snmp.addCommandResponder(this);
snmp.getUSM().addUser(
new OctetString("opennmsUser"),
new UsmUser(new OctetString("opennmsUser"), AuthMD5.ID, new OctetString("0p3nNMSv3"), PrivDES.ID, new OctetString("0p3nNMSv3")));
snmp.listen();
sendTraps();
System.out.println("SNMP4J: Unregister for Traps");
snmp.close();
System.out.println("SNMP4J: Checking Trap status");
assertEquals(2, trapCount);
}
示例3: start
import org.snmp4j.Snmp; //导入方法依赖的package包/类
public void start() throws Exception
{
snmp = new Snmp(new DefaultUdpTransportMapping(new UdpAddress(address, port)));
snmp.addCommandResponder(this);
snmp.listen();
}
示例4: MockProxy
import org.snmp4j.Snmp; //导入方法依赖的package包/类
public MockProxy(int port) throws IOException {
m_transport = new DefaultUdpTransportMapping(new UdpAddress(InetAddress.getLocalHost(), port));
m_snmp = new Snmp(m_transport);
m_snmp.addCommandResponder(this);
m_transport.listen();
}