public LatencyCollectionAttributeType(String groupTypeName, String attributeTypeName) { super(new AttributeGroupType(groupTypeName, AttributeGroupType.IF_TYPE_ALL)); m_name = attributeTypeName; }
protected String getIfType() { return m_groupType.getIfType(); }
/** * <p>getName</p> * * @return a {@link java.lang.String} object. */ public String getName() { return m_groupType.getName(); }
@Override public void visitGroup(AttributeGroup group) { pushShouldPersist(group); if (shouldPersist()) { setBuilder(createBuilder(group.getResource(), group.getName(), group.getGroupType().getAttributeTypes())); } }
/** * <p>loadAttributeTypes</p> * * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. * @param ifType a int. * @return a {@link java.util.List} object. */ public List<SnmpAttributeType> loadAttributeTypes(SnmpCollectionAgent agent, int ifType) { String sysObjectId = agent.getSysObjectId(); String hostAddress = agent.getHostAddress(); List<MibObject> oidList = getDataCollectionConfigDao().getMibObjectList(getName(), sysObjectId, hostAddress, ifType); Map<String, AttributeGroupType> groupTypes = new HashMap<String, AttributeGroupType>(); List<SnmpAttributeType> typeList = new LinkedList<>(); for (MibObject mibObject : oidList) { String instanceName = mibObject.getInstance(); AttributeGroupType groupType = findGroup(groupTypes, mibObject); SnmpAttributeType attrType = SnmpAttributeType.create(getResourceType(agent, instanceName), getName(), mibObject, groupType); groupType.addAttributeType(attrType); typeList.add(attrType); } LOG.debug("getAttributeTypes({}, {}): {}", agent, ifType, typeList); return typeList; }
/** {@inheritDoc} */ @Override public void visitGroup(AttributeGroup group) { pushShouldPersist(group); if (shouldPersist()) { Map<String, String> dsNamesToRrdNames = new LinkedHashMap<String , String>(); for (CollectionAttribute a : group.getAttributes()) { if (a.getType().isNumeric()) { dsNamesToRrdNames.put(a.getName(), group.getName()); } } setBuilder(createBuilder(group.getResource(), group.getName(), group.getGroupType().getAttributeTypes())); ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(getRepository(), group.getResource().getPath()); m_resourceStorageDao.updateMetricToResourceMappings(path, dsNamesToRrdNames); } }
public DistributedLatencyCollectionAttributeType(String groupTypeName, String attributeTypeName) { super(new AttributeGroupType(groupTypeName, AttributeGroupType.IF_TYPE_ALL)); m_name = attributeTypeName; }
protected AttributeGroupType getGroupType(final String groupName) { for (AttributeGroupType type : m_groups.keySet()) { if (type.getName().equals(groupName)) { return type; } } return null; } /** {@inheritDoc} */
/** {@inheritDoc} */ @Override public void visitGroup(AttributeGroup group) { pushShouldPersist(group); if (shouldPersist()) { Map<String, String> dsNamesToRrdNames = new LinkedHashMap<String , String>(); for (CollectionAttribute a : group.getAttributes()) { if (a.getType().isNumeric()) { dsNamesToRrdNames.put(a.getName(), group.getName()); } } setBuilder(createBuilder(group.getResource(), group.getName(), group.getGroupType().getAttributeTypes())); ResourcePath path = ResourceTypeUtils.getResourcePathWithRepository(getRepository(), group.getResource().getPath()); m_resourceStorageDao.updateMetricToResourceMappings(path, dsNamesToRrdNames); } }
/** * <p>getGroupIfType</p> * * @return a {@link java.lang.String} object. */ public String getGroupIfType() { return getGroupType().getIfType(); }
public DistributedLatencyCollectionAttributeType(String groupTypeName, String attributeTypeName) { super(new AttributeGroupType(groupTypeName, AttributeGroupType.IF_TYPE_ALL)); m_name = attributeTypeName; }
/** * <p>getGroupName</p> * * @return a {@link java.lang.String} object. */ public String getGroupName() { return getGroupType().getName(); }
private AttributeGroupType findGroup(Map<String, AttributeGroupType> groupTypes, MibObject mibObject) { AttributeGroupType groupType = groupTypes.get(mibObject.getGroupName()); if (groupType == null) { groupType = new AttributeGroupType(mibObject.getGroupName(), mibObject.getGroupIfType()); groupTypes.put(mibObject.getGroupName(), groupType); } return groupType; }
final AbstractCollectionResource collectionResource = CollectionSetBuilder.toCollectionResource(resource, agent); for (Attribute<?> attribute : entry.getAttributes()) { final AttributeGroupType groupType = new AttributeGroupType(attribute.getGroup(), AttributeGroupType.IF_TYPE_ALL); final AbstractCollectionAttributeType attributeType = new AbstractCollectionAttributeType(groupType) { @Override
private static void addAttributeToCollectionResource(SnmpCollectionResource resource, ResourceType type, String attributeName, String attributeType, String attributeInstance, long value) { MibObject object = createMibObject(attributeType, attributeName, attributeInstance); SnmpAttributeType objectType = new NumericAttributeType(type, "default", object, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE)); SnmpValue snmpValue = attributeType.equals("counter") ? SnmpUtils.getValueFactory().getCounter32(value) : SnmpUtils.getValueFactory().getGauge32(value); resource.setAttributeValue(objectType, snmpValue); }
private SnmpAttribute addAttributeToCollectionResource(SnmpCollectionResource resource, String attributeName, AttributeType attributeType, String attributeInstance, BigInteger value) { MibObject object = createMibObject(attributeType, attributeName, attributeInstance); SnmpAttributeType objectType = new NumericAttributeType(resource.getResourceType(), "default", object, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE)); SnmpValue snmpValue = SnmpUtils.getValueFactory().getCounter64(value); resource.setAttributeValue(objectType, snmpValue); return new SnmpAttribute(resource, objectType, snmpValue); }
private SnmpAttribute addAttributeToCollectionResource(SnmpCollectionResource resource, String attributeName, AttributeType attributeType, String attributeInstance, String value) { MibObject object = createMibObject(attributeType, attributeName, attributeInstance); SnmpAttributeType objectType = null; SnmpValue snmpValue = null; if (AttributeType.STRING.equals(attributeType)) { objectType = new SnmpAttributeType(resource.getResourceType(), "default", object, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE)) { @Override public AttributeType getType() { return AttributeType.STRING; } @Override public void storeAttribute(CollectionAttribute attribute, Persister persister) { persister.persistStringAttribute(attribute); } }; snmpValue = SnmpUtils.getValueFactory().getOctetString(value.getBytes()); } else { objectType = new NumericAttributeType(resource.getResourceType(), "default", object, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE)); long v = Long.parseLong(value); snmpValue = AttributeType.COUNTER.equals(attributeType) ? SnmpUtils.getValueFactory().getCounter32(v) : SnmpUtils.getValueFactory().getGauge32(v); } resource.setAttributeValue(objectType, snmpValue); return new SnmpAttribute(resource, objectType, snmpValue); }
/** * <p>loadAliasAttributeTypes</p> * * @param agent a {@link org.opennms.netmgt.collection.api.CollectionAgent} object. * @return a {@link java.util.List} object. */ public List<SnmpAttributeType> loadAliasAttributeTypes(SnmpCollectionAgent agent) { IfAliasResourceType resType = getIfAliasResourceType(agent); MibObject ifAliasMibObject = new MibObject(); ifAliasMibObject.setOid(".1.3.6.1.2.1.31.1.1.1.18"); ifAliasMibObject.setAlias("ifAlias"); ifAliasMibObject.setType("string"); ifAliasMibObject.setInstance("ifIndex"); ifAliasMibObject.setGroupName("aliasedResource"); ifAliasMibObject.setGroupIfType(AttributeGroupType.IF_TYPE_ALL); AttributeGroupType groupType = new AttributeGroupType(ifAliasMibObject.getGroupName(), ifAliasMibObject.getGroupIfType()); SnmpAttributeType type = SnmpAttributeType.create(resType, resType.getCollectionName(), ifAliasMibObject, groupType); return Collections.singletonList(type); }
private SnmpAttribute buildStringAttribute() { EasyMock.expect(m_ifDao.load(m_intf.getId())).andReturn(m_intf).anyTimes(); m_easyMockUtils.replayAll(); SnmpCollectionAgent agent = DefaultSnmpCollectionAgent.create(m_intf.getId(), m_ifDao, m_transMgr); MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig(); OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient); NodeResourceType resourceType = new NodeResourceType(agent, collection); SnmpCollectionResource resource = new NodeInfo(resourceType, agent); MibObject mibObject = new MibObject(); mibObject.setOid(".1.1.1.1"); mibObject.setAlias("mibObjectAlias"); mibObject.setType("string"); mibObject.setInstance("0"); mibObject.setMaxval(null); mibObject.setMinval(null); SnmpAttributeType attributeType = new StringAttributeType(resourceType, "some-collection", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE)); return new SnmpAttribute(resource, attributeType, SnmpUtils.getValueFactory().getOctetString("foo".getBytes())); }
SnmpAttributeType objectType = new NumericAttributeType(resourceType, "default", object, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));