Search in sources :

Example 36 with OnmsMonitoringLocation

use of org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation 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 37 with OnmsMonitoringLocation

use of org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation in project opennms by OpenNMS.

the class DefaultLocationDataService method updateGeolocations.

/**
 * <p>updateGeolocations</p>
 */
public void updateGeolocations() {
    LOG.info("geolocating monitoring location definitions");
    final Collection<OnmsMonitoringLocation> definitions = m_monitoringLocationDao.findAll();
    for (final OnmsMonitoringLocation def : definitions) {
        final GWTLatLng latLng = getLatLng(def, true);
        if (latLng != null) {
            def.setLatitude(latLng.getLatitude().floatValue());
            def.setLongitude(latLng.getLongitude().floatValue());
            if (m_save) {
                m_monitoringLocationDao.saveOrUpdate(def);
            }
        }
    }
    LOG.info("finished geolocating monitoring location definitions");
    updateGeolocationsComplete();
}
Also used : GWTLatLng(org.opennms.features.poller.remote.gwt.client.GWTLatLng) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 38 with OnmsMonitoringLocation

use of org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation in project opennms by OpenNMS.

the class DefaultLocationDataService method getUpdatedLocationsBetween.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public Collection<LocationInfo> getUpdatedLocationsBetween(final Date startDate, final Date endDate) {
    waitForGeocoding("getApplicationDetails");
    final Collection<LocationInfo> locations = new ArrayList<LocationInfo>();
    final Map<String, OnmsMonitoringLocation> definitions = new HashMap<String, OnmsMonitoringLocation>();
    // check for any monitors that have changed status
    for (OnmsMonitoringLocation def : m_monitoringLocationDao.findAll()) {
        for (OnmsLocationMonitor mon : m_locationDao.findByLocationDefinition(def)) {
            final MonitorStatus status = m_monitorStatuses.get(mon.getLocation());
            if (status == null || !status.equals(mon.getStatus())) {
                definitions.put(def.getLocationName(), def);
                m_monitorStatuses.put(def.getLocationName(), mon.getStatus());
            }
        }
    }
    // check for any definitions that have status updates
    for (final OnmsLocationSpecificStatus status : m_locationDao.getStatusChangesBetween(startDate, endDate)) {
        final String definitionName = status.getLocationMonitor().getLocation();
        if (!definitions.containsKey(definitionName)) {
            definitions.put(definitionName, m_monitoringLocationDao.get(definitionName));
        }
    }
    for (final OnmsMonitoringLocation def : definitions.values()) {
        final LocationInfo location = getLocationInfo(def);
        locations.add(location);
    }
    return locations;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ArrayList(java.util.ArrayList) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) MonitorStatus(org.opennms.netmgt.model.OnmsLocationMonitor.MonitorStatus) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 39 with OnmsMonitoringLocation

use of org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation in project opennms by OpenNMS.

the class DefaultLocationDataService method getInfoForAllLocations.

/**
 * <p>getInfoForAllLocations</p>
 *
 * @return a {@link java.util.List} object.
 */
@Transactional
@Override
public List<LocationInfo> getInfoForAllLocations() {
    waitForGeocoding("getInfoForAllLocations");
    Map<String, StatusDetails> statusDetails = getStatusDetailsForAllLocations();
    List<LocationInfo> locations = new ArrayList<LocationInfo>();
    for (Map.Entry<String, StatusDetails> entry : statusDetails.entrySet()) {
        OnmsMonitoringLocation def = m_monitoringLocationDao.get(entry.getKey());
        LocationInfo locationInfo = this.getLocationInfo(def, entry.getValue());
        locations.add(locationInfo);
    }
    return locations;
}
Also used : StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LocationInfo(org.opennms.features.poller.remote.gwt.client.location.LocationInfo) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 40 with OnmsMonitoringLocation

use of org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation in project opennms by OpenNMS.

the class DefaultLocationDataService method getLocationInfo.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public LocationInfo getLocationInfo(final String locationName) {
    waitForGeocoding("getLocationInfo");
    final OnmsMonitoringLocation def = m_monitoringLocationDao.get(locationName);
    if (def == null) {
        LOG.warn("no monitoring location found for name {}", locationName);
        return null;
    }
    return getLocationInfo(def);
}
Also used : OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)58 OnmsNode (org.opennms.netmgt.model.OnmsNode)19 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)18 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)16 ArrayList (java.util.ArrayList)13 Date (java.util.Date)13 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)12 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)10 Transactional (org.springframework.transaction.annotation.Transactional)10 LinkedList (java.util.LinkedList)8 Test (org.junit.Test)8 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)8 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)7 HashSet (java.util.HashSet)5 Before (org.junit.Before)5 InetAddress (java.net.InetAddress)4 HashMap (java.util.HashMap)4 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)4 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)4 LinkedHashMap (java.util.LinkedHashMap)3