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);
}
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);
}
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();
}
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;
}
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);
}
Aggregations