Search in sources :

Example 6 with JRobinRrdStrategy

use of org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy in project opennms by OpenNMS.

the class XmlCollectorITCase method initializeRrdStrategy.

/**
 * Initialize RRD strategy.
 *
 * @throws Exception the exception
 */
protected void initializeRrdStrategy() throws Exception {
    m_rrdStrategy = new JRobinRrdStrategy();
    m_resourceStorageDao = new FilesystemResourceStorageDao();
    m_resourceStorageDao.setRrdDirectory(m_temporaryFolder.getRoot());
    m_temporaryFolder.newFolder("snmp");
    m_persisterFactory = new RrdPersisterFactory();
    m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
    m_persisterFactory.setRrdStrategy(m_rrdStrategy);
}
Also used : FilesystemResourceStorageDao(org.opennms.netmgt.dao.support.FilesystemResourceStorageDao) RrdPersisterFactory(org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)

Example 7 with JRobinRrdStrategy

use of org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy in project opennms by OpenNMS.

the class DefaultResourceDaoTest method setUp.

@Before
public void setUp() throws Exception {
    m_fileAnticipator = new FileAnticipator();
    m_easyMockUtils = new EasyMockUtils();
    m_nodeDao = m_easyMockUtils.createMock(NodeDao.class);
    m_locationMonitorDao = m_easyMockUtils.createMock(LocationMonitorDao.class);
    m_resourceTypesDao = m_easyMockUtils.createMock(ResourceTypesDao.class);
    m_filterDao = m_easyMockUtils.createMock(FilterDao.class);
    m_ipInterfaceDao = m_easyMockUtils.createMock(IpInterfaceDao.class);
    FilterDaoFactory.setInstance(m_filterDao);
    expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
    m_easyMockUtils.replayAll();
    setUpCollectdConfigFactory();
    m_easyMockUtils.verifyAll();
    RrdStrategy<?, ?> rrdStrategy = new JRobinRrdStrategy();
    m_rrdFileExtension = rrdStrategy.getDefaultFileExtension();
    m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
    m_resourceStorageDao.setRrdStrategy(rrdStrategy);
    m_resourceDao = new DefaultResourceDao();
    m_resourceDao.setNodeDao(m_nodeDao);
    m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
    m_resourceDao.setIpInterfaceDao(m_ipInterfaceDao);
    m_resourceDao.setCollectdConfig(m_collectdConfig);
    m_resourceDao.setResourceTypesDao(m_resourceTypesDao);
    m_resourceDao.setResourceStorageDao(m_resourceStorageDao);
    expect(m_resourceTypesDao.getResourceTypes()).andReturn(new HashMap<String, ResourceType>());
    expect(m_resourceTypesDao.getLastUpdate()).andReturn(m_lastUpdateTime);
    m_easyMockUtils.replayAll();
    m_resourceDao.afterPropertiesSet();
    m_easyMockUtils.verifyAll();
}
Also used : ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) ArrayList(java.util.ArrayList) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) LocationMonitorDao(org.opennms.netmgt.dao.api.LocationMonitorDao) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) NodeDao(org.opennms.netmgt.dao.api.NodeDao) FilterDao(org.opennms.netmgt.filter.api.FilterDao) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) Before(org.junit.Before)

Example 8 with JRobinRrdStrategy

use of org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy in project opennms by OpenNMS.

the class CollectableServiceTest method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    rrdStrategy = new JRobinRrdStrategy();
    fileAnticipator = new FileAnticipator();
    MockEventIpcManager mockEventIpcManager = new MockEventIpcManager();
    EventIpcManagerFactory.setIpcManager(mockEventIpcManager);
}
Also used : MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) Before(org.junit.Before)

Example 9 with JRobinRrdStrategy

use of org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy in project opennms by OpenNMS.

the class SnmpCollectorIT method testUsingFetch.

