/** * Builds target resource. * @param context Process context */ private void buildTargetResource(ProcessContext context) { if((this.transportMapping == null) || !this.transportMapping.isListening() || (this.snmp == null)) { try { this.transportMapping = new DefaultUdpTransportMapping(); this.snmp = new Snmp(this.transportMapping); if("SNMPv3".equals(context.getProperty(SNMP_VERSION).getValue())) { USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); SecurityModels.getInstance().addSecurityModel(usm); } this.transportMapping.listen(); } catch (Exception e) { throw new IllegalStateException("Failed to initialize UDP transport mapping", e); } } if (this.snmpTarget == null) { this.snmpTarget = this.createSnmpTarget(context); } if (this.targetResource == null) { this.targetResource = this.finishBuildingTargetResource(context); } }
snmp = new Snmp( transMap );
public SnmpHelper(String address, String community) { _target = new CommunityTarget(); _target.setCommunity(new OctetString(community)); _target.setVersion(SnmpConstants.version2c); _target.setAddress(new UdpAddress(address)); try { _snmp = new Snmp(new DefaultUdpTransportMapping()); } catch (IOException e) { _snmp = null; throw new CloudRuntimeException(" Error in crearting snmp object, " + e.getMessage()); } }
/** * Creates the SNMP session to be used for this agent. * * @param dispatcher * the message dispatcher to be associated with the session. * @return * a SNMP session (a {@link Snmp} instance by default). */ protected Session createSnmpSession(MessageDispatcher dispatcher) { return new Snmp(dispatcher); }
/** * Creates the SNMP session to be used for this agent. * * @param dispatcher * the message dispatcher to be associated with the session. * * @return a SNMP session (a {@link Snmp} instance by default). */ protected Session createSnmpSession(MessageDispatcher dispatcher) { return new Snmp(dispatcher); }
public void initSnmp4J(TransportMapping transportMapping) throws IOException { if (target == null) return; // no execution.. maybe throw exception snmp4J = new Snmp(transportMapping); snmp4J.listen(); }
private void initSession(){ this.session = new Snmp(dispatcher); for (int i = 0; i < transportMappings.length;i++){ try{ session.addTransportMapping(transportMappings[i]); } catch(Exception e){ log.warn("Tranport mapping invalid. Failed to initialize mapping '"+ transportMappings[i]+"' with: "+e.getMessage()); } } this.session.addCommandResponder(responder); }
private void initSession(){ this.session = new Snmp(dispatcher); for (int i = 0; i < transportMappings.length;i++){ try{ session.addTransportMapping(transportMappings[i]); } catch(Exception e){ log.warn("Tranport mapping invalid. Failed to initialize mapping '"+ transportMappings[i]+"' with: "+e.getMessage()); } } this.session.addCommandResponder(responder); }
public SNMPProvider(String address) { try { this.address = address; TransportMapping transport = new DefaultUdpTransportMapping(); this.snmp = new Snmp(transport); transport.listen(); } catch (IOException e) { throw new RuntimeException(e); } }
private org.snmp4j.Snmp createSnmp() { try { // Create a new session and define it's transport. return new org.snmp4j.Snmp(new DefaultUdpTransportMapping()); } catch (IOException e) { throw new NotificationServiceException("error creating " + getClass().getName()); } }
private void start() throws IOException { TransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); // Do not forget this line! transport.listen(); }
protected void initSnmpSession() { session = new Snmp(dispatcher); for (TransportMapping<? extends Address> transportMapping : transportMappings) { try { session.addTransportMapping(transportMapping); } catch (Exception ex) { logger.warn("Failed to initialize transport mapping '" + transportMapping + "' with: " + ex.getMessage()); } } updateSession(session); }
protected void initSnmpSession() { session = new Snmp(dispatcher); for (int i=0; i<transportMappings.length; i++) { try { session.addTransportMapping(transportMappings[i]); } catch (Exception ex) { logger.warn("Failed to initialize transport mapping '"+ transportMappings[i]+"' with: "+ex.getMessage()); } } updateSession(session); }
@Override public final boolean start() { try { snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.listen(); } catch (IOException e) { log(Level.ERROR, e, "Discovery SNMP listener failed to start: %s", e.getMessage()); } return true; }
@Override public synchronized void activate() throws Exception { super.activate(); // load connection data only if the endpoint is enabled if (isEnabled()) { logger.debug("Activating endpoint"); this.listenGenericAddress = GenericAddress.parse(this.address); this.transport = new DefaultUdpTransportMapping((UdpAddress) this.listenGenericAddress); this.snmp = new Snmp(transport); snmp.addCommandResponder(this); } }
/** * <p>init.</p> * * @throws java.io.IOException if any. */ public void init() throws IOException { TransportMapping transportMapping = transportMappingAbstractFactory.createTransportMapping(transportLocalIpAddress); MessageDispatcher messageDispatcher = messageDispatcherFactory.createMessageDispatcherMapping(); snmp = new Snmp(messageDispatcher, transportMapping); doInit(); transportMapping.listen(); }
public boolean start() { boolean started = false; try { snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.listen(); started = true; } catch (IOException e) { log(Level.ERROR, e, "SNMP UDP Transport Mapping not started: %s", e); snmp = null; } return started; }
public void registerForTraps(TrapNotificationListener listener, TrapProcessorFactory processorFactory, int snmpTrapPort) throws IOException { RegistrationInfo info = new RegistrationInfo(listener, snmpTrapPort); Snmp4JTrapNotifier m_trapHandler = new Snmp4JTrapNotifier(listener, processorFactory); info.setHandler(m_trapHandler); TransportMapping transport = new DefaultUdpTransportMapping(new UdpAddress(snmpTrapPort)); info.setTransportMapping(transport); Snmp snmp = new Snmp(transport); snmp.addCommandResponder(m_trapHandler); info.setSession(snmp); s_registrations.put(listener, info); snmp.listen(); }
public MockProxy(int port) throws IOException { // Set socket option SO_REUSEADDR so that we can bind to the port even if it // has recently been closed by passing 'true' as the second argument here. m_transport = new DefaultUdpTransportMapping(new UdpAddress(InetAddress.getLocalHost(), port), true); m_snmp = new Snmp(m_transport); m_snmp.addCommandResponder(this); m_transport.listen(); }
public void start () throws IOException { this.address = GenericAddress.parse ( this.connectionInformation.getAddress () ); this.transport = new DefaultUdpTransportMapping (); this.snmp = new Snmp ( this.transport ); //MPv3 mpv3 = (MPv3)_snmp.getMessageProcessingModel ( MessageProcessingModel.MPv3 ); final USM usm = new USM ( SecurityProtocols.getInstance (), new OctetString ( MPv3.createLocalEngineID () ), 0 ); SecurityModels.getInstance ().addSecurityModel ( usm ); this.snmp.listen (); }