/** * Return a read only instance of the parameters, which consists of the overall service parameters, * plus various other Collection specific parameters (e.g. storeByNodeID etc) * * @return A read only Map instance */ public ServiceParameters getServiceParameters() { return new ServiceParameters(Collections.unmodifiableMap(m_parameters)); }
private boolean isPersistDisabled() { return m_params != null && m_params.getParameters().containsKey("storing-enabled") && "false".equals(m_params.getParameters().get("storing-enabled")); }
@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; }
/** * <p>toString</p> * * @return a {@link java.lang.String} object. */ @Override public String toString() { return "domain: " + getDomain() + ", " + "storeByNodeID: " + getStoreByNodeID() + ", " + "storeByIfAlias: " + getStoreByIfAlias() + ", " + "storeFlagOverride: " + getStorFlagOverride() + ", " + "ifAliasComment: " + getIfAliasComment(); }
public boolean forceStoreByAlias(String alias) { if(alias == null || alias.equals("")) { return false; } String comment = getIfAliasComment(); int si = -1; if( comment != null && !comment.equals("")) { si = alias.indexOf(comment); } //if ifAlias begins with comment, return false if (si == 0) { return false; } return overrideStorageFlag(); }
/** {@inheritDoc} */ @Override public SnmpCollectionResource findAliasedResource(SnmpInstId inst, String ifAlias) { Integer key = inst.toInt(); AliasedResource resource = (AliasedResource) m_aliasedIfs.get(key); if (resource == null) { IfInfo ifInfo = (IfInfo)m_ifResourceType.findResource(inst); if(ifInfo == null) { LOG.info("Not creating an aliased resource for ifInfo = null"); } else { LOG.info("Creating an aliased resource for {}", ifInfo); resource = new AliasedResource(this, m_params.getDomain(), ifInfo, m_params.getIfAliasComment(), ifAlias); m_aliasedIfs.put(key, resource); } } return resource; }
/** * Test override of read community string and max repetitions in Collectd configuration parameters */ @Test public void testOverrides() { Map<String, Object> map = new HashMap<String, Object>(); map.put("max-repetitions", "11"); map.put("read-community", "notPublic"); ServiceParameters params = new ServiceParameters(map); int reps = params.getSnmpMaxRepetitions(6); assertEquals("Overriding max repetitions failed.", 11, reps); params = new ServiceParameters(map); map.remove("max-repetitions"); map.put("maxRepetitions", "11"); assertEquals("Overriding max repetitions failed.", 11, reps); String s = params.getSnmpReadCommunity("public"); assertEquals("Overriding read community failed.", "notPublic", s); map.remove("read-community"); map.put("readCommunity", "notPublic"); params = new ServiceParameters(map); s = params.getSnmpReadCommunity("public"); assertEquals("Overriding read community failed.", "notPublic", s); }
public CollectionSet collect(CollectionAgent agent, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig();
/** * <p>getName</p> * * @return a {@link java.lang.String} object. */ public String getName() { return m_params.getCollectionName(); }
public boolean aliasesEnabled() { return getStoreByIfAlias().equals("true"); }
/** * <p>getSnmpMaxRepetitions</p> * * @param current a int. * @return a int. */ public int getSnmpMaxRepetitions(int current) { return m_params.getSnmpMaxRepetitions(current); }
/** * <p>getSnmpReadCommunity</p> * * @param current a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ public String getSnmpReadCommunity(String current) { return m_params.getSnmpReadCommunity(current); }
@Override public CollectionSet collect(CollectionAgent agent, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig();
m_repository=m_spec.getRrdRepository(m_params.getCollectionName());
/** * <p>Constructor for CollectorThresholdingSet.</p> * * @param nodeId a int. * @param hostAddress a {@link java.lang.String} object. * @param serviceName a {@link java.lang.String} object. * @param repository a {@link org.opennms.netmgt.rrd.RrdRepository} object. * @param svcParams a {@link org.opennms.netmgt.collection.api.ServiceParameters} object. * @throws ThresholdInitializationException */ public CollectorThresholdingSet(int nodeId, String hostAddress, String serviceName, RrdRepository repository, ServiceParameters svcParams, ResourceStorageDao resourceStorageDao) throws ThresholdInitializationException { super(nodeId, hostAddress, serviceName, repository); m_resourceStorageDao = resourceStorageDao; String storeByIfAliasString = svcParams.getStoreByIfAlias(); storeByIfAlias = storeByIfAliasString != null && "true".equalsIgnoreCase(storeByIfAliasString); this.svcParams = svcParams; }
/** * Return a read only instance of the parameters, which consists of the overall service parameters, * plus various other Collection specific parameters (e.g. storeByNodeID etc) * * @return A read only Map instance */ public ServiceParameters getServiceParameters() { return new ServiceParameters(Collections.unmodifiableMap(m_parameters)); }
boolean checkDisableForceRescan(final String disabledString) { final Map<String, Object> parameters = m_snmpCollection.getServiceParameters().getParameters(); final String src = ParameterMap.getKeyedString(parameters, "disableForceRescan", null); return ((src != null) && (src.toLowerCase().equals("all") || src.toLowerCase().equals(disabledString))); }
@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; }
private NodeResourceType createNodeResourceType(SnmpCollectionAgent agent) { MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig(); OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient); return new NodeResourceType(agent, collection); }
public int getSnmpVersion(int current) { String version = ParameterMap.getKeyedString(getParameters(), ParameterName.VERSION.toString(), null); if (version != null) { if (version.equals("v1")) { return SnmpAgentConfig.VERSION1; } else if (version.equals("v2c")) { return SnmpAgentConfig.VERSION2C; } else if (version.equals("v3")) { return SnmpAgentConfig.VERSION3; } } return current; }