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;
}
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;
}
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;
}
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();
}
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));
}
Aggregations