use of org.opennms.netmgt.config.datacollection.SnmpCollection in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDao method getMibObjProperties.
@Override
public List<MibObjProperty> getMibObjProperties(final String cName, final String aSysoid, final String anAddress) {
LOG.debug("getMibObjProperties: collection: {} sysoid: {} address: {}", cName, aSysoid, anAddress);
if (aSysoid == null) {
LOG.debug("getMibObjProperties: aSysoid parameter is NULL...");
return new ArrayList<>();
}
final SnmpCollection collection = getSnmpCollection(getContainer(), cName);
if (collection == null) {
return Collections.emptyList();
}
final Systems systems = collection.getSystems();
if (systems == null) {
return Collections.emptyList();
}
final List<SystemDef> systemList = new ArrayList<>();
for (final SystemDef system : systems.getSystemDefs()) {
if (systemDefMatches(system, aSysoid, anAddress)) {
systemList.add(system);
}
}
final List<MibObjProperty> mibProperties = new ArrayList<>();
for (final SystemDef system : systemList) {
for (final String grpName : system.getCollect().getIncludeGroups()) {
processGroupForProperties(cName, grpName, mibProperties);
}
}
return mibProperties;
}
use of org.opennms.netmgt.config.datacollection.SnmpCollection in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testLoadSimpleWithExclusions.
@Test
public void testLoadSimpleWithExclusions() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-excludes.xml"));
DatacollectionConfig config = JaxbUtils.unmarshal(DatacollectionConfig.class, resource, false);
// Validate default datacollection content
SnmpCollection collection = config.getSnmpCollections().get(0);
Assert.assertEquals(1, collection.getIncludeCollections().size());
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertNull(collection.getSystems());
Assert.assertNull(collection.getGroups());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
// 48 systemDef to exclude
Assert.assertEquals(41, collection.getSystems().getSystemDefs().size());
// 1 group to exclude (used only on Cisco PIX or Cisco AS)
Assert.assertEquals(27, collection.getGroups().getGroups().size());
}
use of org.opennms.netmgt.config.datacollection.SnmpCollection in project opennms by OpenNMS.
the class SnmpCollectionForm method createBasicSnmpCollection.
/**
* Creates the basic SNMP collection.
*
* @return the basic example SNMP collection
*/
public SnmpCollection createBasicSnmpCollection() {
SnmpCollection collection = new SnmpCollection();
collection.setName("New Collection");
collection.setSnmpStorageFlag("select");
Rrd rrd = new Rrd();
rrd.setStep(300);
rrd.addRra("RRA:AVERAGE:0.5:1:2016");
rrd.addRra("RRA:AVERAGE:0.5:12:1488");
rrd.addRra("RRA:AVERAGE:0.5:288:366");
rrd.addRra("RRA:MAX:0.5:288:366");
rrd.addRra("RRA:MIN:0.5:288:366");
collection.setRrd(rrd);
return collection;
}
use of org.opennms.netmgt.config.datacollection.SnmpCollection in project opennms by OpenNMS.
the class SnmpCollectionPanel method saveSnmpCollections.
/**
* Save SNMP collections.
*
* @param snmpCollections the SNMP collections
* @param logger the logger
*/
public void saveSnmpCollections(final List<SnmpCollection> snmpCollections, Logger logger) {
try {
final DatacollectionConfig dataCollectionConfig = dataCollectionConfigDao.getRootDataCollection();
File file = ConfigFileConstants.getFile(ConfigFileConstants.DATA_COLLECTION_CONF_FILE_NAME);
logger.info("Saving data colleciton configuration on " + file);
// TODO: Normalize the SNMP Collections Content, I'm not sure why
for (SnmpCollection snmpCollection : snmpCollections) {
snmpCollection.setGroups(null);
snmpCollection.setSystems(null);
}
dataCollectionConfig.setSnmpCollections(snmpCollections);
JaxbUtils.marshal(dataCollectionConfig, new FileWriter(file));
logger.info("The data collection configuration has been saved.");
} catch (Exception e) {
logger.error("An error ocurred while saving the data collection configuration: " + (e.getMessage() == null ? "[No Details]" : e.getMessage()));
if (e.getMessage() == null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
logger.error(sw.toString());
}
Notification.show("Can't save data collection configuration. " + e.getMessage(), Notification.Type.ERROR_MESSAGE);
}
}
Aggregations