/** {@inheritDoc} */ @Override public String getResourceTypeName() { return m_wrapped.getResourceTypeName(); }
/** * <p>getResourceTypeName</p> * * @return a {@link java.lang.String} object. */ public String getResourceTypeName() { return m_resource != null ? m_resource.getResourceTypeName() : null; }
/** * Gets the resource id. * * @param resource the resource * @return the resource id */ protected String getResourceId(CollectionResource resource) { final StringBuilder sb = new StringBuilder(); sb.append(resource.getParent()); sb.append('/').append(resource.getResourceTypeName()); if (!CollectionResource.RESOURCE_TYPE_NODE.equals(resource.getResourceTypeName())) { sb.append('/').append(resource.getInterfaceLabel()); } return sb.toString(); } }
/** * Matches. * * @param sourceType the source type * @param sourceAlias the source alias * @param index the resource index to check * @param a the collection attribute to check * @return true, if successful */ private boolean matches(final String sourceType, final String sourceAlias, final String index, final CollectionAttribute a) { final CollectionResource r = a.getResource(); return a.getName().equals(sourceAlias) && r.getResourceTypeName().equals(sourceType) && r.getInstance().equals(index); }
/** * Gets the attribute map. * * @param sourceAttributes the source attributes * @param type the resource type * @param objName the object name * @return the attribute map */ private Map<String, String> getAttributeMap(List<CollectionAttribute> sourceAttributes, String type, String objName) { Map<String,String> attributes = new HashMap<String,String>(); sourceAttributes.stream().filter(a -> objName.equals(a.getAttributeType().getName()) && type.equals(a.getResource().getResourceTypeName())).forEach(a -> attributes.put(a.getResource().getInstance(), a.getStringValue())); return attributes; }
/** * Gets the attribute value. * * @param sourceAttributes the source attributes * @param index the index * @param type the resource type * @param attrName the attribute name * @return the attribute value */ private String getAttributeValue(List<CollectionAttribute> sourceAttributes, String index, String type, String attrName) { Optional<CollectionAttribute> attr = sourceAttributes.stream().filter(a -> attrName.equals(a.getAttributeType().getName()) && type.equals(a.getResource().getResourceTypeName()) && index.equals(a.getResource().getInstance())).findFirst(); return attr.isPresent() ? attr.get().getStringValue() : null; }
/** * 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); } }); }); } }
String id = "node[" + m_nodeId + "].resourceType[" + m_resource.getResourceTypeName() + "].instance[" + m_resource.getInterfaceLabel() + "].metric[" + ds + "]"; Double current = numValue.doubleValue(); if (!AttributeType.COUNTER.equals(m_attributes.get(ds).getType())) {
return null; LOG.debug("getLabelValue: Getting Value for {}::{}", m_resource.getResourceTypeName(), ds); if ("nodeid".equalsIgnoreCase(ds)) { return Integer.toString(m_nodeId);
/** * <p>hasThresholds</p> * * @param attribute a {@link org.opennms.netmgt.collection.api.CollectionAttribute} object. * @return a boolean. */ public boolean hasThresholds(CollectionAttribute attribute) { CollectionResource resource = attribute.getResource(); if (!isCollectionEnabled(attribute.getResource())) return false; if (resource instanceof AliasedResource && !storeByIfAlias) return false; return hasThresholds(resource.getResourceTypeName(), attribute.getName()); }
@Override public void visitResource(CollectionResource resource) { collectionSetResourceBuilder = CollectionSetProtos.CollectionSetResource.newBuilder(); if (resource.getResourceTypeName().equals(CollectionResource.RESOURCE_TYPE_NODE)) { String nodeCriteria = getNodeCriteriaFromResource(resource); CollectionSetProtos.NodeLevelResource.Builder nodeResourceBuilder = buildNodeLevelResourceForProto( nodeCriteria); collectionSetResourceBuilder.setNode(nodeResourceBuilder); } else if (resource.getResourceTypeName().equals(CollectionResource.RESOURCE_TYPE_IF)) { CollectionSetProtos.InterfaceLevelResource.Builder interfaceResourceBuilder = CollectionSetProtos.InterfaceLevelResource .newBuilder(); nodeCriteria); genericResourceBuilder.setNode(nodeResourceBuilder); genericResourceBuilder.setType(resource.getResourceTypeName()); genericResourceBuilder.setInstance(resource.getInstance()); collectionSetResourceBuilder.setGeneric(genericResourceBuilder);
@Override public void visitResource(CollectionResource resource) { collectionSetResourceBuilder = CollectionSetProtos.CollectionSetResource.newBuilder(); if (resource.getResourceTypeName().equals(CollectionResource.RESOURCE_TYPE_NODE)) { String nodeCriteria = getNodeCriteriaFromResource(resource); CollectionSetProtos.NodeLevelResource.Builder nodeResourceBuilder = buildNodeLevelResourceForProto( nodeCriteria); collectionSetResourceBuilder.setNode(nodeResourceBuilder); } else if (resource.getResourceTypeName().equals(CollectionResource.RESOURCE_TYPE_IF)) { CollectionSetProtos.InterfaceLevelResource.Builder interfaceResourceBuilder = CollectionSetProtos.InterfaceLevelResource .newBuilder(); nodeCriteria); genericResourceBuilder.setNode(nodeResourceBuilder); genericResourceBuilder.setType(resource.getResourceTypeName()); genericResourceBuilder.setInstance(resource.getInstance()); collectionSetResourceBuilder.setGeneric(genericResourceBuilder);