Examples of SnmpAdaptorServer


Examples of com.sun.jmx.snmp.daemon.SnmpAdaptorServer

        } catch (UnknownHostException e) {
            throw new AgentConfigurationError(UNKNOWN_SNMP_INTERFACE, e, e.getMessage());
        }

        // Create adaptor
        final SnmpAdaptorServer adaptor =
            new SnmpAdaptorServer(acl, port, address);
        adaptor.setUserDataFactory(new JvmContextFactory());
        adaptor.setTrapPort(trapPort);

        // Create MIB
        //
        final JVM_MANAGEMENT_MIB_IMPL mib = new JVM_MANAGEMENT_MIB_IMPL();
        try {
            mib.init();
        } catch (IllegalAccessException x) {
            throw new AgentConfigurationError(SNMP_MIB_INIT_FAILED, x, x.getMessage());
        }

        // Configure the trap destinations.
        //
        mib.addTargets(getTargetList(acl,trapPort));


        // Start Adaptor
        //
        try {
            // Will wait until the adaptor starts or fails to start.
            // If the adaptor fails to start, a CommunicationException or
            // an InterruptedException is thrown.
            //
            adaptor.start(Long.MAX_VALUE);
        } catch (Exception x) {
            Throwable t=x;
            if (x instanceof com.sun.jmx.snmp.daemon.CommunicationException) {
                final Throwable next = t.getCause();
                if (next != null) t = next;
            }
            throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED, t,
                                              address + ":" + port,
                                              "(" + t.getMessage() + ")");
        }

        // double check that adaptor is actually started (should always
        // be active, so that exception should never be thrown from here)
        //
        if (!adaptor.isActive()) {
            throw new AgentConfigurationError(SNMP_ADAPTOR_START_FAILED,
                                              address + ":" + port);
        }

        try {
            // Add MIB to adaptor
            //
            adaptor.addMib(mib);

            // Add Adaptor to the MIB
            //
            mib.setSnmpAdaptor(adaptor);
        } catch (RuntimeException x) {
            new AdaptorBootstrap(adaptor,mib).terminate();
            throw x;
        }

        log.debug("initialize",
                  Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.initialize1"));
        log.config("initialize",
                   Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.initialize2",
                                 address.toString(), java.lang.Integer.toString(adaptor.getPort())));
        return new AdaptorBootstrap(adaptor,mib);
    }
View Full Code Here

Examples of com.sun.jmx.snmp.daemon.SnmpAdaptorServer

        emitter.addNotificationListener(handler, null, null);
    }

    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);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.