Search in sources :

Example 26 with OnmsMonitoringLocation

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

the class DefaultLocationDataService method getLocationInfoForMonitor.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public LocationInfo getLocationInfoForMonitor(Integer monitorId) {
    waitForGeocoding("getLocationInfoForMonitor");
    final Criteria criteria = new Criteria(OnmsLocationMonitor.class).addRestriction(new EqRestriction("id", monitorId));
    final List<OnmsLocationMonitor> monitors = m_locationDao.findMatching(criteria);
    if (monitors == null) {
        LOG.warn("unable to get location monitor list for monitor ID '{}'", monitorId);
        return null;
    }
    final String definitionName = monitors.get(0).getLocation();
    final OnmsMonitoringLocation def = m_monitoringLocationDao.get(definitionName);
    if (def == null) {
        LOG.warn("unable to find monitoring location definition for '{}'", definitionName);
        return null;
    }
    return getLocationInfo(def);
}
Also used : EqRestriction(org.opennms.core.criteria.restrictions.EqRestriction) Criteria(org.opennms.core.criteria.Criteria) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with OnmsMonitoringLocation

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

the class DefaultLocationDataService method getLocationDetails.

/**
 * {@inheritDoc}
 */
@Transactional
@Override
public LocationDetails getLocationDetails(final String locationName) {
    waitForGeocoding("getLocationDetails");
    final OnmsMonitoringLocation def = m_monitoringLocationDao.get(locationName);
    if (def == null) {
        LOG.warn("no monitoring location found for name {}", locationName);
        return null;
    }
    return getLocationDetails(def);
}
Also used : OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with OnmsMonitoringLocation

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

the class VacuumdIT method setUp.

/**
 * Sets up the test.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_ancitipator = ((MockEventIpcManager) m_eventProxy).getEventAnticipator();
    m_location = new OnmsMonitoringLocation("Default", "Default");
    m_distPoller = new OnmsDistPoller("00000000-0000-0000-0000-000000000000");
    m_distPoller.setLabel("localhost");
    m_distPoller.setLocation("Default");
    m_distPoller.setType(OnmsMonitoringSystem.TYPE_OPENNMS);
    OnmsNode node = createNode();
    m_down = new NorthboundAlarm(createDownAlarm(node, new Date()));
    System.err.println(JaxbUtils.marshal(m_down));
    m_up = new NorthboundAlarm(createUpAlarm(node, new Date(m_down.getLastOccurrence().getTime() + DELAY)));
    System.err.println(JaxbUtils.marshal(m_up));
    // Setup the Drools northbounder configuration DAO
    DroolsNorthbounderConfigDao configDao = new DroolsNorthbounderConfigDao();
    configDao.setConfigResource(new FileSystemResource(new File("src/test/resources/etc/vacuumd/drools-northbounder-configuration.xml")));
    configDao.afterPropertiesSet();
    Assert.assertNotNull(configDao.getConfig().getEngine("Vacuumd"));
    // Setup the northbounder
    nbi = new DroolsNorthbounder(m_appContext, configDao, m_eventProxy, "Vacuumd");
    nbi.afterPropertiesSet();
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) DroolsNorthbounderConfigDao(org.opennms.netmgt.alarmd.northbounder.drools.DroolsNorthbounderConfigDao) DroolsNorthbounder(org.opennms.netmgt.alarmd.northbounder.drools.DroolsNorthbounder) NorthboundAlarm(org.opennms.netmgt.alarmd.api.NorthboundAlarm) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) Date(java.util.Date) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Before(org.junit.Before)

Example 29 with OnmsMonitoringLocation

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

the class OnmsOutageTest method createNode.

private static OnmsNode createNode(int id, String label) {
    OnmsNode node = new OnmsNode();
    node.setId(id);
    node.setLabel(label);
    node.setCreateTime(new Date());
    OnmsMonitoringLocation location = new OnmsMonitoringLocation("Default", "Default");
    node.setLocation(location);
    return node;
}
Also used : Date(java.util.Date) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 30 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<>();
    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

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