use of org.opennms.nrtg.api.model.CollectionJob in project opennms by OpenNMS.
the class CollectionJobListener method onMessage.
@Override
public void onMessage(Message message) {
try {
// FIXME abstraction between technology and job handling is missing
CollectionJob collectionJob = (CollectionJob) simpleMessageConverter.fromMessage(message);
collectionJob = protocolCollectorRegistry.getProtocolCollector(collectionJob.getService()).collect(collectionJob);
Date finishedTimestamp = new Date();
collectionJob.setFinishedTimestamp(finishedTimestamp);
Map<String, MeasurementSet> measurementSets = collectionJob.getMeasurementSetsByDestination();
int val = counter.incrementAndGet();
if (val % 1000 == 0) {
logger.debug("processed job #{}, {} measurement set(s)", val, measurementSets.size());
} else {
logger.trace("processed job #{}, {} measurement set(s)", val, measurementSets.size());
}
for (String destinationString : measurementSets.keySet()) {
jmsTemplate.convertAndSend(destinationString, measurementSets.get(destinationString));
logger.info("** sending msg '{}' to '{}'", measurementSets.get(destinationString), destinationString);
}
LightweightMeasurementSet errorMeasurementSet = new LightweightMeasurementSet(collectionJob.getNodeId(), collectionJob.getService(), collectionJob.getNetInterface(), collectionJob.getFinishedTimestamp());
for (String metricId : collectionJob.getAllMetrics()) {
if (collectionJob.getMetricValue(metricId) == null) {
errorMeasurementSet.addMeasurement(metricId, collectionJob.getMetricType(metricId), null, collectionJob.getOnmsLogicMetricId(metricId));
}
logger.trace("collected metric of job #{}='{}'", counter + ": " + metricId, collectionJob.getMetricValue(metricId));
}
if (errorMeasurementSet.getMeasurements().size() > 0) {
logger.warn("result set of job #{} contains {} null values", counter, errorMeasurementSet.getMeasurements().size());
jmsTemplate.convertAndSend("error", errorMeasurementSet);
logger.trace("** sending to 'error'");
}
} catch (JMSException ex) {
logger.error(ex.getMessage());
// FIXME react, don't continue
} catch (MessageConversionException ex) {
logger.error(ex.getMessage());
// FIXME react, don't continue
}
}
use of org.opennms.nrtg.api.model.CollectionJob in project opennms by OpenNMS.
the class SnmpProtocolCollectorTest method testCollect.
@Test
public void testCollect() {
collectionJob.setService("SNMP");
collectionJob.setNodeId(1);
collectionJob.setNetInterface(localhost.getHostAddress());
collectionJob.addMetric(testMetric, destinations, "OnmsLocicMetricId");
collectionJob.setId("testing");
CollectionJob result = protocolCollector.collect(collectionJob);
Assert.assertEquals(result.getService(), "SNMP");
Assert.assertEquals(result.getMetricValue(testMetric), testMetricValue);
}
use of org.opennms.nrtg.api.model.CollectionJob in project opennms by OpenNMS.
the class PooledJobPublisher method createTestJob.
private CollectionJob createTestJob() {
if (this.job == null) {
TreeSet<String> destinationSet = new TreeSet<String>();
destinationSet.add("NrtResults");
CollectionJob snmpJob = new DefaultCollectionJob();
snmpJob.addMetric(".1.3.6.1.4.1.2021.9.1.9.1", destinationSet, "DummyName");
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.1", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.2", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.4", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.5", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.6", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.7", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.8", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.9", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.10", destinationSet);
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.11", destinationSet);
// destinationSet.add("NrtPersister");
// snmpJob.addMetric(".1.3.6.1.2.1.2.2.1.10.11", destinationSet);
snmpJob.setNetInterface("127.0.0.1");
snmpJob.setService("SNMP");
this.job = snmpJob;
}
return this.job;
}
use of org.opennms.nrtg.api.model.CollectionJob in project opennms by OpenNMS.
the class TcaProtocolCollectorTest method testCollectWithCompountMertic.
@Test
public void testCollectWithCompountMertic() {
final String testMetric = ".1.3.6.1.4.1.27091.3.1.6.1.2.171.19.37.60_inboundDelay";
final String testMetricValue = "12";
collectionJob.setService("TCA");
collectionJob.setNodeId(1);
collectionJob.setNetInterface(localhost.getHostAddress());
collectionJob.addMetric(testMetric, destinations, "OnmsLocicMetricId");
collectionJob.setId("testing");
CollectionJob result = protocolCollector.collect(collectionJob);
Assert.assertNotNull(result);
Assert.assertEquals(result.getMetricValue(testMetric), testMetricValue);
}
use of org.opennms.nrtg.api.model.CollectionJob in project opennms by OpenNMS.
the class NrtController method nrtStart.
public ModelAndView nrtStart(ResourceId resourceId, String report, HttpSession httpSession) {
assert (resourceId != null);
logger.debug("resourceId: '{}'", resourceId);
assert (report != null);
logger.debug("report: '{}'", report);
OnmsResource reportResource = m_resourceDao.getResourceById(resourceId);
PrefabGraph prefabGraph = m_graphDao.getPrefabGraph(report);
String nrtCollectionTaskId = String.format("NrtCollectionTaskId_%d_%d", System.currentTimeMillis(), new Random().nextInt());
List<CollectionJob> collectionJobs = createCollectionJobs(reportResource, prefabGraph, nrtCollectionTaskId);
for (CollectionJob collectionJob : collectionJobs) {
m_nrtBroker.publishCollectionJob(collectionJob);
getCollectionJobMap(httpSession, true).put(nrtCollectionTaskId, collectionJob);
}
ModelAndView modelAndView = new ModelAndView("nrt/realtime.json");
modelAndView.addObject("nrtCollectionTaskId", nrtCollectionTaskId);
modelAndView.addObject("graphTitle", prefabGraph.getTitle());
modelAndView.addObject("graphName", prefabGraph.getName());
modelAndView.addObject("graphDescription", prefabGraph.getDescription());
NrtHelper nrtHelper = new NrtHelper();
modelAndView.addObject("rrdGraphString", nrtHelper.cleanUpRrdGraphStringForWebUi(prefabGraph, getRequiredExternalPropertyAttributes(reportResource, prefabGraph), getRequiredStringPropertyAttributes(reportResource, prefabGraph)));
Set<RrdGraphAttribute> relevantRrdGraphAttributes = getRequiredRrdGraphAttributes(reportResource, prefabGraph);
Map<String, String> rrdGraphAttributesMetaData = getMetaDataForReport(relevantRrdGraphAttributes);
Map<String, String> rrdGraphAttributesToMetricIds = getRrdGraphAttributesToMetricIds(rrdGraphAttributesMetaData);
modelAndView.addObject("metricsMapping", nrtHelper.generateJsMappingObject(prefabGraph.getCommand(), rrdGraphAttributesToMetricIds));
return modelAndView;
}
Aggregations