Search in sources :

Example 1 with Category

use of org.opennms.netmgt.config.categories.Category in project opennms by OpenNMS.

the class DefaultCategoryStatusServiceTest method createCategoryFromLabel.

private Category createCategoryFromLabel(String label) {
    Category category = new Category();
    category.setLabel(label);
    category.setNormalThreshold(0d);
    category.setWarningThreshold(0d);
    category.setRule("isHTTP");
    category.addService("HTTP");
    return category;
}
Also used : Category(org.opennms.netmgt.config.categories.Category) StatusCategory(org.opennms.web.svclayer.catstatus.model.StatusCategory)

Example 2 with Category

use of org.opennms.netmgt.config.categories.Category in project opennms by OpenNMS.

the class DefaultCategoryStatusService method createCategory.

private StatusCategory createCategory(String category) {
    Collection<OnmsOutage> outages;
    CategoryBuilder categoryBuilder = new CategoryBuilder();
    StatusCategory statusCategory = new StatusCategory();
    Category categoryDetail = m_categoryConfigDao.getCategoryByLabel(category);
    // statusCategory.setComment(categoryDetail.getCategoryComment());
    statusCategory.setLabel(category);
    ServiceSelector selector = new ServiceSelector(categoryDetail.getRule(), getServicesForCategory(categoryDetail));
    outages = m_outageDao.matchingCurrentOutages(selector);
    for (OnmsOutage outage : outages) {
        OnmsMonitoredService monitoredService = outage.getMonitoredService();
        OnmsServiceType serviceType = monitoredService.getServiceType();
        OnmsIpInterface ipInterface = monitoredService.getIpInterface();
        final String ipAddress = InetAddressUtils.str(ipInterface.getIpAddress());
        categoryBuilder.addOutageService(monitoredService.getNodeId(), ipAddress, ipAddress, ipInterface.getNode().getLabel(), serviceType.getName());
    }
    for (StatusNode node : categoryBuilder.getNodes()) {
        statusCategory.addNode(node);
    }
    return statusCategory;
}
Also used : OnmsOutage(org.opennms.netmgt.model.OnmsOutage) StatusCategory(org.opennms.web.svclayer.catstatus.model.StatusCategory) Category(org.opennms.netmgt.config.categories.Category) StatusCategory(org.opennms.web.svclayer.catstatus.model.StatusCategory) StatusNode(org.opennms.web.svclayer.catstatus.model.StatusNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) ServiceSelector(org.opennms.netmgt.model.ServiceSelector) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService)

Example 3 with Category

use of org.opennms.netmgt.config.categories.Category in project opennms by OpenNMS.

the class DefaultCategoryConfigDao method findAll.

/**
 * <p>findAll</p>
 *
 * @return a {@link java.util.Collection} object.
 */
@Override
public Collection<Category> findAll() {
    List<Category> catList = new ArrayList<>();
    Catinfo catInfo = CategoryFactory.getInstance().getConfig();
    List<CategoryGroup> catGroupList = catInfo.getCategoryGroups();
    if (catGroupList != null) {
        for (final CategoryGroup cg : catGroupList) {
            catList.addAll(cg.getCategories());
        }
    }
    return catList;
}
Also used : Category(org.opennms.netmgt.config.categories.Category) ArrayList(java.util.ArrayList) Catinfo(org.opennms.netmgt.config.categories.Catinfo) CategoryGroup(org.opennms.netmgt.config.categories.CategoryGroup)

Example 4 with Category

use of org.opennms.netmgt.config.categories.Category in project opennms by OpenNMS.

the class DataSenderTest method testSendData.

/*
     * This doesn't work unless we have a receiver on the other end.... more of an integration test
     */
@Test
@Ignore
public void testSendData() throws IOException, FilterParseException, SAXException, SQLException, RTCException {
    InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/config/rtc-configuration.xml");
    RTCConfigFactory configFactory = new RTCConfigFactory(stream);
    stream.close();
    Resource categoryResource = ConfigurationTestUtils.getSpringResourceForResource(this, "/org/opennms/netmgt/config/categories.xml");
    CategoryFactory.setInstance(new CategoryFactory(categoryResource));
    stream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/config/test-database-schema.xml");
    DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(stream));
    stream.close();
    DataManager dataManager = new DataManager();
    String categoryName = "Database Servers";
    String categoryNameUrl = "Database+Servers";
    Category category = new Category();
    category.setLabel(categoryName);
    category.setComment("Some database servers.  Exciting, eh?");
    category.setNormalThreshold(99.0);
    category.setWarningThreshold(97.0);
    RTCCategory rtcCategory = new RTCCategory(category, categoryName);
    Map<String, RTCCategory> rtcCategories = new HashMap<String, RTCCategory>();
    rtcCategories.put(categoryName, rtcCategory);
    DataSender sender = new DataSender(dataManager, configFactory);
    sender.subscribe("http://localhost:8080/opennms-webapp/rtc/post/" + categoryNameUrl, categoryName, "rtc", "rtc");
    sender.sendData();
}
Also used : Category(org.opennms.netmgt.config.categories.Category) RTCCategory(org.opennms.netmgt.rtc.datablock.RTCCategory) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) DatabaseSchemaConfigFactory(org.opennms.netmgt.config.DatabaseSchemaConfigFactory) RTCConfigFactory(org.opennms.netmgt.config.RTCConfigFactory) CategoryFactory(org.opennms.netmgt.config.CategoryFactory) RTCCategory(org.opennms.netmgt.rtc.datablock.RTCCategory) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Category

use of org.opennms.netmgt.config.categories.Category in project opennms by OpenNMS.

the class MockCategoryFactoryTest method testGetCategory.

public void testGetCategory() {
    Category category = m_catFactory.getCategory(CATLABEL);
    assertEquals(99, category.getNormalThreshold(), 0);
    assertEquals(97, category.getWarningThreshold(), 0);
    assertTrue(category.getComment().isPresent());
    assertEquals(CATCOMMENT, category.getComment().get());
    assertEquals(CATRULE, category.getRule());
    assertEquals("ICMP", category.getServices().get(0));
    assertEquals("SNMP", category.getServices().get(1));
}
Also used : Category(org.opennms.netmgt.config.categories.Category)

Aggregations

Category (org.opennms.netmgt.config.categories.Category)5 StatusCategory (org.opennms.web.svclayer.catstatus.model.StatusCategory)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 CategoryFactory (org.opennms.netmgt.config.CategoryFactory)1 DatabaseSchemaConfigFactory (org.opennms.netmgt.config.DatabaseSchemaConfigFactory)1 RTCConfigFactory (org.opennms.netmgt.config.RTCConfigFactory)1 CategoryGroup (org.opennms.netmgt.config.categories.CategoryGroup)1 Catinfo (org.opennms.netmgt.config.categories.Catinfo)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)1 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)1 ServiceSelector (org.opennms.netmgt.model.ServiceSelector)1 RTCCategory (org.opennms.netmgt.rtc.datablock.RTCCategory)1 StatusNode (org.opennms.web.svclayer.catstatus.model.StatusNode)1 Resource (org.springframework.core.io.Resource)1