Search in sources :

Example 11 with MockDataCollectionConfig

use of org.opennms.netmgt.mock.MockDataCollectionConfig in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createGenericIndexResourceType.

private GenericIndexResourceType createGenericIndexResourceType(SnmpCollectionAgent agent, String resourceTypeName) {
    org.opennms.netmgt.config.datacollection.ResourceType type = createIndexResourceType(agent, resourceTypeName);
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    return new GenericIndexResourceType(agent, collection, type);
}
Also used : HashMap(java.util.HashMap) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection) GenericIndexResourceType(org.opennms.netmgt.collectd.GenericIndexResourceType)

Example 12 with MockDataCollectionConfig

use of org.opennms.netmgt.mock.MockDataCollectionConfig in project opennms by OpenNMS.

the class SnmpCollectorITCase method setUp.

@Before
@Override
public void setUp() throws Exception {
    setStartEventd(false);
    super.setUp();
    m_mockAgent = MockSnmpAgent.createAgentAndRun(new ClassPathResource("org/opennms/netmgt/snmp/snmpTestData1.properties").getURL(), InetAddressUtils.str(myLocalHost()) + "/9161");
    m_config = new MockDataCollectionConfig();
    DataCollectionConfigFactory.setInstance(m_config);
    m_sysNameOid = SnmpObjId.get(".1.3.6.1.2.1.1.5");
    m_ifOutOctets = SnmpObjId.get("..1.3.6.1.2.1.2.2.1.16");
    m_invalid = SnmpObjId.get(".1.5.6.1.2.1.1.5");
    m_ifDescr = SnmpObjId.get(".1.3.6.1.2.1.2.2.1.2");
    m_easyMockUtils = new EasyMockUtils();
    m_ifaceDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    createAgent(1, PrimaryType.PRIMARY);
}
Also used : MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) ClassPathResource(org.springframework.core.io.ClassPathResource) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Before(org.junit.Before)

Example 13 with MockDataCollectionConfig

use of org.opennms.netmgt.mock.MockDataCollectionConfig 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)

Example 14 with MockDataCollectionConfig

use of org.opennms.netmgt.mock.MockDataCollectionConfig in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createInterfaceResourceType.

private IfResourceType createInterfaceResourceType(SnmpCollectionAgent agent) {
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    return new IfResourceType(agent, collection);
}
Also used : IfResourceType(org.opennms.netmgt.collectd.IfResourceType) HashMap(java.util.HashMap) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection)

Example 15 with MockDataCollectionConfig

use of org.opennms.netmgt.mock.MockDataCollectionConfig in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createNodeResourceType.

private NodeResourceType createNodeResourceType(SnmpCollectionAgent agent) {
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    return new NodeResourceType(agent, collection);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) HashMap(java.util.HashMap) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection)

Aggregations

MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)15 HashMap (java.util.HashMap)14 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)14 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)9 Test (org.junit.Test)8 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)6 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)6 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)5 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)5 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)5 MibObject (org.opennms.netmgt.config.datacollection.MibObject)5 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)5 IfResourceType (org.opennms.netmgt.collectd.IfResourceType)4 SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)4 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)4 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)4 RrdPersistOperationBuilder (org.opennms.netmgt.collection.persistence.rrd.RrdPersistOperationBuilder)4 SnmpResult (org.opennms.netmgt.snmp.SnmpResult)4 GenericIndexResourceType (org.opennms.netmgt.collectd.GenericIndexResourceType)3 NodeInfo (org.opennms.netmgt.collectd.NodeInfo)3