Search in sources :

Example 1 with TcaDataCollectionConfig

use of org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig in project opennms by OpenNMS.

the class TcaCollectorComplianceIT method getRequiredBeans.

@Override
public Map<String, Object> getRequiredBeans() {
    TcaDataCollectionConfig config = mock(TcaDataCollectionConfig.class);
    RrdRepository rrdRepository = new RrdRepository();
    rrdRepository.setRrdBaseDir(new File("target"));
    when(config.buildRrdRepository(COLLECTION)).thenReturn(rrdRepository);
    TcaDataCollectionConfigDao tcaDataCollectionConfigDao = mock(TcaDataCollectionConfigDao.class);
    when(tcaDataCollectionConfigDao.getConfig()).thenReturn(config);
    ResourceStorageDao resourceStorageDao = mock(ResourceStorageDao.class);
    ResourceTypesDao resourceTypesDao = mock(ResourceTypesDao.class);
    ResourceType resourceType = TcaCollectorIT.getJuniperTcaEntryResourceType();
    when(resourceTypesDao.getResourceTypeByName(TcaCollectionHandler.RESOURCE_TYPE_NAME)).thenReturn(resourceType);
    return new ImmutableMap.Builder<String, Object>().put("tcaDataCollectionConfigDao", tcaDataCollectionConfigDao).put("resourceStorageDao", resourceStorageDao).put("resourceTypesDao", resourceTypesDao).put("locationAwareSnmpClient", m_client).build();
}
Also used : ResourceStorageDao(org.opennms.netmgt.dao.api.ResourceStorageDao) TcaDataCollectionConfigDao(org.opennms.netmgt.collectd.tca.dao.TcaDataCollectionConfigDao) ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) File(java.io.File) TcaDataCollectionConfig(org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with TcaDataCollectionConfig

use of org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig in project opennms by OpenNMS.

the class TcaCollectorIT method setUp.

/**
 * Sets the up.
 *
 * @throws Exception the exception
 */
@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_tempFolder.newFolder("snmp");
    m_resourceStorageDao.setRrdDirectory(m_tempFolder.getRoot());
    OnmsIpInterface iface = null;
    OnmsNode testNode = null;
    Collection<OnmsNode> testNodes = m_nodeDao.findByLabel(TEST_NODE_LABEL);
    if (testNodes == null || testNodes.size() < 1) {
        NetworkBuilder builder = new NetworkBuilder();
        builder.addNode(TEST_NODE_LABEL).setId(1).setSysObjectId(".1.3.6.1.4.1.1588.2.1.1.1");
        InterfaceBuilder ifBldr = builder.addInterface(TEST_NODE_IP).setIsSnmpPrimary("P");
        ifBldr.addSnmpInterface(6).setIfName("fw0").setPhysAddr("44:33:22:11:00").setIfType(144).setCollectionEnabled(true);
        testNode = builder.getCurrentNode();
        Assert.assertNotNull(testNode);
        m_nodeDao.save(testNode);
        m_nodeDao.flush();
    } else {
        testNode = testNodes.iterator().next();
    }
    Set<OnmsIpInterface> ifaces = testNode.getIpInterfaces();
    Assert.assertEquals(1, ifaces.size());
    iface = ifaces.iterator().next();
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    m_collectionAgent = DefaultSnmpCollectionAgent.create(iface.getId(), m_ipInterfaceDao, m_transactionManager);
    TcaRrd rrd = new TcaRrd();
    rrd.addRra("RRA:AVERAGE:0.5:1:3600");
    rrd.addRra("RRA:AVERAGE:0.5:300:288");
    rrd.addRra("RRA:MIN:0.5:300:288");
    rrd.addRra("RRA:MAX:0.5:300:288");
    rrd.addRra("RRA:AVERAGE:0.5:900:2880");
    rrd.addRra("RRA:MIN:0.5:900:2880");
    rrd.addRra("RRA:MAX:0.5:900:2880");
    rrd.addRra("RRA:AVERAGE:0.5:3600:4300");
    rrd.addRra("RRA:MIN:0.5:3600:4300");
    rrd.addRra("RRA:MAX:0.5:3600:4300");
    TcaDataCollection tcadc = new TcaDataCollection();
    tcadc.setName("default");
    tcadc.setRrd(rrd);
    TcaDataCollectionConfig tcadcc = new TcaDataCollectionConfig();
    tcadcc.addDataCollection(tcadc);
    tcadcc.setRrdRepository(getSnmpRoot().getAbsolutePath());
    EasyMock.expect(m_configDao.getConfig()).andReturn(tcadcc).atLeastOnce();
    EasyMock.replay(m_configDao);
    // Define the resource type
    ResourceType resourceType = getJuniperTcaEntryResourceType();
    m_resourceTypesDao = EasyMock.createMock(ResourceTypesDao.class);
    EasyMock.expect(m_resourceTypesDao.getResourceTypeByName(TcaCollectionHandler.RESOURCE_TYPE_NAME)).andReturn(resourceType).anyTimes();
    EasyMock.replay(m_resourceTypesDao);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) TcaRrd(org.opennms.netmgt.collectd.tca.config.TcaRrd) ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) InterfaceBuilder(org.opennms.netmgt.model.NetworkBuilder.InterfaceBuilder) TcaDataCollection(org.opennms.netmgt.collectd.tca.config.TcaDataCollection) TcaDataCollectionConfig(org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig) Before(org.junit.Before)

Aggregations

TcaDataCollectionConfig (org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig)2 ResourceTypesDao (org.opennms.netmgt.config.api.ResourceTypesDao)2 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 Before (org.junit.Before)1 TcaDataCollection (org.opennms.netmgt.collectd.tca.config.TcaDataCollection)1 TcaRrd (org.opennms.netmgt.collectd.tca.config.TcaRrd)1 TcaDataCollectionConfigDao (org.opennms.netmgt.collectd.tca.dao.TcaDataCollectionConfigDao)1 ResourceStorageDao (org.opennms.netmgt.dao.api.ResourceStorageDao)1 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)1 InterfaceBuilder (org.opennms.netmgt.model.NetworkBuilder.InterfaceBuilder)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)1