use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultLocationDataService method getApplicationDetails.
/**
* <p>getApplicationDetails</p>
*
* @param app a {@link org.opennms.netmgt.model.OnmsApplication} object.
* @return a {@link org.opennms.features.poller.remote.gwt.client.ApplicationDetails} object.
*/
@Transactional
@Override
public ApplicationDetails getApplicationDetails(final OnmsApplication app) {
waitForGeocoding("getApplicationDetails");
final ApplicationInfo applicationInfo = getApplicationInfo(app, StatusDetails.unknown());
List<GWTLocationSpecificStatus> statuses = new ArrayList<GWTLocationSpecificStatus>();
final Date to = new Date();
final Date from = new Date(to.getTime() - AVAILABILITY_MS);
final Collection<OnmsMonitoredService> services = m_monitoredServiceDao.findByApplication(app);
final List<GWTLocationMonitor> monitors = new ArrayList<GWTLocationMonitor>();
for (final OnmsLocationMonitor monitor : m_locationDao.findByApplication(app)) {
monitors.add(transformLocationMonitor(monitor));
for (final OnmsLocationSpecificStatus locationSpecificStatus : m_locationDao.getStatusChangesForLocationBetween(from, to, monitor.getLocation())) {
if (services.contains(locationSpecificStatus.getMonitoredService())) {
statuses.add(transformLocationSpecificStatus(locationSpecificStatus));
}
}
}
ApplicationDetails details = new ApplicationDetails(applicationInfo, from, to, monitors, statuses);
LOG.warn("getApplicationDetails({}) returning {}", app.getName(), details);
return details;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultLocationDataService method getStatusDetailsForApplication.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public StatusDetails getStatusDetailsForApplication(final OnmsApplication app) {
waitForGeocoding("getStatusDetailsForApplication");
List<GWTLocationSpecificStatus> statuses = new ArrayList<GWTLocationSpecificStatus>();
final Date to = new Date();
final Date from = new Date(to.getTime() - AVAILABILITY_MS);
final Collection<OnmsMonitoredService> services = m_monitoredServiceDao.findByApplication(app);
final Set<GWTLocationMonitor> monitors = new LinkedHashSet<GWTLocationMonitor>();
final Set<GWTMonitoredService> gwtServices = new LinkedHashSet<GWTMonitoredService>(services.size());
for (final OnmsMonitoredService service : services) {
gwtServices.add(transformMonitoredService(service));
}
for (OnmsLocationSpecificStatus status : m_locationDao.getStatusChangesForApplicationBetween(to, from, app.getName())) {
monitors.add(transformLocationMonitor(status.getLocationMonitor()));
statuses.add(transformLocationSpecificStatus(status));
}
StatusDetails statusDetails = new AppStatusDetailsComputer(from, to, monitors, gwtServices, statuses).compute();
LOG.warn("getStatusDetailsForApplication({}) returning {}", app.getName(), statusDetails);
return statusDetails;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultSurveillanceViewService method calculateServiceDownTime.
/**
* Calculates and returns a map of service/downtime for a given period of time.
*
* @param periodEnd the end of the period
* @param periodStart the start of the period
* @param outages the outages encountered
* @return a mapping of service/downtime
*/
private static Map<OnmsMonitoredService, Long> calculateServiceDownTime(Date periodEnd, Date periodStart, List<OnmsOutage> outages) {
Map<OnmsMonitoredService, Long> map = new HashMap<OnmsMonitoredService, Long>();
for (OnmsOutage outage : outages) {
if (map.get(outage.getMonitoredService()) == null) {
map.put(outage.getMonitoredService(), Long.valueOf(0));
}
Date begin;
if (outage.getIfLostService().before(periodStart)) {
begin = periodStart;
} else {
begin = outage.getIfLostService();
}
Date end;
if (outage.getIfRegainedService() == null || !outage.getIfRegainedService().before(periodEnd)) {
end = periodEnd;
} else {
end = outage.getIfRegainedService();
}
Long count = map.get(outage.getMonitoredService());
count += (end.getTime() - begin.getTime());
map.put(outage.getMonitoredService(), count);
}
return map;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class PathOutageStatusProviderIT method createOutage.
/**
* This method creates an outage with a given parameters for the specified node
* @param uie Event UIE
* @param ipaddress IP-address (in dot-format)
* @param node Node
* @param severity Severity
* @return Resulting outage
* @throws UnknownHostException
*/
private OnmsOutage createOutage(String uie, String ipaddress, OnmsNode node, OnmsSeverity severity) throws UnknownHostException {
OnmsEvent event = createEvent(uie, ipaddress, node, severity);
eventDao.save(event);
OnmsMonitoredService service = createService(node);
monitoredServiceDao.save(service);
OnmsOutage outage = new OnmsOutage(new Date(), event, service);
return outage;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class QueryManagerDaoImpl method getNodeServices.
@Override
public List<String[]> getNodeServices(int nodeId) {
final LinkedList<String[]> servicemap = new LinkedList<>();
Criteria criteria = new Criteria(OnmsMonitoredService.class);
criteria.setAliases(Arrays.asList(new Alias[] { new Alias("ipInterface", "ipInterface", JoinType.LEFT_JOIN), new Alias("ipInterface.node", "node", JoinType.LEFT_JOIN) }));
criteria.addRestriction(new EqRestriction("node.id", nodeId));
// Ignore forced-unmanaged
criteria.addRestriction(new NeRestriction("status", "F"));
for (OnmsMonitoredService service : m_monitoredServiceDao.findMatching(criteria)) {
servicemap.add(new String[] { service.getIpAddressAsString(), service.getServiceName() });
}
return servicemap;
}
Aggregations