Search in sources :

Example 1 with TcaDataCollection

use of org.opennms.netmgt.collectd.tca.config.TcaDataCollection 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

Before (org.junit.Before)1 TcaDataCollection (org.opennms.netmgt.collectd.tca.config.TcaDataCollection)1 TcaDataCollectionConfig (org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig)1 TcaRrd (org.opennms.netmgt.collectd.tca.config.TcaRrd)1 ResourceTypesDao (org.opennms.netmgt.config.api.ResourceTypesDao)1 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)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