Search in sources :

Example 81 with OnmsMonitoredService

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

the class WebOutageRepositoryFilterIT method setUp.

@Before
public void setUp() {
    m_dbPopulator.populateDatabase();
    OnmsMonitoredService svc2 = m_dbPopulator.getMonitoredServiceDao().get(m_dbPopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP");
    // This requires every test method to have a new database instance :/
    OnmsEvent event = m_dbPopulator.getEventDao().get(1);
    OnmsOutage unresolved2 = new OnmsOutage(new Date(), event, svc2);
    m_dbPopulator.getOutageDao().save(unresolved2);
    m_dbPopulator.getOutageDao().flush();
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsOutage(org.opennms.netmgt.model.OnmsOutage) Date(java.util.Date) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Before(org.junit.Before)

Example 82 with OnmsMonitoredService

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

the class RestClient method getServicesForANode.

public List<OnmsMonitoredService> getServicesForANode(String nodeCriteria, String ipAddress) {
    GenericType<List<OnmsMonitoredService>> services = new GenericType<List<OnmsMonitoredService>>() {
    };
    final WebTarget target = getTarget().path("nodes").path(nodeCriteria).path("ipinterfaces").path(ipAddress).path("services");
    return getBuilder(target).get(services);
}
Also used : GenericType(javax.ws.rs.core.GenericType) List(java.util.List) WebTarget(javax.ws.rs.client.WebTarget) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 83 with OnmsMonitoredService

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

the class Poller method scheduleServices.

private int scheduleServices() {
    final Criteria criteria = new Criteria(OnmsMonitoredService.class);
    criteria.addRestriction(new InRestriction("status", Arrays.asList("A", "N")));
    return m_transactionTemplate.execute(new TransactionCallback<Integer>() {

        @Override
        public Integer doInTransaction(TransactionStatus arg0) {
            final List<OnmsMonitoredService> services = m_monitoredServiceDao.findMatching(criteria);
            for (OnmsMonitoredService service : services) {
                scheduleService(service);
            }
            return services.size();
        }
    });
}
Also used : InRestriction(org.opennms.core.criteria.restrictions.InRestriction) TransactionStatus(org.springframework.transaction.TransactionStatus) List(java.util.List) Criteria(org.opennms.core.criteria.Criteria) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 84 with OnmsMonitoredService

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

the class DefaultDistributedStatusService method initializeGraphUrls.

private void initializeGraphUrls(DistributedStatusHistoryModel model) {
    if (model.getChosenMonitor() != null) {
        Collection<OnmsMonitoredService> services = model.getChosenApplicationMemberServices();
        long[] times = model.getChosenPeriod().getStartAndEndTimes();
        SortedSet<ServiceGraph> serviceGraphs = new TreeSet<ServiceGraph>(SERVICE_GRAPH_COMPARATOR);
        for (OnmsMonitoredService service : services) {
            serviceGraphs.add(getServiceGraphForService(model.getChosenMonitor(), service, times));
        }
        model.setServiceGraphs(serviceGraphs);
    }
}
Also used : TreeSet(java.util.TreeSet) ServiceGraph(org.opennms.web.svclayer.model.DistributedStatusHistoryModel.ServiceGraph) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 85 with OnmsMonitoredService

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

the class DefaultSiteStatusServiceIT method createOutageForNodeInCategory.

private void createOutageForNodeInCategory(String categoryName) {
    OnmsCategory category = m_categoryDao.findByName(categoryName);
    Collection<OnmsNode> nodes = m_nodeDao.findByCategory(category);
    assertNotNull(nodes);
    assertFalse(nodes.isEmpty());
    /*
         * There should only be 1 node per category based on the set of
         * default nodes that are stored in {@link DatabasePopulator}
         */
    assertEquals(1, nodes.size());
    OnmsNode node = nodes.iterator().next();
    node.visit(new AbstractEntityVisitor() {

        @Override
        public void visitMonitoredService(OnmsMonitoredService monSvc) {
            createOutageForService(monSvc);
        }
    });
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) AbstractEntityVisitor(org.opennms.netmgt.model.AbstractEntityVisitor) 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