private Resource getWmiResource(CollectionAgent agent, String resourceType, NodeLevelResource nodeResource, String instance) { ResourceType rt = DataCollectionConfigFactory.getInstance().getConfiguredResourceTypes().get(resourceType); if (rt == null) { LOG.debug("getWmiResourceType: using default WMI resource type strategy - index / all"); rt = new ResourceType(); rt.setName(resourceType); rt.setStorageStrategy(new StorageStrategy()); rt.getStorageStrategy().setClazz(IndexStorageStrategy.class.getName()); rt.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy()); rt.getPersistenceSelectorStrategy().setClazz(PersistAllSelectorStrategy.class.getName()); } return new GenericTypeResource(nodeResource, rt, instance); }
private Resource getWmiResource(CollectionAgent agent, String resourceType, NodeLevelResource nodeResource, String instance) { ResourceType rt = DataCollectionConfigFactory.getInstance().getConfiguredResourceTypes().get(resourceType); if (rt == null) { LOG.debug("getWmiResourceType: using default WMI resource type strategy - index / all"); rt = new ResourceType(); rt.setName(resourceType); rt.setStorageStrategy(new StorageStrategy()); rt.getStorageStrategy().setClazz(IndexStorageStrategy.class.getName()); rt.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy()); rt.getPersistenceSelectorStrategy().setClazz(PersistAllSelectorStrategy.class.getName()); } return new GenericTypeResource(nodeResource, rt, instance); }
@Override protected StorageStrategy getInternalValue() { StorageStrategy strategy = new StorageStrategy(); if (combo.getValue() != null) { strategy.setClazz((String) combo.getValue()); } for (Object itemId: container.getItemIds()) { strategy.addParameter(container.getItem(itemId).getBean()); } return strategy; }
@Override protected StorageStrategy getInternalValue() { StorageStrategy strategy = new StorageStrategy(); if (combo.getValue() != null) { strategy.setClazz((String) combo.getValue()); } for (Object itemId: container.getItemIds()) { strategy.addParameter(container.getItem(itemId).getBean()); } return strategy; }
/** * Creates the basic resource type. * * @return the resource type */ public ResourceType createBasicResourceType() { ResourceType rt = new ResourceType(); rt.setName("New Resource Type"); rt.setLabel("New Resource Type"); rt.setResourceLabel("{index}"); PersistenceSelectorStrategy persistence = new PersistenceSelectorStrategy(); persistence.setClazz("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy"); // To avoid requires opennms-services rt.setPersistenceSelectorStrategy(persistence); StorageStrategy storage = new StorageStrategy(); storage.setClazz(IndexStorageStrategy.class.getName()); rt.setStorageStrategy(storage); return rt; }
/** * Creates the basic resource type. * * @return the resource type */ public ResourceType createBasicResourceType() { ResourceType rt = new ResourceType(); rt.setName("New Resource Type"); rt.setLabel("New Resource Type"); rt.setResourceLabel("{index}"); PersistenceSelectorStrategy persistence = new PersistenceSelectorStrategy(); persistence.setClazz("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy"); // To avoid requires opennms-services rt.setPersistenceSelectorStrategy(persistence); StorageStrategy storage = new StorageStrategy(); storage.setClazz(IndexStorageStrategy.class.getName()); rt.setStorageStrategy(storage); return rt; }
private static org.opennms.netmgt.config.datacollection.ResourceType createIndexResourceType(SnmpCollectionAgent agent, String resourceTypeName) { org.opennms.netmgt.config.datacollection.ResourceType type = new org.opennms.netmgt.config.datacollection.ResourceType(); type.setName(resourceTypeName); type.setLabel(resourceTypeName); org.opennms.netmgt.config.datacollection.StorageStrategy strategy = new org.opennms.netmgt.config.datacollection.StorageStrategy(); strategy.setClazz(IndexStorageStrategy.class.getCanonicalName()); type.setStorageStrategy(strategy); org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy pstrategy = new org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy(); pstrategy.setClazz(PersistAllSelectorStrategy.class.getCanonicalName()); type.setPersistenceSelectorStrategy(pstrategy); return type; }
/** * 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}"); type.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy")); // To avoid requires opennms-services type.setStorageStrategy(new StorageStrategy(IndexStorageStrategy.class.getName())); data.addResourceType(type); } data.addGroup(group); return group; }
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; } }
/** * 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}"); type.setPersistenceSelectorStrategy(new PersistenceSelectorStrategy("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy")); // To avoid requires opennms-services type.setStorageStrategy(new StorageStrategy(IndexStorageStrategy.class.getName())); data.addResourceType(type); } data.addGroup(group); return group; }
private GenericIndexResourceType instantiate() { org.opennms.netmgt.config.datacollection.ResourceType rt = new org.opennms.netmgt.config.datacollection.ResourceType(); PersistenceSelectorStrategy ps = new PersistenceSelectorStrategy(); ps.setClazz("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy"); rt.setPersistenceSelectorStrategy(ps); StorageStrategy ss = new StorageStrategy(); ss.setClazz("org.opennms.netmgt.collection.support.IndexStorageStrategy"); rt.setStorageStrategy(ss); return new GenericIndexResourceType(null, null, rt); } }
private static org.opennms.netmgt.config.datacollection.ResourceType createWmiLogicalDiskResourceType() { org.opennms.netmgt.config.datacollection.ResourceType wmiLogicalDisk = new org.opennms.netmgt.config.datacollection.ResourceType(); wmiLogicalDisk.setName("wmiLogicalDisk"); wmiLogicalDisk.setLabel("(wsman) Logical Storage"); wmiLogicalDisk.setResourceLabel("Logical Disk (${wmiLDName})"); PersistenceSelectorStrategy pss = new PersistenceSelectorStrategy(); pss.setClazz(PersistAllSelectorStrategy.class.getCanonicalName()); wmiLogicalDisk.setPersistenceSelectorStrategy(pss); StorageStrategy ss = new StorageStrategy(); ss.setClazz(SiblingColumnStorageStrategy.class.getCanonicalName()); org.opennms.netmgt.config.datacollection.Parameter siblingColumnName = new org.opennms.netmgt.config.datacollection.Parameter(); siblingColumnName.setKey("sibling-column-name"); siblingColumnName.setValue("wmiLDName"); ss.addParameter(siblingColumnName); wmiLogicalDisk.setStorageStrategy(ss); return wmiLogicalDisk; }
@Test public void testGenericResource() 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("hrStorageIndex"); rt.setLabel("host-resources storage"); StorageStrategy strategy = new StorageStrategy(); strategy.setClazz("org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy"); strategy.addParameter(new Parameter("sibling-column-name", "hrStorageLabel")); 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 used = addAttributeToCollectionResource(resource, "hrStorageUsed", AttributeType.GAUGE, "hrStorageIndex", "5000"); SnmpAttribute label = addAttributeToCollectionResource(resource, "hrStorageLabel", AttributeType.STRING, "hrStorageIndex", "/opt"); Map<String, CollectionAttribute> attributes = new HashMap<String, CollectionAttribute>(); attributes.put(used.getName(), used); attributes.put(label.getName(), label); CollectionResourceWrapper wrapper = createWrapper(resource, attributes); Assert.assertEquals("opt", wrapper.getInstanceLabel()); }
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"));
StorageStrategy storageStrategy = new StorageStrategy(); storageStrategy.setClazz("org.opennms.netmgt.collection.support.IndexStorageStrategy"); rt.setStorageStrategy(storageStrategy);