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;
}
use of org.opennms.nrtg.api.model.CollectionJob in project opennms by OpenNMS.
the class PooledJobPublisher method run.
@Override
public void run() {
for (int i = 0; i < task.getCount(); i++) {
CollectionJob job = this.createTestJob();
logger.info("publishJob '{}' start", i + " " + Thread.currentThread());
Long startTime = System.currentTimeMillis();
publishJob(job, "NrtCollectMe");
try {
Thread.sleep(25);
} catch (InterruptedException ex) {
java.util.logging.Logger.getLogger(PooledJobPublisher.class.getName()).log(Level.SEVERE, null, ex);
}
logger.info("publishJob '{}' done after'{}'", i + " " + Thread.currentThread(), System.currentTimeMillis() - startTime);
}
}
Aggregations