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);
}
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();
}
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);
}
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));
}
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);
}
Aggregations