Search in sources :

Example 71 with OnmsMonitoredService

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

the class Collectd method scheduleNode.

private void scheduleNode(final int nodeId, final boolean existing) {
    OnmsNode node = m_nodeDao.getHierarchy(nodeId);
    node.visit(new AbstractEntityVisitor() {

        @Override
        public void visitMonitoredService(OnmsMonitoredService monSvc) {
            scheduleInterface(monSvc.getIpInterface(), monSvc.getServiceName(), existing);
        }
    });
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) AbstractEntityVisitor(org.opennms.netmgt.model.AbstractEntityVisitor) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 72 with OnmsMonitoredService

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

the class AvailabilityRestService method getAvailabilityNode.

AvailabilityNode getAvailabilityNode(final int id) throws Exception {
    final OnmsNode dbNode = m_nodeDao.get(id);
    initialize(dbNode);
    if (dbNode == null) {
        throw getException(Status.NOT_FOUND, "Node {} was not found.", Integer.toString(id));
    }
    final double nodeAvail = CategoryModel.getNodeAvailability(id);
    final AvailabilityNode node = new AvailabilityNode(dbNode, nodeAvail);
    for (final OnmsIpInterface iface : dbNode.getIpInterfaces()) {
        final double ifaceAvail = CategoryModel.getInterfaceAvailability(id, str(iface.getIpAddress()));
        final AvailabilityIpInterface ai = new AvailabilityIpInterface(iface, ifaceAvail);
        for (final OnmsMonitoredService svc : iface.getMonitoredServices()) {
            final double serviceAvail = CategoryModel.getServiceAvailability(id, str(iface.getIpAddress()), svc.getServiceId());
            final AvailabilityMonitoredService ams = new AvailabilityMonitoredService(svc, serviceAvail);
            ai.addService(ams);
        }
        node.addIpInterface(ai);
    }
    return node;
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) AvailabilityNode(org.opennms.web.category.AvailabilityNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) AvailabilityIpInterface(org.opennms.web.category.AvailabilityIpInterface) AvailabilityMonitoredService(org.opennms.web.category.AvailabilityMonitoredService) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 73 with OnmsMonitoredService

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

the class RemotePollerAvailabilityRestServiceIT method createLocationMonitors.

private void createLocationMonitors() throws InterruptedException {
    m_transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            System.err.println("======= Starting createLocationMonitors() ======");
            OnmsLocationMonitor locMon1 = new OnmsLocationMonitor();
            locMon1.setId(UUID.randomUUID().toString());
            locMon1.setLocation("RDU");
            locMon1.setLastUpdated(new Date());
            locMon1.setStatus(MonitorStatus.STARTED);
            m_locationMonitorDao.save(locMon1);
            OnmsApplication ipv6App = new OnmsApplication();
            ipv6App.setName("IPv6");
            m_applicationDao.saveOrUpdate(ipv6App);
            OnmsApplication ipv4App = new OnmsApplication();
            ipv4App.setName("IPv4");
            m_applicationDao.saveOrUpdate(ipv4App);
            OnmsMonitoredService service2 = m_monServiceDao.findByType("HTTP").get(1);
            service2.addApplication(ipv4App);
            ipv4App.addMonitoredService(service2);
            m_monServiceDao.saveOrUpdate(service2);
            m_applicationDao.saveOrUpdate(ipv4App);
            List<OnmsMonitoredService> services = m_monServiceDao.findByType("HTTP");
            for (OnmsMonitoredService service : services) {
                service = m_monServiceDao.findByType("HTTP").get(0);
                service.addApplication(ipv6App);
                ipv6App.addMonitoredService(service);
                m_monServiceDao.saveOrUpdate(service);
                m_applicationDao.saveOrUpdate(ipv6App);
                OnmsLocationMonitor locMon = m_locationMonitorDao.findAll().get(0);
                OnmsLocationSpecificStatus statusChange = new OnmsLocationSpecificStatus();
                statusChange.setLocationMonitor(locMon);
                statusChange.setPollResult(PollStatus.available());
                statusChange.setMonitoredService(service);
                m_locationMonitorDao.saveStatusChange(statusChange);
            }
            System.err.println("======= End createLocationMonitors() ======");
        }
    });
    Thread.sleep(2000L);
    m_transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            List<OnmsMonitoredService> services = m_monServiceDao.findByType("HTTP");
            for (OnmsMonitoredService service : services) {
                OnmsLocationMonitor locMon = m_locationMonitorDao.findAll().get(0);
                OnmsLocationSpecificStatus statusChange = new OnmsLocationSpecificStatus();
                statusChange.setLocationMonitor(locMon);
                statusChange.setPollResult(PollStatus.unavailable());
                statusChange.setMonitoredService(service);
                m_locationMonitorDao.saveStatusChange(statusChange);
            }
        }
    });
    Thread.sleep(2000L);
    m_transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            List<OnmsMonitoredService> services = m_monServiceDao.findByType("HTTP");
            for (OnmsMonitoredService service : services) {
                OnmsLocationMonitor locMon = m_locationMonitorDao.findAll().get(0);
                OnmsLocationSpecificStatus statusChange = new OnmsLocationSpecificStatus();
                statusChange.setLocationMonitor(locMon);
                statusChange.setPollResult(PollStatus.available());
                statusChange.setMonitoredService(service);
                m_locationMonitorDao.saveStatusChange(statusChange);
            }
        }
    });
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) TransactionStatus(org.springframework.transaction.TransactionStatus) List(java.util.List) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 74 with OnmsMonitoredService

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

the class DefaultLocationDataService method transformApplication.

private static ApplicationInfo transformApplication(final Collection<OnmsMonitoredService> services, final OnmsApplication application) {
    final ApplicationInfo app = new ApplicationInfo();
    app.setId(application.getId());
    app.setName(application.getName());
    final Set<GWTMonitoredService> s = new TreeSet<GWTMonitoredService>();
    final Set<String> locations = new TreeSet<String>();
    for (final OnmsMonitoredService service : services) {
        for (final OnmsApplication oa : service.getApplications()) {
            locations.add(oa.getName());
        }
        s.add(transformMonitoredService(service));
    }
    app.setServices(s);
    app.setLocations(locations);
    return app;
}
Also used : TreeSet(java.util.TreeSet) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 75 with OnmsMonitoredService

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

the class MonitoredServiceDaoIT method testGetByCompositeId.

@Test
@Transactional
public void testGetByCompositeId() {
    final OnmsMonitoredService monSvc = m_monitoredServiceDao.get(m_databasePopulator.getNode1().getId(), addr("192.168.1.1"), "SNMP");
    assertNotNull(monSvc);
    final OnmsMonitoredService monSvc2 = m_monitoredServiceDao.get(m_databasePopulator.getNode1().getId(), addr("192.168.1.1"), monSvc.getIfIndex(), monSvc.getServiceId());
    assertNotNull(monSvc2);
}
Also used : OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

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