Search in sources :

Example 11 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class DefaultLocationDataService method getApplicationDetails.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public ApplicationDetails getApplicationDetails(final String applicationName) {
    waitForGeocoding("getApplicationDetails");
    final OnmsApplication app = m_applicationDao.findByName(applicationName);
    return getApplicationDetails(app);
}
Also used : OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class DefaultLocationDataService method getApplicationInfo.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public ApplicationInfo getApplicationInfo(final String applicationName) {
    waitForGeocoding("getApplicationInfo");
    final OnmsApplication app = m_applicationDao.findByName(applicationName);
    if (app == null) {
        LOG.warn("no application found with name '{}'", applicationName);
    }
    return getApplicationInfo(app);
}
Also used : OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class LocationDataManagerTest method testGetStatusDetailsForApplication.

@Test
public void testGetStatusDetailsForApplication() {
    String appName = "Domain Controllers";
    int count = 100;
    long start = System.currentTimeMillis();
    for (int i = 0; i < count; i++) {
        OnmsApplication app = m_applicationDao.findByName(appName);
        // System.err.println("TEST testGetSatusDetailsForApplication: calling getStatusDetailsForApplication");
        StatusDetails details = m_locationDataService.getStatusDetailsForApplication(app);
        assertEquals(Status.UP, details.getStatus());
    }
    System.err.println(String.format("Avg getStatusDetailsForApplication: %d\n", (System.currentTimeMillis() - start) / count));
}
Also used : StatusDetails(org.opennms.features.poller.remote.gwt.client.StatusDetails) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Test(org.junit.Test)

Example 14 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.

the class RemotePollerAvailabilityService method getAvailabilityList.

/**
 * @param timeChunker
 * @param sortedApplications
 * @param selectedMonitors
 * @param selectedNodes
 * @return
 */
private OnmsLocationAvailDefinitionList getAvailabilityList(TimeChunker timeChunker, List<OnmsApplication> sortedApplications, Collection<OnmsLocationMonitor> selectedMonitors, Collection<OnmsNode> selectedNodes) {
    OnmsLocationAvailDefinitionList availList = new OnmsLocationAvailDefinitionList();
    List<String> names = new ArrayList<String>(sortedApplications.size());
    for (OnmsApplication app : sortedApplications) {
        names.add(app.getName());
    }
    Collection<OnmsLocationSpecificStatus> statusesPeriod = m_locationMonitorDao.getStatusChangesBetweenForApplications(timeChunker.getStartDate(), timeChunker.getEndDate(), names);
    AvailCalculator availCalc = new AvailCalculator(timeChunker);
    removeUnneededMonitors(statusesPeriod, selectedMonitors);
    removeUnneededServices(statusesPeriod, selectedNodes);
    for (OnmsLocationSpecificStatus statusChange : statusesPeriod) {
        availCalc.onStatusChange(statusChange);
    }
    int counter = 0;
    for (int i = 0; i < timeChunker.getSegmentCount(); i++) {
        counter++;
        TimeChunk timeChunk = timeChunker.getAt(i);
        OnmsLocationAvailDataPoint point = new OnmsLocationAvailDataPoint();
        point.setTime(timeChunk.getEndDate());
        for (OnmsApplication application : sortedApplications) {
            double percentage = availCalc.getAvailabilityFor(m_monitoredServiceDao.findByApplication(application), i);
            String strPercent = new DecimalFormat("0.0").format(percentage * 100);
            point.addAvailDefinition(new OnmsLocationAvailDefinition(application.getName(), strPercent));
        }
        availList.add(point);
    }
    System.err.println(new Date() + "After Calculations total loops: " + counter);
    return availList;
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) OnmsLocationAvailDefinition(org.opennms.netmgt.model.OnmsLocationAvailDefinition) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) OnmsLocationAvailDataPoint(org.opennms.netmgt.model.OnmsLocationAvailDataPoint) OnmsLocationAvailDataPoint(org.opennms.netmgt.model.OnmsLocationAvailDataPoint) Date(java.util.Date) TimeChunk(org.opennms.web.rest.v1.support.TimeChunker.TimeChunk) OnmsLocationAvailDefinitionList(org.opennms.netmgt.model.OnmsLocationAvailDefinitionList)

Example 15 with OnmsApplication

use of org.opennms.netmgt.model.OnmsApplication 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);
}
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)

Aggregations

OnmsApplication (org.opennms.netmgt.model.OnmsApplication)42 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)20 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)14 ArrayList (java.util.ArrayList)13 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)12 Date (java.util.Date)11 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)11 LinkedList (java.util.LinkedList)8 Transactional (org.springframework.transaction.annotation.Transactional)6 HashSet (java.util.HashSet)5 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)4 StatusDetails (org.opennms.features.poller.remote.gwt.client.StatusDetails)4 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)4 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 Test (org.junit.Test)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)3 DistributedStatusHistoryModel (org.opennms.web.svclayer.model.DistributedStatusHistoryModel)3 HashMap (java.util.HashMap)2