@Test
@Transactional
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config.xml", datacollectionType = "snmp", anticipateRrds = { "test" }, anticipateMetaFiles = false)
public void testUsingFetch() throws Exception {
    System.err.println("=== testUsingFetch ===");
    File snmpDir = (File) m_context.getAttribute("rrdDirectory");
    // We initialize an empty attribute map, key=e.g OID; value=e.g. datasource name
    Map<String, String> attributeMappings = new HashMap<String, String>();
    int stepSize = 1;
    int numUpdates = 2;
    long start = System.currentTimeMillis();
    final int stepSizeInMillis = stepSize * 1000;
    final int rangeSizeInMillis = stepSizeInMillis + 20000;
    File rrdFile = new File(snmpDir, rrd("test"));
    RrdStrategy<RrdDef, RrdDb> m_rrdStrategy = new JRobinRrdStrategy();
    RrdDataSource rrdDataSource = new RrdDataSource("testAttr", RrdAttributeType.GAUGE, stepSize * 2, "U", "U");
    RrdDef def = m_rrdStrategy.createDefinition("test", snmpDir.getAbsolutePath(), "test", stepSize, Collections.singletonList(rrdDataSource), Collections.singletonList("RRA:AVERAGE:0.5:1:100"));
    m_rrdStrategy.createFile(def);
    RrdDb rrdFileObject = m_rrdStrategy.openFile(rrdFile.getAbsolutePath());
    for (int i = 0; i < numUpdates; i++) {
        m_rrdStrategy.updateFile(rrdFileObject, "test", ((start / 1000) - (stepSize * (numUpdates - i))) + ":1");
    }
    m_rrdStrategy.closeFile(rrdFileObject);
    assertEquals(Double.valueOf(1.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "testAttr", stepSizeInMillis, rangeSizeInMillis));
}
Also used : RrdDef(org.jrobin.core.RrdDef) HashMap(java.util.HashMap) RrdDb(org.jrobin.core.RrdDb) RrdDataSource(org.opennms.netmgt.rrd.RrdDataSource) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) File(java.io.File) JUnitCollector(org.opennms.core.collection.test.JUnitCollector) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with JRobinRrdStrategy

use of org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy in project opennms by OpenNMS.

the class FindTopLevelResourcesTest method setUp.

@Before
public void setUp() throws Exception {
    m_fileAnticipator = new FileAnticipator();
    m_easyMockUtils = new EasyMockUtils();
    m_nodeDao = m_easyMockUtils.createMock(NodeDao.class);
    m_locationMonitorDao = m_easyMockUtils.createMock(LocationMonitorDao.class);
    m_resourceTypesDao = m_easyMockUtils.createMock(ResourceTypesDao.class);
    m_filterDao = m_easyMockUtils.createMock(FilterDao.class);
    FilterDaoFactory.setInstance(m_filterDao);
    expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
    RrdStrategy<?, ?> rrdStrategy = new JRobinRrdStrategy();
    m_rrdFileExtension = rrdStrategy.getDefaultFileExtension();
    m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
    m_resourceStorageDao.setRrdStrategy(rrdStrategy);
    m_easyMockUtils.replayAll();
    InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/collectdconfiguration-testdata.xml");
    m_collectdConfig = new CollectdConfigFactory(stream, "localhost", false);
    m_easyMockUtils.verifyAll();
    m_resourceDao = new DefaultResourceDao();
    m_resourceDao.setNodeDao(m_nodeDao);
    m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
    m_resourceDao.setCollectdConfig(m_collectdConfig);
    m_resourceDao.setResourceTypesDao(m_resourceTypesDao);
    m_resourceDao.setResourceStorageDao(m_resourceStorageDao);
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) FilterDao(org.opennms.netmgt.filter.api.FilterDao) ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory) EasyMockUtils(org.opennms.test.mock.EasyMockUtils) JRobinRrdStrategy(org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy) FileAnticipator(org.opennms.test.FileAnticipator) LocationMonitorDao(org.opennms.netmgt.dao.api.LocationMonitorDao) Before(org.junit.Before)

Aggregations

JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)14 Before (org.junit.Before)11 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)8 OnmsNode (org.opennms.netmgt.model.OnmsNode)7 FileAnticipator (org.opennms.test.FileAnticipator)6 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)5 File (java.io.File)4 RrdPersisterFactory (org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory)4 NodeDao (org.opennms.netmgt.dao.api.NodeDao)4 MockCollectionAgent (org.opennms.core.collection.test.MockCollectionAgent)3 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 FileSystemResource (org.springframework.core.io.FileSystemResource)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DefaultDataCollectionConfigDao (org.opennms.netmgt.config.DefaultDataCollectionConfigDao)2 ResourceTypesDao (org.opennms.netmgt.config.api.ResourceTypesDao)2 LocationMonitorDao (org.opennms.netmgt.dao.api.LocationMonitorDao)2 FilterDao (org.opennms.netmgt.filter.api.FilterDao)2 OnmsAssetRecord (org.opennms.netmgt.model.OnmsAssetRecord)2