use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultDistributedStatusServiceTest method testCreateFacilityStatusTableLayoutApplicationsVertically.
/*
* XXX need to check sorting
*/
public void testCreateFacilityStatusTableLayoutApplicationsVertically() throws Exception {
// No need to shuffle, since this is a list
List<OnmsMonitoringLocation> locationDefinitions = new LinkedList<>();
locationDefinitions.add(m_locationDefinition1);
locationDefinitions.add(m_locationDefinition2);
locationDefinitions.add(m_locationDefinition3);
List<OnmsApplication> applications = new LinkedList<>();
applications.add(m_application1);
applications.add(m_application2);
Collections.shuffle(applications);
OnmsMonitoredService httpService = findMonitoredService(m_services, m_ip, "HTTP");
OnmsMonitoredService httpsService = findMonitoredService(m_services, m_ip, "HTTPS");
OnmsMonitoredService icmpService = findMonitoredService(m_services, m_ip, "ICMP");
Collection<OnmsLocationSpecificStatus> mostRecentStatuses = new LinkedList<>();
mostRecentStatuses.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061011-00:00:00"));
mostRecentStatuses.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
mostRecentStatuses.add(createStatus(m_locationMonitor2_1, httpService, PollStatus.available(), "20061011-00:00:00"));
mostRecentStatuses.add(createStatus(m_locationMonitor2_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
mostRecentStatuses.add(createStatus(m_locationMonitor2_2, httpService, PollStatus.available(), "20061011-00:00:00"));
mostRecentStatuses.add(createStatus(m_locationMonitor2_2, httpsService, PollStatus.available(), "20061012-06:00:00"));
Collection<OnmsLocationSpecificStatus> statusChanges = new LinkedList<>();
statusChanges.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061011-00:00:00"));
statusChanges.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.unavailable(), "20061012-00:00:00"));
statusChanges.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
statusChanges.add(createStatus(m_locationMonitor1_1, icmpService, PollStatus.down(), "20061010-06:00:00"));
Date startDate = s_dbDate.parse("2006-10-12 00:00:00.0");
Date endDate = s_dbDate.parse("2006-10-13 00:00:00.0");
expect(m_monitoringLocationDao.findAll()).andReturn(locationDefinitions);
expect(m_applicationDao.findAll()).andReturn(applications);
expect(m_locationMonitorDao.getAllMostRecentStatusChanges()).andReturn(mostRecentStatuses);
expect(m_locationMonitorDao.findByLocationDefinition(locationDefinitions.get(0))).andReturn(Collections.singleton(m_locationMonitor1_1));
Collection<OnmsLocationMonitor> monitors2 = new HashSet<>();
monitors2.add(m_locationMonitor2_1);
monitors2.add(m_locationMonitor2_2);
expect(m_locationMonitorDao.findByLocationDefinition(locationDefinitions.get(1))).andReturn(monitors2);
expect(m_locationMonitorDao.findByLocationDefinition(locationDefinitions.get(2))).andReturn(new HashSet<OnmsLocationMonitor>());
expect(m_locationMonitorDao.getStatusChangesBetween(startDate, endDate)).andReturn(statusChanges);
expect(m_locationMonitorDao.getAllStatusChangesAt(startDate)).andReturn(new HashSet<OnmsLocationSpecificStatus>());
expect(m_monitoredServiceDao.findByApplication(m_application1)).andReturn(m_applicationServices1).times(3);
expect(m_monitoredServiceDao.findByApplication(m_application2)).andReturn(m_applicationServices2).times(3);
m_service.setLayoutApplicationsVertically(true);
m_easyMockUtils.replayAll();
SimpleWebTable table = m_service.createFacilityStatusTable(startDate, endDate);
m_easyMockUtils.verifyAll();
SimpleWebTable expectedTable = new SimpleWebTable();
expectedTable.setTitle("Distributed Status Summary");
expectedTable.addColumn("Application", "");
expectedTable.addColumn("Raleigh", "");
expectedTable.addColumn("Durham", "");
expectedTable.addColumn("Columbus", "");
expectedTable.newRow();
expectedTable.addCell("Application 1", "");
expectedTable.addCell("75.000%", "Normal", "distributedStatusHistory.htm?location=Raleigh&application=Application+1");
expectedTable.addCell("No data", "Normal");
expectedTable.addCell("No data", "Indeterminate");
expectedTable.newRow();
expectedTable.addCell("Application 2", "");
expectedTable.addCell("75.000%", "Normal", "distributedStatusHistory.htm?location=Raleigh&application=Application+2");
expectedTable.addCell("No data", "Normal");
expectedTable.addCell("No data", "Indeterminate");
assertTableEquals(expectedTable, table);
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultDistributedStatusServiceTest method testPercentageCalculationOneUnavailableThenAvailaleInMiddleOfDay.
public void testPercentageCalculationOneUnavailableThenAvailaleInMiddleOfDay() throws ParseException {
OnmsMonitoredService httpService = findMonitoredService(m_services, m_ip, "HTTP");
OnmsMonitoredService httpsService = findMonitoredService(m_services, m_ip, "HTTPS");
Collection<OnmsLocationSpecificStatus> statuses = new HashSet<>();
statuses.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061011-00:00:00"));
statuses.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061012-00:00:00"));
statuses.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.unavailable(), "20061012-00:00:00"));
statuses.add(createStatus(m_locationMonitor1_1, httpsService, PollStatus.available(), "20061012-06:00:00"));
statuses.add(createStatus(m_locationMonitor1_1, httpService, PollStatus.available(), "20061013-00:00:00"));
Date startDate = s_dbDate.parse("2006-10-12 00:00:00.0");
Date endDate = s_dbDate.parse("2006-10-13 00:00:00.0");
m_easyMockUtils.replayAll();
String percentage = m_service.calculatePercentageUptime(m_applicationServices1, statuses, startDate, endDate);
m_easyMockUtils.verifyAll();
assertEquals("percentage", "75.000%", percentage);
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultCategoryStatusService method createCategory.
private StatusCategory createCategory(String category) {
Collection<OnmsOutage> outages;
CategoryBuilder categoryBuilder = new CategoryBuilder();
StatusCategory statusCategory = new StatusCategory();
Category categoryDetail = m_categoryConfigDao.getCategoryByLabel(category);
// statusCategory.setComment(categoryDetail.getCategoryComment());
statusCategory.setLabel(category);
ServiceSelector selector = new ServiceSelector(categoryDetail.getRule(), getServicesForCategory(categoryDetail));
outages = m_outageDao.matchingCurrentOutages(selector);
for (OnmsOutage outage : outages) {
OnmsMonitoredService monitoredService = outage.getMonitoredService();
OnmsServiceType serviceType = monitoredService.getServiceType();
OnmsIpInterface ipInterface = monitoredService.getIpInterface();
final String ipAddress = InetAddressUtils.str(ipInterface.getIpAddress());
categoryBuilder.addOutageService(monitoredService.getNodeId(), ipAddress, ipAddress, ipInterface.getNode().getLabel(), serviceType.getName());
}
for (StatusNode node : categoryBuilder.getNodes()) {
statusCategory.addNode(node);
}
return statusCategory;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class PollerIT method getOutages.
/**
* Retrieves all of the outages (using DAOs) associated with
* the given service.
*/
private List<OnmsOutage> getOutages(MockService svc) {
OnmsMonitoredService monitoredSvc = m_monitoredServiceDao.get(svc.getNodeId(), svc.getAddress(), svc.getSvcName());
Criteria criteria = new CriteriaBuilder(OnmsOutage.class).eq("monitoredService", monitoredSvc).orderBy("ifLostService").toCriteria();
return m_outageDao.findMatching(criteria);
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class PollerIT method testServicesWithoutPackagesAreMarkedAsNotPolled.
/**
* Test for NMS-7426.
*/
@Test
public void testServicesWithoutPackagesAreMarkedAsNotPolled() {
MockService monitoredSvc = m_network.getService(5, "192.168.1.7", "SNMP");
MockService notMonitoredSvc = m_network.getService(5, "192.168.1.7", "NotMonitored");
OnmsMonitoredService notMonitored = m_monitoredServiceDao.get(notMonitoredSvc.getNodeId(), notMonitoredSvc.getAddress(), notMonitoredSvc.getSvcName());
// The status should be set initially set to active
assertEquals("A", notMonitored.getStatus());
// Start the poller
startDaemons();
// Take a service down, and wait for the event
// We do this to make ensure the nodes services we're in fact scheduled
anticipateDown(monitoredSvc);
monitoredSvc.bringDown();
verifyAnticipated(10000);
// The status should now be set to not monitored
notMonitored = m_monitoredServiceDao.get(notMonitoredSvc.getNodeId(), notMonitoredSvc.getAddress(), notMonitoredSvc.getSvcName());
assertEquals("N", notMonitored.getStatus());
}
Aggregations