Search in sources :

Example 1 with DefaultCollectionJob

use of org.opennms.nrtg.api.model.DefaultCollectionJob in project opennms by OpenNMS.

the class TcaProtocolCollectorTest method setup.

@Before
public void setup() throws Exception {
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    localhost = InetAddress.getByName("127.0.0.1");
    snmpAgentConfig = SnmpPeerFactory.getInstance().getAgentConfig(localhost);
    collectionJob = new DefaultCollectionJob();
    collectionJob.setProtocolConfiguration(snmpAgentConfig.toProtocolConfigString());
    destinations = new HashSet<String>();
    destinations.add("test");
}
Also used : DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob) Before(org.junit.Before)

Example 2 with DefaultCollectionJob

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

Example 3 with DefaultCollectionJob

use of org.opennms.nrtg.api.model.DefaultCollectionJob in project opennms by OpenNMS.

the class NrtController method createCollectionJobs.

private List<CollectionJob> createCollectionJobs(OnmsResource reportResource, PrefabGraph prefabGraph, String nrtCollectionTaskId) {
    List<CollectionJob> collectionJobs = new ArrayList<CollectionJob>();
    OnmsResource nodeResource = reportResource.getParent();
    OnmsNode node = m_nodeDao.get(nodeResource.getName());
    Integer nodeId = node.getId();
    Date createTimestamp = new Date();
    //What protocols are involved?
    //For each protocol build a new CollectionJob
    Set<RrdGraphAttribute> relevantRrdGraphAttributes = getRequiredRrdGraphAttributes(reportResource, prefabGraph);
    Map<String, String> rrdGraphAttributesMetaData = getMetaDataForReport(relevantRrdGraphAttributes);
    Map<String, List<MetricTuple>> metricsByProtocol = getMetricIdsByProtocol(rrdGraphAttributesMetaData);
    //Destinations for MeasurementSets
    Set<String> resultDestinations = new HashSet<String>();
    resultDestinations.add(nrtCollectionTaskId);
    for (final Map.Entry<String, List<MetricTuple>> entry : metricsByProtocol.entrySet()) {
        final String protocol = entry.getKey();
        final List<MetricTuple> tuples = entry.getValue();
        final CollectionJob collectionJob = new DefaultCollectionJob();
        collectionJob.setService(protocol);
        collectionJob.setNodeId(nodeId);
        collectionJob.setCreationTimestamp(createTimestamp);
        for (final MetricTuple metricTuple : tuples) {
            collectionJob.addMetric(metricTuple.getMetricId(), resultDestinations, metricTuple.getOnmsLogicMetricId());
        }
        //I know....
        if (protocol.equals("SNMP") || protocol.equals("TCA")) {
            collectionJob.setNetInterface(protocol);
            OnmsMonitoringLocation location = node.getLocation();
            String locationName = (location == null) ? null : location.getLocationName();
            final SnmpAgentConfig snmpAgentConfig = m_snmpAgentConfigFactory.getAgentConfig(node.getPrimaryInterface().getIpAddress(), locationName);
            collectionJob.setProtocolConfiguration(snmpAgentConfig.toProtocolConfigString());
            collectionJob.setNetInterface(node.getPrimaryInterface().getIpAddress().getHostAddress());
            collectionJobs.add(collectionJob);
        } else {
            logger.error("Protocol '{}' is not supported yet. CollectionJob will be ignorred.", protocol);
        }
    }
    return collectionJobs;
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) OnmsNode(org.opennms.netmgt.model.OnmsNode) DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob) ArrayList(java.util.ArrayList) Date(java.util.Date) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute) OnmsResource(org.opennms.netmgt.model.OnmsResource) DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob) CollectionJob(org.opennms.nrtg.api.model.CollectionJob) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 4 with DefaultCollectionJob

use of org.opennms.nrtg.api.model.DefaultCollectionJob in project opennms by OpenNMS.

the class SnmpProtocolCollectorTest method setup.

@Before
public void setup() throws Exception {
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    localhost = InetAddress.getByName("127.0.0.1");
    snmpAgentConfig = SnmpPeerFactory.getInstance().getAgentConfig(localhost);
    collectionJob = new DefaultCollectionJob();
    collectionJob.setProtocolConfiguration(snmpAgentConfig.toProtocolConfigString());
    destinations = new HashSet<String>();
    destinations.add("test");
}
Also used : DefaultCollectionJob(org.opennms.nrtg.api.model.DefaultCollectionJob) Before(org.junit.Before)

Aggregations

DefaultCollectionJob (org.opennms.nrtg.api.model.DefaultCollectionJob)4 Before (org.junit.Before)2 CollectionJob (org.opennms.nrtg.api.model.CollectionJob)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)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 TreeSet (java.util.TreeSet)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1