Search in sources :

Example 1 with Parameter

use of org.opennms.netmgt.config.collectd.Parameter in project opennms by OpenNMS.

the class CollectionSpecification method initializeParameters.

private void initializeParameters() {
    final Map<String, Object> m = new TreeMap<String, Object>();
    m.put(ParameterName.SERVICE.toString(), m_svcName);
    m.put(ParameterName.SERVICE_INTERVAL.toString(), getService().getInterval().toString());
    StringBuilder sb;
    Collection<Parameter> params = getService().getParameters();
    for (Parameter p : params) {
        if (LOG.isDebugEnabled()) {
            sb = new StringBuilder();
            sb.append("initializeParameters: adding service: ");
            sb.append(getServiceName());
            sb.append(" parameter: ");
            sb.append(p.getKey());
            sb.append(" of value ");
            sb.append(p.getValue());
            LOG.debug(sb.toString());
        }
        m.put(p.getKey(), p.getValue());
    }
    if (storeByIfAlias() != null && isTrue(storeByIfAlias())) {
        m.put("storeByIfAlias", "true");
        if (storeByNodeId() != null) {
            if (isTrue(storeByNodeId())) {
                m.put("storeByNodeID", "true");
            } else if (isFalse(storeByNodeId())) {
                m.put("storeByNodeID", "false");
            } else {
                m.put("storeByNodeID", "normal");
            }
        }
        if (ifAliasDomain() != null) {
            m.put("domain", ifAliasDomain());
        } else {
            m.put("domain", getPackageName());
        }
        if (storeFlagOverride() != null && isTrue(storeFlagOverride())) {
            m.put("storFlagOverride", "true");
        }
        m.put("ifAliasComment", ifAliasComment());
        if (LOG.isDebugEnabled()) {
            sb = new StringBuilder();
            sb.append("ifAliasDomain = ");
            sb.append(ifAliasDomain());
            sb.append(", storeByIfAlias = ");
            sb.append(storeByIfAlias());
            sb.append(", storeByNodeID = ");
            sb.append(storeByNodeId());
            sb.append(", storFlagOverride = ");
            sb.append(storeFlagOverride());
            sb.append(", ifAliasComment = ");
            sb.append(ifAliasComment());
            LOG.debug(sb.toString());
        }
    }
    m.put("packageName", m_package.getName());
    m_parameters = m;
}
Also used : Parameter(org.opennms.netmgt.config.collectd.Parameter) TreeMap(java.util.TreeMap)

Example 2 with Parameter

use of org.opennms.netmgt.config.collectd.Parameter in project opennms by OpenNMS.

the class UiModel method createParameter.

/**
 * Creates a Parameter object and sets the key and value.
 *
 * @param key
 * The key for the Parameter object. Should not be null.
 * @param value
 * The value for the Parameter object. Should not be null.
 * @return The Parameter object with key value according to method
 * arguments.
 */
private static Parameter createParameter(final String key, final String value) {
    Parameter parameter = new Parameter();
    parameter.setKey(key);
    parameter.setValue(value);
    return parameter;
}
Also used : Parameter(org.opennms.netmgt.config.collectd.Parameter)

Example 3 with Parameter

use of org.opennms.netmgt.config.collectd.Parameter in project opennms by OpenNMS.

the class CollectdIntegrationTest method createGetPackagesExpectation.

