@Override public Map<String, ResourceType> getResourceTypes() { final Map<String, ResourceType> resourceTypesByName = new HashMap<>(); resourceTypesByName.putAll(DataCollectionConfigFactory.getInstance().getConfiguredResourceTypes()); final ResourceTypes configuredResourceTypes = getObject(); if (configuredResourceTypes != null) { configuredResourceTypes.getResourceTypes().stream().forEach(r -> resourceTypesByName.put(r.getName(), r)); } return resourceTypesByName; }
/** * Gets the node directory. * * @param nodeId the node id * @param foreignSource the foreign source * @param foreignId the foreign id * @return the node directory */ protected File getNodeDirectory(int nodeId, String foreignSource, String foreignId) { String rrdPath = DataCollectionConfigFactory.getInstance().getRrdPath(); File dir = new File(rrdPath, String.valueOf(nodeId)); if (Boolean.getBoolean("org.opennms.rrd.storeByForeignSource") && !(foreignSource == null) && !(foreignId == null)) { File fsDir = new File(rrdPath, "fs" + File.separatorChar + foreignSource); dir = new File(fsDir, foreignId); } return dir; }
@Override public Date getLastUpdate() { final Date lastUpdateOfDcConfig = DataCollectionConfigFactory.getInstance().getLastUpdate(); final Date lastUpdateOfResourceTypes = super.getLastUpdate(); if (lastUpdateOfDcConfig.after(lastUpdateOfResourceTypes)) { // The data-collection configuration has been updated more recently // than the resource types configuration, so use that date instead return lastUpdateOfDcConfig; } else { return lastUpdateOfResourceTypes; } } }
@Override public void valueChange(Property.ValueChangeEvent event) { String selected = (String) typeField.getValue(); if (selected == null) { return; } // Get available fields. // FIXME If a new dcGroup is added, DataCollectionConfigDao is not able to reach it. List<String> values = selected.equals(IncludeCollectionWrapper.SYSTEM_DEF) ? dataCollectionConfigDao.getAvailableSystemDefs() : dataCollectionConfigDao.getAvailableDataCollectionGroups(); // Remove already selected for (IncludeCollectionWrapper obj : container.getOnmsBeans()) { if (obj.getType().equals(selected)) { values.remove(obj.getValue()); } } // Updating combo-box valueField.removeAllItems(); for (String v : values) { valueField.addItem(v); } if (wrapper.getValue() != null) { valueField.addItem(wrapper.getValue()); } valueField.setEnabled(valueField.getItemIds().size() > 1); } });
if (dataCollectionConfigDao.getAvailableDataCollectionGroups().contains(dcGroup.getName())) { Notification.show("There is a group with the same name, please pick another one."); } else {
groupNames.addAll(dataCollectionConfigDao.getAvailableMibGroups());
/** * Process. * * @param collectionSet the collection set * @param collectionName the collection name */ public void process(final SnmpCollectionSet collectionSet, final String collectionName, final String sysObjectId, final String ipAddress) { final List<MibObjProperty> mibObjProperties = getDataCollectionConfigDao().getMibObjProperties(collectionName, sysObjectId, ipAddress); if (mibObjProperties.isEmpty()) { LOG.debug("process: there are no custom MibObj properties defined for sysObjectID {} in collection {}", collectionName, sysObjectId); } else { LOG.debug("process: analyzing properties for sysObjectID {} in collection {}: {}", sysObjectId, collectionName, mibObjProperties); // Retrieve all the string attributes List<CollectionAttribute> stringAttributes = collectionSet.getResources().stream() .flatMap(r -> ((SnmpCollectionResource) r).getStringAttributes().stream()) .collect(Collectors.toList()); // Apply MIB Properties collectionSet.getResources().forEach(r -> { mibObjProperties.forEach(p -> { if (p.getInstance().equals(r.getResourceTypeName())) { updateCollectionResource(stringAttributes, (SnmpCollectionResource) r, p); } }); }); } }
@Override public void valueChange(Property.ValueChangeEvent event) { String selected = (String) typeField.getValue(); if (selected == null) { return; } // Get available fields. // FIXME If a new dcGroup is added, DataCollectionConfigDao is not able to reach it. List<String> values = selected.equals(IncludeCollectionWrapper.SYSTEM_DEF) ? dataCollectionConfigDao.getAvailableSystemDefs() : dataCollectionConfigDao.getAvailableDataCollectionGroups(); // Remove already selected for (IncludeCollectionWrapper obj : container.getOnmsBeans()) { if (obj.getType().equals(selected)) { values.remove(obj.getValue()); } } // Updating combo-box valueField.removeAllItems(); for (String v : values) { valueField.addItem(v); } if (wrapper.getValue() != null) { valueField.addItem(wrapper.getValue()); } valueField.setEnabled(valueField.getItemIds().size() > 1); } });
if (dataCollectionConfigDao.getAvailableDataCollectionGroups().contains(dcGroup.getName())) { Notification.show("There is a group with the same name, please pick another one."); } else {
groupNames.addAll(dataCollectionConfigDao.getAvailableMibGroups());
private Map<String, ResourceType> getGenericIndexResourceTypeMap(SnmpCollectionAgent agent) { if (m_genericIndexResourceTypes == null) { Collection<org.opennms.netmgt.config.datacollection.ResourceType> configuredResourceTypes = getDataCollectionConfigDao().getConfiguredResourceTypes().values(); Map<String,ResourceType> resourceTypes = new HashMap<String,ResourceType>(); for (org.opennms.netmgt.config.datacollection.ResourceType configuredResourceType : configuredResourceTypes) { try { resourceTypes.put(configuredResourceType.getName(), new GenericIndexResourceType(agent, this, configuredResourceType)); } catch (IllegalArgumentException e) { LOG.warn("Ignoring resource type {} ({}) because it is not properly configured.", configuredResourceType.getLabel(), configuredResourceType.getName()); } } m_genericIndexResourceTypes = resourceTypes; } return m_genericIndexResourceTypes; }
/** * Gets the node directory. * * @param nodeId the node id * @param foreignSource the foreign source * @param foreignId the foreign id * @return the node directory */ protected File getNodeDirectory(int nodeId, String foreignSource, String foreignId) { File dir = new File(DataCollectionConfigFactory.getInstance().getRrdPath(), String.valueOf(nodeId)); if (Boolean.getBoolean("org.opennms.rrd.storeByForeignSource") && !(foreignSource == null) && !(foreignId == null)) { File fsDir = new File(DataCollectionConfigFactory.getInstance().getRrdPath(), "fs" + File.separatorChar + foreignSource); dir = new File(fsDir, foreignId); } return dir; }
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); }
String rrdPath = DataCollectionConfigFactory.getInstance().getRrdPath();
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); }
resourceTypes.addAll(dataCollectionConfigDao.getConfiguredResourceTypes().keySet());
resourceTypes.addAll(dataCollectionConfigDao.getConfiguredResourceTypes().keySet());