Search in sources :

Example 16 with SnmpResult

use of org.opennms.netmgt.snmp.SnmpResult in project opennms by OpenNMS.

the class SnmpMultiResponseDTOTest method getSnmpMultiResponse.

private static SnmpMultiResponseDTO getSnmpMultiResponse() {
    final SnmpValueFactory snmpValueFactory = new Snmp4JValueFactory();
    final SnmpResult result = new SnmpResult(SnmpObjId.get(".1.3.6.1.2"), new SnmpInstId(".1.3.6.1.2.1.4.34.1.3.1.2.3.4"), snmpValueFactory.getCounter64(BigInteger.TEN));
    final SnmpResponseDTO responseDTO = new SnmpResponseDTO();
    responseDTO.setCorrelationId("42");
    responseDTO.getResults().add(result);
    final SnmpMultiResponseDTO multiResponseDTO = new SnmpMultiResponseDTO();
    multiResponseDTO.getResponses().add(responseDTO);
    return multiResponseDTO;
}
Also used : SnmpValueFactory(org.opennms.netmgt.snmp.SnmpValueFactory) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) Snmp4JValueFactory(org.opennms.netmgt.snmp.snmp4j.Snmp4JValueFactory) SnmpResult(org.opennms.netmgt.snmp.SnmpResult)

Example 17 with SnmpResult

use of org.opennms.netmgt.snmp.SnmpResult in project opennms by OpenNMS.

the class RrdPersistOperationBuilderTest method testCommitWithDeclaredAttribute.

@Test
public void testCommitWithDeclaredAttribute() throws Exception {
    File nodeDir = m_fileAnticipator.expecting(getSnmpRrdDirectory(), m_node.getId().toString());
    m_fileAnticipator.expecting(nodeDir, "rrdName" + m_rrdStrategy.getDefaultFileExtension());
    m_fileAnticipator.expecting(nodeDir, "rrdName" + ".meta");
    RrdRepository repository = createRrdRepository();
    SnmpCollectionAgent agent = getCollectionAgent();
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    NodeResourceType resourceType = new NodeResourceType(agent, collection);
    CollectionResource resource = new NodeInfo(resourceType, agent);
    MibObject mibObject = new MibObject();
    mibObject.setOid(".1.1.1.1");
    mibObject.setAlias("mibObjectAlias");
    mibObject.setType("counter");
    mibObject.setInstance("0");
    mibObject.setMaxval(null);
    mibObject.setMinval(null);
    SnmpCollectionSet collectionSet = new SnmpCollectionSet(agent, collection, m_locationAwareSnmpClient);
    SnmpAttributeType attributeType = new NumericAttributeType(resourceType, "some-collection", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));
    attributeType.storeResult(collectionSet, null, new SnmpResult(mibObject.getSnmpObjId(), new SnmpInstId(mibObject.getInstance()), SnmpUtils.getValueFactory().getOctetString("hello".getBytes())));
    RrdPersistOperationBuilder builder = new RrdPersistOperationBuilder(m_rrdStrategy, repository, resource, "rrdName", false);
    builder.declareAttribute(attributeType);
    builder.commit();
}
Also used : CollectionResource(org.opennms.netmgt.collection.api.CollectionResource) RrdPersistOperationBuilder(org.opennms.netmgt.collection.persistence.rrd.RrdPersistOperationBuilder) HashMap(java.util.HashMap) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) AttributeGroupType(org.opennms.netmgt.collection.api.AttributeGroupType) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) MibObject(org.opennms.netmgt.config.datacollection.MibObject) File(java.io.File) SnmpResult(org.opennms.netmgt.snmp.SnmpResult) Test(org.junit.Test)

Aggregations

SnmpResult (org.opennms.netmgt.snmp.SnmpResult)17 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)9 Test (org.junit.Test)8 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)8 SnmpObjId (org.opennms.netmgt.snmp.SnmpObjId)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)4 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)4 MibObject (org.opennms.netmgt.config.datacollection.MibObject)4 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)4 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)4 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)3 RrdPersistOperationBuilder (org.opennms.netmgt.collection.persistence.rrd.RrdPersistOperationBuilder)3 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)3 File (java.io.File)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 AggregateTracker (org.opennms.netmgt.snmp.AggregateTracker)2 Collectable (org.opennms.netmgt.snmp.Collectable)2