use of com.sun.jmx.snmp.SnmpPeer in project jdk8u_jdk by JetBrains.
the class JVM_MANAGEMENT_MIB_IMPL method sendTrap.
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);
}
}
}
Aggregations