@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); final String collectionName = ParameterMap.getKeyedString(parameters, "collection", null); if (collectionName == null) { throw new IllegalArgumentException("Collector configuration does not include the required 'collection' parameter."); } final Collection collection = m_wsManDataCollectionConfigDao.getCollectionByName(collectionName); if (collection == null) { throw new IllegalArgumentException("No collection found with name: " + collectionName); } final OnmsNode node = m_nodeDao.get(agent.getNodeId()); if (node == null) { throw new IllegalArgumentException("Could not find node with id: " + agent.getNodeId()); } final Definition agentConfig = m_wsManConfigDao.getAgentConfig(agent.getAddress()); final Groups groups = new Groups(m_wsManDataCollectionConfigDao.getGroupsForAgent(collection, agent, agentConfig, node)); runtimeAttributes.put(WSMAN_AGENT_CONFIG_KEY, agentConfig); runtimeAttributes.put(WSMAN_GROUPS_KEY, groups); 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); }
public CollectionAgentDTO(CollectionAgent agent) { Objects.requireNonNull(agent); for (String attribute : agent.getAttributeNames()) { setAttribute(attribute, agent.getAttribute(attribute)); } address = agent.getAddress(); storeByForeignSource = agent.isStoreByForeignSource(); nodeId = agent.getNodeId(); nodeLabel = agent.getNodeLabel(); foreignSource = agent.getForeignSource(); foreignId = agent.getForeignId(); location = agent.getLocationName(); setStorageResourcePath(agent.getStorageResourcePath()); sysUpTime = agent.getSavedSysUpTime(); }
protected static ResourcePath createStorageResourcePath(CollectionAgent agent) { Objects.requireNonNull(agent); return createStorageResourcePath(agent.getForeignSource(), agent.getForeignId(), agent.getNodeId()); }
/** * <p>Constructor for NodeInfo.</p> * * @param def a {@link org.opennms.netmgt.collectd.NodeResourceType} object. * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. */ public NodeInfo(NodeResourceType def, CollectionAgent agent) { super(def); m_agent = agent; m_nodeId = agent.getNodeId(); }
/** * This is the main method of the class. An instance is normally enqueued on * the scheduler which checks its <code>isReady</code> method to determine * execution. If the instance is ready for execution then it is started with * it's own thread context to execute the query. The last step in the method * before it exits is to reschedule the interface. */ @Override public void run() { Logging.withPrefix(Collectd.LOG4J_CATEGORY, () -> { Logging.putThreadContext("service", m_spec.getServiceName()); Logging.putThreadContext("ipAddress", m_agent.getAddress().getHostAddress()); Logging.putThreadContext("nodeId", Integer.toString(m_agent.getNodeId())); Logging.putThreadContext("nodeLabel", m_agent.getNodeLabel()); Logging.putThreadContext("foreignSource", m_agent.getForeignSource()); Logging.putThreadContext("foreignId", m_agent.getForeignId()); doRun(); }); }
/** * <p>getOwnerName</p> * * @return a {@link java.lang.String} object. */ @Override public final String getOwnerName() { return m_agent.getHostAddress(); }
/** * <p>getAddress</p> * * @return a {@link java.net.InetAddress} object. */ public InetAddress getAddress() { return m_agent.getAddress(); }
XmpAgentConfig peerConfig = XmpPeerFactory.getInstance().getAgentConfig(agent.getAddress()); authenUser = peerConfig.getAuthenUser(); timeout = (int)peerConfig.getTimeout(); final NodeLevelResource nodeLevelResource = new NodeLevelResource(agent.getNodeId()); oldUptime = agent.getSavedSysUpTime(); LOG.debug("collect: attempting to open XMP session with {}:{},{}", agent.getAddress(), xmpPort, authenUser); session = new XmpSession(sockopts, agent.getAddress(), xmpPort,authenUser); LOG.debug("XMP collect finished for {}, uptime for {} is {}", collectionName, agent, agent.getSavedSysUpTime());
.withNodeId(agent.getNodeId()) .withLocation(agent.getLocationName()) .withSystemId(systemId) .withServiceAttributes(attributes)
/** * Gets the collection resource. * * @param agent the collection agent * @param instance the resource instance * @param resourceType the resource type * @param timestamp the timestamp * @return the collection resource */ protected Resource getCollectionResource(CollectionAgent agent, String instance, String resourceType, Date timestamp) { final NodeLevelResource nodeResource = new NodeLevelResource(agent.getNodeId()); if (CollectionResource.RESOURCE_TYPE_NODE.equalsIgnoreCase(resourceType)) { return nodeResource; } else { DeferredGenericTypeResource resource = new DeferredGenericTypeResource(nodeResource, resourceType, FALLBACK_RESOURCE_TYPE_NAME, instance); if (timestamp != null) { LOG.debug("getCollectionResource: the date that will be used when updating the RRDs is {}", timestamp); resource.setTimestamp(timestamp); } return resource; } }
private String getHostAddress() { return m_agent.getHostAddress(); }
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); final ServiceParameters serviceParams = new ServiceParameters(parameters); final String collectionName = serviceParams.getCollectionName(); final NsclientCollection collection = NSClientDataCollectionConfigFactory.getInstance().getNSClientCollection(collectionName); if (collection == null) { throw new IllegalArgumentException(String.format("NSClientCollector: No collection found with name '%s'.", collectionName)); } runtimeAttributes.put(NSCLIENT_COLLECTION_KEY, collection); final NSClientAgentConfig agentConfig = NSClientPeerFactory.getInstance().getAgentConfig(agent.getAddress()); runtimeAttributes.put(NSCLIENT_AGENT_CONFIG_KEY, agentConfig); return runtimeAttributes; }
protected static ResourcePath createStorageResourcePath(CollectionAgent agent) { Objects.requireNonNull(agent); return createStorageResourcePath(agent.getForeignSource(), agent.getForeignId(), agent.getNodeId()); }
.withNodeId(agent.getNodeId()) .withLocation(agent.getLocationName()) .withSystemId(systemId) .withServiceAttributes(attributes)
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); final String collectionName = ParameterMap.getKeyedString(parameters, "collection", null); if (collectionName == null) { throw new IllegalArgumentException("Collector configuration does not include the required 'collection' parameter."); } final Collection collection = m_wsManDataCollectionConfigDao.getCollectionByName(collectionName); if (collection == null) { throw new IllegalArgumentException("No collection found with name: " + collectionName); } final OnmsNode node = m_nodeDao.get(agent.getNodeId()); if (node == null) { throw new IllegalArgumentException("Could not find node with id: " + agent.getNodeId()); } final Definition agentConfig = m_wsManConfigDao.getAgentConfig(agent.getAddress()); final Groups groups = new Groups(m_wsManDataCollectionConfigDao.getGroupsForAgent(collection, agent, agentConfig, node)); runtimeAttributes.put(WSMAN_AGENT_CONFIG_KEY, agentConfig); runtimeAttributes.put(WSMAN_GROUPS_KEY, groups); 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); }
/** * <p>toString</p> * * @return a {@link java.lang.String} object. */ // NMS-5062: Avoid call getLabel here, otherwise the SiblingColumnStorageStrategy will fail if DEBUG is enabled for Collectd. @Override public String toString() { return "node["+getCollectionAgent().getNodeId() + "]." + getResourceTypeName() + "[" + getInstance() + "]"; }
/** * <p>getOwnerName</p> * * @return a {@link java.lang.String} object. */ @Override public String getOwnerName() { return getCollectionAgent().getHostAddress(); }
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); final ServiceParameters serviceParams = new ServiceParameters(parameters); final String collectionName = serviceParams.getCollectionName(); final NsclientCollection collection = NSClientDataCollectionConfigFactory.getInstance().getNSClientCollection(collectionName); if (collection == null) { throw new IllegalArgumentException(String.format("NSClientCollector: No collection found with name '%s'.", collectionName)); } runtimeAttributes.put(NSCLIENT_COLLECTION_KEY, collection); final NSClientAgentConfig agentConfig = NSClientPeerFactory.getInstance().getAgentConfig(agent.getAddress()); runtimeAttributes.put(NSCLIENT_AGENT_CONFIG_KEY, agentConfig); return runtimeAttributes; }