private void createGetPackagesExpectation(OnmsMonitoredService svc) {
    String rule = "ipaddr = '" + str(svc.getIpAddress()) + "'";
    // EasyMock.expect(m_filterDao.getActiveIPAddressList(rule)).andReturn(Collections.singletonList(svc.getIpAddress()));
    final Package pkg = new Package();
    pkg.setName("testPackage");
    Filter filter = new Filter();
    filter.setContent(rule);
    pkg.setFilter(filter);
    final Service collector = new Service();
    collector.setName("SNMP");
    collector.setStatus("on");
    collector.setInterval(3000l);
    Parameter parm = new Parameter();
    parm.setKey(TEST_KEY_PARM_NAME);
    parm.setValue(m_key);
    collector.setParameters(Collections.singletonList(parm));
    pkg.addService(collector);
    EasyMock.expect(m_collectdConfiguration.getPackages()).andReturn(Collections.singletonList(pkg));
    EasyMock.expect(m_collectdConfigFactory.interfaceInPackage(anyObject(OnmsIpInterface.class), eq(pkg))).andReturn(true);
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Example 4 with Parameter

use of org.opennms.netmgt.config.collectd.Parameter in project opennms by OpenNMS.

the class CollectionSpecification method initializeParameters.

private void initializeParameters() {
    final Map<String, Object> m = new TreeMap<String, Object>();
    m.put(ParameterName.SERVICE.toString(), m_svcName);
    m.put(ParameterName.SERVICE_INTERVAL.toString(), getService().getInterval().toString());
    StringBuffer sb;
    Collection<Parameter> params = getService().getParameters();
    for (Parameter p : params) {
        if (LOG.isDebugEnabled()) {
            sb = new StringBuffer();
            sb.append("initializeParameters: adding service: ");
            sb.append(getServiceName());
            sb.append(" parameter: ");
            sb.append(p.getKey());
            sb.append(" of value ");
            sb.append(p.getValue());
            LOG.debug(sb.toString());
        }
        m.put(p.getKey(), p.getValue());
    }
    if (storeByIfAlias() != null && isTrue(storeByIfAlias())) {
        m.put("storeByIfAlias", "true");
        if (storeByNodeId() != null) {
            if (isTrue(storeByNodeId())) {
                m.put("storeByNodeID", "true");
            } else if (isFalse(storeByNodeId())) {
                m.put("storeByNodeID", "false");
            } else {
                m.put("storeByNodeID", "normal");
            }
        }
        if (ifAliasDomain() != null) {
            m.put("domain", ifAliasDomain());
        } else {
            m.put("domain", getPackageName());
        }
        if (storeFlagOverride() != null && isTrue(storeFlagOverride())) {
            m.put("storFlagOverride", "true");
        }
        m.put("ifAliasComment", ifAliasComment());
        if (LOG.isDebugEnabled()) {
            sb = new StringBuffer();
            sb.append("ifAliasDomain = ");
            sb.append(ifAliasDomain());
            sb.append(", storeByIfAlias = ");
            sb.append(storeByIfAlias());
            sb.append(", storeByNodeID = ");
            sb.append(storeByNodeId());
            sb.append(", storFlagOverride = ");
            sb.append(storeFlagOverride());
            sb.append(", ifAliasComment = ");
            sb.append(ifAliasComment());
            LOG.debug(sb.toString());
        }
    }
    m.put("packageName", m_package.getName());
    m_parameters = m;
}
Also used : Parameter(org.opennms.netmgt.config.collectd.Parameter) TreeMap(java.util.TreeMap)

Example 5 with Parameter

use of org.opennms.netmgt.config.collectd.Parameter in project opennms by OpenNMS.

the class CollectdTest method getCollectionPackageThatMatchesSNMP.

private static Package getCollectionPackageThatMatchesSNMP() {
    Package pkg = new Package();
    pkg.setName("pkg");
    Filter filter = new Filter();
    filter.setContent("IPADDR IPLIKE *.*.*.*");
    pkg.setFilter(filter);
    Service svc = new Service();
    pkg.addService(svc);
    svc.setName("SNMP");
    svc.setStatus("on");
    Parameter parm = new Parameter();
    parm.setKey("collection");
    parm.setValue("default");
    svc.addParameter(parm);
    parm = new Parameter();
    parm.setKey("thresholding-enabled");
    parm.setValue("true");
    svc.addParameter(parm);
    svc.setStatus("on");
    return pkg;
}
Also used : Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Aggregations

Parameter (org.opennms.netmgt.config.collectd.Parameter)10 Filter (org.opennms.netmgt.config.collectd.Filter)6 Service (org.opennms.netmgt.config.collectd.Service)6 Package (org.opennms.netmgt.config.collectd.Package)5 TreeMap (java.util.TreeMap)3 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)3 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)3 CollectionSpecification (org.opennms.netmgt.collection.core.CollectionSpecification)2 DefaultCollectdInstrumentation (org.opennms.netmgt.collection.core.DefaultCollectdInstrumentation)2 CollectdConfiguration (org.opennms.netmgt.config.collectd.CollectdConfiguration)2 File (java.io.File)1 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Before (org.junit.Before)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 InsufficientInformationException (org.opennms.core.utils.InsufficientInformationException)1 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)1 DefaultServiceCollectorRegistry (org.opennms.netmgt.collection.support.DefaultServiceCollectorRegistry)1