Search in sources :

Example 11 with OnmsMonitoringLocation

use of org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation 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<OnmsMonitoringLocation>();
    locationDefinitions.add(m_locationDefinition1);
    locationDefinitions.add(m_locationDefinition2);
    locationDefinitions.add(m_locationDefinition3);
    List<OnmsApplication> applications = new LinkedList<OnmsApplication>();
    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<OnmsLocationSpecificStatus>();
    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<OnmsLocationSpecificStatus>();
    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<OnmsLocationMonitor>();
    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);
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) LinkedList(java.util.LinkedList) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) SimpleWebTable(org.opennms.web.svclayer.model.SimpleWebTable) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) HashSet(java.util.HashSet)

Example 12 with OnmsMonitoringLocation

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

the class ResponseTimeResourceTypeTest method canGetResourcesForNodeAtLocation.

@Test
public void canGetResourcesForNodeAtLocation() throws IOException {
    OnmsMonitoringLocation location = new OnmsMonitoringLocation();
    location.setLocationName(NON_DEFAULT_LOCATION_NAME);
    expect(node.getIpInterfaces()).andReturn(ipInterfaces);
    expect(node.getLocation()).andReturn(location).atLeastOnce();
    expect(ipInterface.getIpAddress()).andReturn(InetAddress.getByName("127.0.0.1")).atLeastOnce();
    replay(node, ipInterface);
    NodeResourceType nodeResourceType = new NodeResourceType(resourceDao, nodeDao);
    OnmsResource nodeResource = new OnmsResource("1", "Node", nodeResourceType, Collections.emptySet(), ResourcePath.get("foo"));
    nodeResource.setEntity(node);
    List<OnmsResource> resources = responseTimeResourceType.getResourcesForParent(nodeResource);
    verify(node, ipInterface);
    assertEquals(1, resources.size());
    assertEquals("127.0.0.1", resources.get(0).getName());
}
Also used : OnmsResource(org.opennms.netmgt.model.OnmsResource) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Test(org.junit.Test)

Example 13 with OnmsMonitoringLocation

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

the class LocationDataManagerTest method testGetStatusDetailsForLocation.

@Test
public void testGetStatusDetailsForLocation() {
    OnmsMonitoringLocation def = m_monitoringLocationDao.get("00002");
    m_locationDataService.getStatusDetailsForLocation(def);
}
Also used : OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Test(org.junit.Test)

Example 14 with OnmsMonitoringLocation

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

the class LocationDataServiceIT method setUp.

@Before
public void setUp() throws Exception {
    Properties p = new Properties();
    p.setProperty("log4j.logger.org.hibernate", "INFO");
    p.setProperty("log4j.logger.org.hibernate.SQL", "DEBUG");
    MockLogAppender.setupLogging(p);
    OnmsMonitoringLocation location = new OnmsMonitoringLocation("RDU", "East Coast", new String[] { "example1" }, new String[0], "Research Triangle Park, NC", 35.715751f, -79.16262f, 1L, "odd");
    m_monitoringLocationDao.saveOrUpdate(location);
    OnmsApplication app = new OnmsApplication();
    app.setName("TestApp1");
    m_applicationDao.saveOrUpdate(app);
    OnmsNode localhostNode = new OnmsNode(location, "localhost");
    m_nodeDao.saveOrUpdate(localhostNode);
    OnmsNode googleNode = new OnmsNode(location, "google");
    m_nodeDao.saveOrUpdate(googleNode);
    OnmsIpInterface localhostIpInterface = new OnmsIpInterface(addr("127.0.0.1"), localhostNode);
    m_ipInterfaceDao.saveOrUpdate(localhostIpInterface);
    OnmsIpInterface googleIpInterface = new OnmsIpInterface(addr("66.249.80.104"), googleNode);
    m_ipInterfaceDao.saveOrUpdate(googleIpInterface);
    OnmsServiceType httpServiceType = new OnmsServiceType("HTTP");
    m_serviceTypeDao.saveOrUpdate(httpServiceType);
    m_localhostHttpService = createService(app, localhostIpInterface, httpServiceType);
    m_googleHttpService = createService(app, googleIpInterface, httpServiceType);
    m_rduMonitor1 = new OnmsLocationMonitor();
    m_rduMonitor1.setId(UUID.randomUUID().toString());
    m_rduMonitor1.setLocation("RDU");
    m_rduMonitor1.setLastUpdated(m_pollingEnd);
    m_rduMonitor1.setStatus(MonitorStatus.STARTED);
    m_locationMonitorDao.saveOrUpdate(m_rduMonitor1);
    m_rduMonitor2 = new OnmsLocationMonitor();
    m_rduMonitor2.setId(UUID.randomUUID().toString());
    m_rduMonitor2.setLocation("RDU");
    m_rduMonitor2.setLastUpdated(m_pollingEnd);
    m_rduMonitor2.setStatus(MonitorStatus.STARTED);
    m_locationMonitorDao.saveOrUpdate(m_rduMonitor2);
    m_applicationDao.flush();
    m_distPollerDao.flush();
    m_nodeDao.flush();
    m_ipInterfaceDao.flush();
    m_serviceTypeDao.flush();
    m_monitoredServiceDao.flush();
    m_locationMonitorDao.flush();
    OnmsApplication onmsApp = m_applicationDao.findByName("TestApp1");
    assertTrue(onmsApp.equals(app));
    assertEquals("Count of applications associated with services is wrong", 1, m_localhostHttpService.getApplications().size());
    assertEquals("Count of applications associated with services is wrong", 1, m_googleHttpService.getApplications().size());
    assertEquals("Count of services associated with application is wrong", 2, app.getMonitoredServices().size());
    m_pollingEnd = new Date();
    m_pollingStart = new Date(m_pollingEnd.getTime() - (1000 * 60 * 60 * 24));
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) Properties(java.util.Properties) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) Date(java.util.Date) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Before(org.junit.Before)

Example 15 with OnmsMonitoringLocation

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

the class PollerBackEndIT method setUp.

@Before
public void setUp() {
    MockLogAppender.setupLogging();
    OnmsMonitoringLocation location = new OnmsMonitoringLocation("RDU", "East Coast", new String[] { "example1" }, new String[0], "Research Triangle Park, NC", 35.715751f, -79.16262f, 1L, "odd");
    m_monitoringLocationDao.saveOrUpdate(location);
}
Also used : OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Before(org.junit.Before)

Aggregations

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