本文整理汇总了Java中com.sun.jmx.snmp.SnmpParameters.setRdCommunity方法的典型用法代码示例。如果您正苦于以下问题:Java SnmpParameters.setRdCommunity方法的具体用法?Java SnmpParameters.setRdCommunity怎么用?Java SnmpParameters.setRdCommunity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jmx.snmp.SnmpParameters
的用法示例。
在下文中一共展示了SnmpParameters.setRdCommunity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendTrap
import com.sun.jmx.snmp.SnmpParameters; //导入方法依赖的package包/类
private synchronized void sendTrap(SnmpOid trap, SnmpVarBindList list) {
final Iterator<NotificationTarget> iterator = notificationTargets.iterator();
final SnmpAdaptorServer adaptor =
(SnmpAdaptorServer) getSnmpAdaptor();
if (adaptor == null) {
log.error("sendTrap", "Cannot send trap: adaptor is null.");
return;
}
if (!adaptor.isActive()) {
log.config("sendTrap", "Adaptor is not active: trap not sent.");
return;
}
while(iterator.hasNext()) {
NotificationTarget target = null;
try {
target = iterator.next();
SnmpPeer peer =
new SnmpPeer(target.getAddress(), target.getPort());
SnmpParameters p = new SnmpParameters();
p.setRdCommunity(target.getCommunity());
peer.setParams(p);
log.debug("handleNotification", "Sending trap to " +
target.getAddress() + ":" + target.getPort());
adaptor.snmpV2Trap(peer, trap, list, null);
}catch(Exception e) {
log.error("sendTrap",
"Exception occurred while sending trap to [" +
target + "]. Exception : " + e);
log.debug("sendTrap",e);
}
}
}
示例2: sendTrap
import com.sun.jmx.snmp.SnmpParameters; //导入方法依赖的package包/类
private synchronized void sendTrap(SnmpOid trap, SnmpVarBindList list) {
final Iterator iterator = notificationTargets.iterator();
final SnmpAdaptorServer adaptor =
(SnmpAdaptorServer) getSnmpAdaptor();
if (adaptor == null) {
log.error("sendTrap", "Cannot send trap: adaptor is null.");
return;
}
if (!adaptor.isActive()) {
log.config("sendTrap", "Adaptor is not active: trap not sent.");
return;
}
while(iterator.hasNext()) {
NotificationTarget target = null;
try {
target = (NotificationTarget) iterator.next();
SnmpPeer peer =
new SnmpPeer(target.getAddress(), target.getPort());
SnmpParameters p = new SnmpParameters();
p.setRdCommunity(target.getCommunity());
peer.setParams(p);
log.debug("handleNotification", "Sending trap to " +
target.getAddress() + ":" + target.getPort());
adaptor.snmpV2Trap(peer, trap, list, null);
}catch(Exception e) {
log.error("sendTrap",
"Exception occured while sending trap to [" +
target + "]. Exception : " + e);
log.debug("sendTrap",e);
}
}
}