use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class ApplicationTopologyProvider method load.
private void load() {
resetContainer();
for (OnmsApplication application : applicationDao.findAll()) {
ApplicationVertex applicationVertex = new ApplicationVertex(application);
addVertices(applicationVertex);
for (OnmsMonitoredService eachMonitoredService : application.getMonitoredServices()) {
final ApplicationVertex serviceVertex = new ApplicationVertex(eachMonitoredService);
applicationVertex.addChildren(serviceVertex);
addVertices(serviceVertex);
// connect with application
String id = String.format("connection:%s:%s", applicationVertex.getId(), serviceVertex.getId());
Edge edge = new AbstractEdge(getNamespace(), id, applicationVertex, serviceVertex);
addEdges(edge);
}
}
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DatabasePopulator method doPopulateDatabase.
private void doPopulateDatabase() {
LOG.debug("==== DatabasePopulator Starting ====");
final NetworkBuilder builder = new NetworkBuilder();
final OnmsNode node1 = buildNode1(builder);
getNodeDao().save(node1);
getNodeDao().flush();
OnmsNode node2 = buildNode2(builder);
getNodeDao().save(node2);
getNodeDao().flush();
setNode2(node2);
OnmsNode node3 = buildNode3(builder);
getNodeDao().save(node3);
getNodeDao().flush();
setNode3(node3);
OnmsNode node4 = buildNode4(builder);
getNodeDao().save(node4);
getNodeDao().flush();
setNode4(node4);
OnmsNode node5 = buildNode5(builder);
getNodeDao().save(node5);
getNodeDao().flush();
setNode5(node5);
OnmsNode node6 = buildNode6(builder);
getNodeDao().save(node6);
getNodeDao().flush();
setNode6(node6);
final OnmsEvent event = buildEvent(builder.getDistPoller());
event.setEventCreateTime(new Date(1436881548292L));
event.setEventTime(new Date(1436881548292L));
getEventDao().save(event);
getEventDao().flush();
final OnmsNotification notif = buildTestNotification(builder, event);
getNotificationDao().save(notif);
getNotificationDao().flush();
final OnmsUserNotification userNotif = buildTestUserNotification(notif);
getUserNotificationDao().save(userNotif);
getUserNotificationDao().flush();
final OnmsUserNotification userNotif2 = buildTestUser2Notification(notif);
getUserNotificationDao().save(userNotif2);
getUserNotificationDao().flush();
final OnmsMonitoredService svc = getMonitoredServiceDao().get(node1.getId(), InetAddressUtils.addr("192.168.1.1"), "SNMP");
final OnmsOutage resolved = new OnmsOutage(new Date(1436881548292L), new Date(1436881548292L), event, event, svc, null, null);
getOutageDao().save(resolved);
getOutageDao().flush();
final OnmsOutage unresolved = new OnmsOutage(new Date(1436881548292L), event, svc);
getOutageDao().save(unresolved);
getOutageDao().flush();
final OnmsAlarm alarm = buildAlarm(event);
getAlarmDao().save(alarm);
getAlarmDao().flush();
final OnmsAcknowledgment ack = new OnmsAcknowledgment();
ack.setAckTime(new Date(1437073152156L));
ack.setAckType(AckType.UNSPECIFIED);
ack.setAckAction(AckAction.UNSPECIFIED);
ack.setAckUser("admin");
getAcknowledgmentDao().save(ack);
getAcknowledgmentDao().flush();
final OnmsMonitoringLocation def = new OnmsMonitoringLocation();
def.setLocationName("RDU");
def.setMonitoringArea("East Coast");
def.setPollingPackageNames(Collections.singletonList("example1"));
def.setCollectionPackageNames(Collections.singletonList("example1"));
def.setGeolocation("Research Triangle Park, NC");
def.setLatitude(35.715751f);
def.setLongitude(-79.16262f);
def.setPriority(1L);
def.setTags(Collections.singletonList("blah"));
m_monitoringLocationDao.save(def);
LOG.debug("= DatabasePopulatorExtension Populate Starting =");
for (Extension eachExtension : extensions) {
DaoSupport daoSupport = eachExtension.getDaoSupport();
OnmsDao<?, ?> dao = daoSupport != null ? daoSupport.getDao() : null;
Class<? super OnmsDao<?, ?>> daoClass = daoSupport != null ? daoSupport.getDaoClass() : null;
registerDao(daoClass, dao);
dao = lookupDao(daoClass);
eachExtension.onPopulate(this, dao);
if (dao != null) {
dao.flush();
}
}
LOG.debug("= DatabasePopulatorExtension Populate Finished =");
LOG.debug("==== DatabasePopulator Finished ====");
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultDemandPollService method pollMonitoredService.
@Override
public DemandPoll pollMonitoredService(final int nodeId, final InetAddress ipAddr, final int ifIndex, final int serviceId) {
final DemandPoll demandPoll = new DemandPoll();
demandPoll.setRequestTime(new Date());
m_demandPollDao.save(demandPoll);
final OnmsMonitoredService monSvc = m_monitoredServiceDao.get(nodeId, ipAddr, ifIndex, serviceId);
if (monSvc == null) {
throw new RuntimeException("Service doesn't exist: " + monSvc);
}
m_pollerService.poll(monSvc, demandPoll.getId());
return demandPoll;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DefaultAdminApplicationService method findService.
private OnmsMonitoredService findService(String ifServiceIdString) {
int ifServiceId;
try {
ifServiceId = WebSecurityUtils.safeParseInt(ifServiceIdString);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("parameter ifserviceid '" + ifServiceIdString + "' is not an integer");
}
OnmsMonitoredService service = m_monitoredServiceDao.get(ifServiceId);
if (service == null) {
throw new IllegalArgumentException("monitored service with " + "id of " + ifServiceId + " could not be found");
}
return service;
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class PollerServiceTest method testPoll.
public void testPoll() throws EventProxyException {
final int expectedPolldId = 7;
OnmsServiceType svcType = new OnmsServiceType();
svcType.setId(3);
svcType.setName("HTTP");
OnmsNode node = new OnmsNode();
node.setId(1);
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, 1);
OnmsIpInterface iface = new OnmsIpInterface("192.168.1.1", node);
iface.setSnmpInterface(snmpIface);
final OnmsMonitoredService monSvc = new OnmsMonitoredService(iface, svcType);
m_eventProxy.send(isA(Event.class));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
Event event = (Event) getCurrentArguments()[0];
assertEquals("Incorrect uei for demandPollService event", EventConstants.DEMAND_POLL_SERVICE_EVENT_UEI, event.getUei());
assertEquals("Incorrect nodeid for demandPollService event", monSvc.getNodeId().longValue(), event.getNodeid().longValue());
assertEquals("Incorrect ipadr for demandPollService event", InetAddressUtils.str(monSvc.getIpAddress()), event.getInterface());
assertEquals("Incorrect ifIndex for demandPollService event", monSvc.getIfIndex(), Integer.valueOf(event.getIfIndex()));
assertEquals("Incorrect service for demandPollService event", monSvc.getServiceType().getName(), event.getService());
EventUtils.requireParm(event, EventConstants.PARM_DEMAND_POLL_ID);
assertEquals(expectedPolldId, EventUtils.getIntParm(event, EventConstants.PARM_DEMAND_POLL_ID, -1));
return null;
}
});
replay(m_eventProxy);
m_pollerService.poll(monSvc, expectedPolldId);
verify(m_eventProxy);
}
Aggregations