/** * <p>getOwnerName</p> * * @return a {@link java.lang.String} object. */ @Override public final String getOwnerName() { return m_agent.getHostAddress(); }
private String getHostAddress() { return m_agent.getHostAddress(); }
/** * <p>getOwnerName</p> * * @return a {@link java.lang.String} object. */ @Override public String getOwnerName() { return getCollectionAgent().getHostAddress(); }
private PackageDefinition getPackageFor(AdapterDefinition protocol, CollectionAgent agent) { try { Optional<PackageDefinition> value = cache.get(new CacheKey(protocol.getName(), agent.getHostAddress())); return value.orElse(null); } catch (ExecutionException e) { LOG.error("Error while retrieving package from Cache: {}.", e.getMessage(), e); throw new RuntimeException(e); } }
private Package getPackageFor(Protocol protocol, CollectionAgent agent) { try { Optional<Package> value = cache.get(new CacheKey(protocol.getName(), agent.getHostAddress())); return value.orElse(null); } catch (ExecutionException e) { LOG.error("Error while retrieving package from Cache: {}.", e.getMessage(), e); throw new RuntimeException(e); } }
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); // Retrieve the name of the JMX data collector final String collectionName = ParameterMap.getKeyedString(parameters, ParameterName.COLLECTION.toString(), serviceName); final JmxCollection jmxCollection = m_jmxDataCollectionConfigDao.getJmxCollection(collectionName); if (jmxCollection == null) { throw new IllegalArgumentException(String.format("JMXCollector: No collection found with name '%s'.", collectionName)); } runtimeAttributes.put(JMX_COLLECTION_KEY, jmxCollection); // Retrieve the agent config. final Map<String, String> parameterStringMap = new HashMap<String, String>(); for (Map.Entry<String, Object> eachEntry : parameters.entrySet()) { if (eachEntry.getValue() instanceof String) { parameterStringMap.put(eachEntry.getKey(), (String) eachEntry.getValue()); } } final MBeanServer mBeanServer = JmxUtils.getMBeanServer(m_jmxConfigDao, agent.getHostAddress(), parameterStringMap); if (mBeanServer != null) { runtimeAttributes.put(JMX_MBEAN_SERVER_KEY, mBeanServer); } return runtimeAttributes; }
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); // Retrieve the name of the JMX data collector final String collectionName = ParameterMap.getKeyedString(parameters, ParameterName.COLLECTION.toString(), serviceName); final JmxCollection jmxCollection = m_jmxDataCollectionConfigDao.getJmxCollection(collectionName); if (jmxCollection == null) { throw new IllegalArgumentException(String.format("JMXCollector: No collection found with name '%s'.", collectionName)); } runtimeAttributes.put(JMX_COLLECTION_KEY, jmxCollection); // Retrieve the agent config. final Map<String, String> parameterStringMap = new HashMap<String, String>(); for (Map.Entry<String, Object> eachEntry : parameters.entrySet()) { if (eachEntry.getValue() instanceof String) { parameterStringMap.put(eachEntry.getKey(), (String) eachEntry.getValue()); } } final MBeanServer mBeanServer = JmxUtils.getMBeanServer(m_jmxConfigDao, agent.getHostAddress(), parameterStringMap); if (mBeanServer != null) { runtimeAttributes.put(JMX_MBEAN_SERVER_KEY, mBeanServer); } return runtimeAttributes; }
/** * <p>release</p> * * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. */ public void release(CollectionAgent agent) { m_instrumentation.beginCollectorRelease(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); m_instrumentation.endCollectorRelease(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); }
/** * This method is responsible for building a Capsd forceRescan event object * and sending it out over the EventProxy. */ void sendForceRescanEvent() { // Log4j category LOG.debug("generateForceRescanEvent: interface = {}", getAgent().getHostAddress()); // Send event via EventProxy try { getEventProxy().send(createForceRescanEvent()); } catch (EventProxyException e) { LOG.error("generateForceRescanEvent: Unable to send forceRescan event.", e); } }
/** * <p>release</p> * * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. */ public void release(CollectionAgent agent) { m_instrumentation.beginCollectorRelease(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); m_instrumentation.endCollectorRelease(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); }
@Override public CollectionSet collect(CollectionAgent agent, Map<String, Object> parameters) throws CollectionException { try { String collectionName = ParameterMap.getKeyedString(parameters, "collection", null); if (collectionName == null) { collectionName = ParameterMap.getKeyedString(parameters, "tca-collection", null); } if (collectionName == null) { throw new CollectionException("Parameter collection is required for the TCA Collector!"); } TcaCollectionHandler collectionHandler = new TcaCollectionHandler((SnmpCollectionAgent)agent, getRrdRepository(collectionName), m_resourceStorageDao, m_resourceTypesDao, m_locationAwareSnmpClient); return collectionHandler.collect(); } catch (CollectionException e) { throw e; } catch (Throwable t) { LOG.error("Unexpected error during node TCA collection for: {}", agent.getHostAddress(), t); throw new CollectionException("Unexpected error during node TCA collection for: " + agent.getHostAddress() + ": " + t, t); } }
/** * <p>initialize</p> * * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. */ public void initialize(CollectionAgent agent) throws CollectionInitializationException { m_instrumentation.beginCollectorInitialize(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); try { m_collector.validateAgent(agent, getPropertyMap()); } finally { m_instrumentation.endCollectorInitialize(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); } }
/** * <p>createWalker</p> * * @return a {@link org.opennms.netmgt.snmp.SnmpWalker} object. */ protected SnmpWalker createWalker() { CollectionAgent agent = getCollectionAgent(); return SnmpUtils.createWalker(getAgentConfig(), "SnmpCollectors for " + agent.getHostAddress(), getTracker()); }
/** * Parses the URL. * * <p>Additional placeholders:</p> * <ul> * <li><b>step</b>, The Collection Step in seconds</li> * </ul> * * @param unformattedUrl the unformatted URL * @param agent the collection agent * @param collectionStep the collection step (in seconds) * @param parameters the service parameters * @return the string * * @throws IllegalArgumentException the illegal argument exception */ @Override public String parseUrl(final NodeDao nodeDao, final String unformattedUrl, final CollectionAgent agent, final Integer collectionStep, final Map<String,String> parameters) throws IllegalArgumentException { final OnmsNode node = nodeDao.get(agent.getNodeId()); return parseString("URL", unformattedUrl, node, agent.getHostAddress(), collectionStep, parameters); }
/** * Parses the URL. * * <p>Additional placeholders:</p> * <ul> * <li><b>step</b>, The Collection Step in seconds</li> * </ul> * * @param unformattedUrl the unformatted URL * @param agent the collection agent * @param collectionStep the collection step (in seconds) * @param parameters the service parameters * @return the string * * @throws IllegalArgumentException the illegal argument exception */ @Override public String parseUrl(final NodeDao nodeDao, final String unformattedUrl, final CollectionAgent agent, final Integer collectionStep, final Map<String,String> parameters) throws IllegalArgumentException { final OnmsNode node = nodeDao.get(agent.getNodeId()); return parseString("URL", unformattedUrl, node, agent.getHostAddress(), collectionStep, parameters); }
(outageFactory.isInterfaceInOutage(agent.getHostAddress(), outageName))) LOG.debug("scheduledOutage: configured outage '{}' applies, interface {} will not be collected for {}", outageName, agent.getHostAddress(), this); outageFound = true; break;
/** * <p>initialize</p> * * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. */ public void initialize(CollectionAgent agent) throws CollectionInitializationException { m_instrumentation.beginCollectorInitialize(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); try { m_collector.validateAgent(agent, getPropertyMap()); } finally { m_instrumentation.endCollectorInitialize(m_package.getName(), agent.getNodeId(), agent.getHostAddress(), m_svcName); } }
(outageFactory.isInterfaceInOutage(agent.getHostAddress(), outageName))) LOG.debug("scheduledOutage: configured outage '{}' applies, interface {} will not be collected for {}", outageName, agent.getHostAddress(), this); outageFound = true; break;
/** * Parses the request. * * @param unformattedRequest the unformatted request * @param agent the agent * @param collectionStep the collection step * @param parameters the service parameters * @return the request * @throws IllegalArgumentException the illegal argument exception */ @Override public Request parseRequest(final NodeDao nodeDao, final Request unformattedRequest, final CollectionAgent agent, final Integer collectionStep, final Map<String,String> parameters) throws IllegalArgumentException { if (unformattedRequest == null) return null; final OnmsNode node = nodeDao.get(agent.getNodeId()); final Request request = new Request(); request.setMethod(unformattedRequest.getMethod()); for (Header header : unformattedRequest.getHeaders()) { request.addHeader(header.getName(), parseString(header.getName(), header.getValue(), node, agent.getHostAddress(), collectionStep, parameters)); } for (Parameter param : unformattedRequest.getParameters()) { request.addParameter(param.getName(), parseString(param.getName(), param.getValue(), node, agent.getHostAddress(), collectionStep, parameters)); } final Content cnt = unformattedRequest.getContent(); if (cnt != null) request.setContent(new Content(cnt.getType(), parseString("Content", cnt.getData(), node, agent.getHostAddress(), collectionStep, parameters))); return request; }
/** * Parses the request. * * @param unformattedRequest the unformatted request * @param agent the agent * @param collectionStep the collection step * @param parameters the service parameters * @return the request * @throws IllegalArgumentException the illegal argument exception */ @Override public Request parseRequest(final NodeDao nodeDao, final Request unformattedRequest, final CollectionAgent agent, final Integer collectionStep, final Map<String,String> parameters) throws IllegalArgumentException { if (unformattedRequest == null) return null; final OnmsNode node = nodeDao.get(agent.getNodeId()); final Request request = new Request(); request.setMethod(unformattedRequest.getMethod()); for (Header header : unformattedRequest.getHeaders()) { request.addHeader(header.getName(), parseString(header.getName(), header.getValue(), node, agent.getHostAddress(), collectionStep, parameters)); } for (Parameter param : unformattedRequest.getParameters()) { request.addParameter(param.getName(), parseString(param.getName(), param.getValue(), node, agent.getHostAddress(), collectionStep, parameters)); } final Content cnt = unformattedRequest.getContent(); if (cnt != null) request.setContent(new Content(cnt.getType(), parseString("Content", cnt.getData(), node, agent.getHostAddress(), collectionStep, parameters))); return request; }