Search in sources :

Example 6 with CollectionJob

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);
}
Also used : DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob) CollectionJob(org.opennms.nrtg.api.model.CollectionJob) Test(org.junit.Test)

Example 7 with CollectionJob

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;
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) PrefabGraph(org.opennms.netmgt.model.PrefabGraph) Random(java.util.Random) DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob) CollectionJob(org.opennms.nrtg.api.model.CollectionJob) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute)

Example 8 with CollectionJob

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);
    }
}
Also used : CollectionJob(org.opennms.nrtg.api.model.CollectionJob) DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob)

Aggregations

CollectionJob (org.opennms.nrtg.api.model.CollectionJob)8 DefaultCollectionJob (org.opennms.nrtg.api.model.DefaultCollectionJob)7 Date (java.util.Date)2 Test (org.junit.Test)2 OnmsResource (org.opennms.netmgt.model.OnmsResource)2 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 TreeSet (java.util.TreeSet)1 JMSException (javax.jms.JMSException)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1 LightweightMeasurementSet (org.opennms.nrtg.api.model.LightweightMeasurementSet)1