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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations