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;
}
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();
}
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;
}
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;
}
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);
}
Aggregations