use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.
the class JsmiMibParser method getGroup.
/**
* Gets the group.
*
* @param data the data collection group object
* @param groupName the group name
* @param resourceType the resource type
* @return the group
*/
protected Group getGroup(DatacollectionGroup data, String groupName, String resourceType) {
for (Group group : data.getGroups()) {
if (group.getName().equals(groupName))
return group;
}
Group group = new Group();
group.setName(groupName);
group.setIfType(resourceType == null ? "ignore" : "all");
if (resourceType != null) {
ResourceType type = new ResourceType();
type.setName(resourceType);
type.setLabel(resourceType);
type.setResourceLabel("${index}");
// To avoid requires opennms-services
type.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy"));
type.setStorageStrategy(new StorageStrategy(IndexStorageStrategy.class.getName()));
data.addResourceType(type);
}
data.addGroup(group);
return group;
}
use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.
the class ResourceDaoIntegrityIT method createResourceTypes.
/**
* Define a resource type so that test the GenericIndexResourceType
*/
private Map<String, ResourceType> createResourceTypes() {
Map<String, ResourceType> types = new HashMap<String, ResourceType>();
ResourceType hrStorageIndex = new ResourceType();
hrStorageIndex.setName("hrStorageIndex");
hrStorageIndex.setLabel("Storage (SNMP MIB-2 Host Resources)");
hrStorageIndex.setResourceLabel("${hrStorageDescr}");
hrStorageIndex.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy("org.opennms.netmgt.collectd.PersistAllSelectorStrategy"));
StorageStrategy storageStrategy = new StorageStrategy("org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy");
storageStrategy.addParameter(new Parameter("sibling-column-name", "hrStorageDescr"));
storageStrategy.addParameter(new Parameter("replace-first", "s/^-$/_root_fs/"));
storageStrategy.addParameter(new Parameter("replace-all", "s/^-//"));
storageStrategy.addParameter(new Parameter("replace-all", "s/\\s//"));
storageStrategy.addParameter(new Parameter("replace-all", "s/:\\\\.*//"));
hrStorageIndex.setStorageStrategy(storageStrategy);
types.put(hrStorageIndex.getName(), hrStorageIndex);
return types;
}
use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.
the class CollectionResourceWrapperIT method testNumericFields.
@Test
public void testNumericFields() throws Exception {
SnmpCollectionAgent agent = createCollectionAgent();
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
ResourceType rt = new ResourceType();
rt.setName("dskIndex");
rt.setLabel("Disk Table Index (UCD-SNMP MIB)");
StorageStrategy strategy = new StorageStrategy();
strategy.setClazz("org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy");
strategy.addParameter(new Parameter("sibling-column-name", "ns-dskPath"));
strategy.addParameter(new Parameter("replace-first", "s/^-$/_root_fs/"));
strategy.addParameter(new Parameter("replace-all", "s/^-//"));
strategy.addParameter(new Parameter("replace-all", "s/\\s//"));
strategy.addParameter(new Parameter("replace-all", "s/:\\\\.*//"));
rt.setStorageStrategy(strategy);
PersistenceSelectorStrategy pstrategy = new PersistenceSelectorStrategy();
pstrategy.setClazz("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy");
rt.setPersistenceSelectorStrategy(pstrategy);
GenericIndexResourceType resourceType = new GenericIndexResourceType(agent, collection, rt);
SnmpCollectionResource resource = new GenericIndexResource(resourceType, resourceType.getName(), new SnmpInstId(100));
SnmpAttribute total = addAttributeToCollectionResource(resource, "ns-dskTotal", AttributeType.GAUGE, "dskIndex", "10000");
SnmpAttribute used = addAttributeToCollectionResource(resource, "ns-dskUsed", AttributeType.GAUGE, "dskIndex", "5000");
SnmpAttribute label = addAttributeToCollectionResource(resource, "ns-dskPath", AttributeType.STRING, "dskIndex", "/opt");
Map<String, CollectionAttribute> attributes = new HashMap<String, CollectionAttribute>();
attributes.put(used.getName(), used);
attributes.put(total.getName(), total);
attributes.put(label.getName(), label);
CollectionResourceWrapper wrapper = createWrapper(resource, attributes);
Assert.assertEquals("opt", wrapper.getInstanceLabel());
Assert.assertEquals(new Double("10000.0"), wrapper.getAttributeValue(total.getName()));
Assert.assertEquals("10000.0", wrapper.getFieldValue(total.getName()));
}
use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.
the class XmlCollectorTestUtils method getResourceType.
public static ResourceType getResourceType(String resourceType) {
ResourceType rt = new ResourceType();
rt.setName(resourceType);
rt.setStorageStrategy(new StorageStrategy());
rt.getStorageStrategy().setClazz(XmlStorageStrategy.class.getName());
rt.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy());
rt.getPersistenceSelectorStrategy().setClazz(PersistAllSelectorStrategy.class.getName());
return rt;
}
use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.
the class TcaCollectorIT method getJuniperTcaEntryResourceType.
public static ResourceType getJuniperTcaEntryResourceType() {
final ResourceType resourceType = new ResourceType();
resourceType.setName("juniperTcaEntry");
resourceType.setLabel("Juniper TCA Entry");
resourceType.setResourceLabel("Peer ${index}");
StorageStrategy storageStrategy = new StorageStrategy();
storageStrategy.setClazz(IndexStorageStrategy.class.getCanonicalName());
resourceType.setStorageStrategy(storageStrategy);
PersistenceSelectorStrategy persistenceSelectorStrategy = new PersistenceSelectorStrategy();
persistenceSelectorStrategy.setClazz(PersistAllSelectorStrategy.class.getCanonicalName());
resourceType.setPersistenceSelectorStrategy(persistenceSelectorStrategy);
return resourceType;
}
Aggregations