Search in sources :

Example 1 with SnmpPeer

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);
        }
    }
}
Also used : SnmpAdaptorServer(com.sun.jmx.snmp.daemon.SnmpAdaptorServer) SnmpParameters(com.sun.jmx.snmp.SnmpParameters) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ListenerNotFoundException(javax.management.ListenerNotFoundException) SnmpPeer(com.sun.jmx.snmp.SnmpPeer)

Aggregations

SnmpParameters (com.sun.jmx.snmp.SnmpParameters)1 SnmpPeer (com.sun.jmx.snmp.SnmpPeer)1 SnmpAdaptorServer (com.sun.jmx.snmp.daemon.SnmpAdaptorServer)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 ListenerNotFoundException (javax.management.ListenerNotFoundException)1