Search in sources :

Example 1 with OnmsMonitoredService

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);
        }
    }
}
Also used : AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Edge(org.opennms.features.topology.api.topo.Edge) AbstractEdge(org.opennms.features.topology.api.topo.AbstractEdge) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 2 with OnmsMonitoredService

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 ====");
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) OnmsAcknowledgment(org.opennms.netmgt.model.OnmsAcknowledgment) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) OnmsUserNotification(org.opennms.netmgt.model.OnmsUserNotification) OnmsNotification(org.opennms.netmgt.model.OnmsNotification) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 3 with OnmsMonitoredService

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;
}
Also used : DemandPoll(org.opennms.netmgt.model.DemandPoll) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 4 with OnmsMonitoredService

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;
}
Also used : OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 5 with OnmsMonitoredService

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);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Event(org.opennms.netmgt.xml.event.Event) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Aggregations

OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)119 Date (java.util.Date)37 OnmsNode (org.opennms.netmgt.model.OnmsNode)36 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)33 Test (org.junit.Test)27 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)25 Transactional (org.springframework.transaction.annotation.Transactional)22 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)20 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)18 ArrayList (java.util.ArrayList)17 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)17 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)15 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)15 LinkedList (java.util.LinkedList)13 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)13 HashSet (java.util.HashSet)9 Before (org.junit.Before)6 Criteria (org.opennms.core.criteria.Criteria)5 BusinessServiceEntity (org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity)5 SimpleWebTable (org.opennms.web.svclayer.model.SimpleWebTable)5