use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class JdbcCollectorComplianceIT method getRequiredBeans.
@Override
public Map<String, Object> getRequiredBeans() {
JdbcDataCollection collection = new JdbcDataCollection();
collection.setJdbcRrd(new JdbcRrd());
JdbcDataCollectionConfigDao jdbcCollectionDao = mock(JdbcDataCollectionConfigDao.class, RETURNS_DEEP_STUBS);
when(jdbcCollectionDao.getDataCollectionByName(COLLECTION)).thenReturn(collection);
when(jdbcCollectionDao.getConfig().buildRrdRepository(COLLECTION)).thenReturn(new RrdRepository());
ResourceTypesDao resourceTypesDao = mock(ResourceTypesDao.class);
return new ImmutableMap.Builder<String, Object>().put("jdbcDataCollectionConfigDao", jdbcCollectionDao).put("resourceTypesDao", resourceTypesDao).build();
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class NewtsPersisterIT method canPersist.
@Test
public void canPersist() throws InterruptedException {
ServiceParameters params = new ServiceParameters(Collections.emptyMap());
RrdRepository repo = new RrdRepository();
// Only the last element of the path matters here
repo.setRrdBaseDir(Paths.get("a", "path", "that", "ends", "with", "snmp").toFile());
Persister persister = m_persisterFactory.createPersister(params, repo);
int nodeId = 1;
CollectionAgent agent = mock(CollectionAgent.class);
when(agent.getStorageResourcePath()).thenReturn(ResourcePath.get(Integer.toString(nodeId)));
NodeLevelResource nodeLevelResource = new NodeLevelResource(nodeId);
// Build a collection set with a single sample
Timestamp now = Timestamp.now();
CollectionSet collectionSet = new CollectionSetBuilder(agent).withNumericAttribute(nodeLevelResource, "metrics", "metric", 900, AttributeType.GAUGE).withTimestamp(now.asDate()).build();
// Persist
collectionSet.visit(persister);
// Wait for the sample(s) to be flushed
Thread.sleep(5 * 1000);
// Fetch the (persisted) sample
Resource resource = new Resource("snmp:1:metrics");
Timestamp end = Timestamp.now();
Results<Sample> samples = m_sampleRepository.select(Context.DEFAULT_CONTEXT, resource, Optional.of(now), Optional.of(end));
assertEquals(1, samples.getRows().size());
Row<Sample> row = samples.getRows().iterator().next();
assertEquals(900, row.getElement("metric").getValue().doubleValue(), 0.00001);
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class ThresholdingVisitorIT method getRepository.
private RrdRepository getRepository() {
RrdRepository repo = new RrdRepository();
repo.setRrdBaseDir(new File(m_fileAnticipator.getTempDir(), "snmp"));
return repo;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class XmlDataCollectionConfig method buildRrdRepository.
public static RrdRepository buildRrdRepository(String rrdRepositoryPath, XmlDataCollection collection) {
XmlRrd rrd = collection.getXmlRrd();
RrdRepository repo = new RrdRepository();
repo.setRrdBaseDir(new File(rrdRepositoryPath));
repo.setRraList(rrd.getXmlRras());
repo.setStep(rrd.getStep());
repo.setHeartBeat((2 * rrd.getStep()));
return repo;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class WsManCollector method getRrdRepository.
@Override
public RrdRepository getRrdRepository(String collectionName) {
LOG.debug("getRrdRepository({})", collectionName);
WsmanDatacollectionConfig config = m_wsManDataCollectionConfigDao.getConfig();
Collection collection = m_wsManDataCollectionConfigDao.getCollectionByName(collectionName);
if (collection == null) {
throw new IllegalArgumentException("No configuration found for collection with name: " + collectionName);
}
RrdRepository rrdRepository = new RrdRepository();
rrdRepository.setStep(collection.getRrd().getStep());
rrdRepository.setHeartBeat(2 * rrdRepository.getStep());
rrdRepository.setRraList(collection.getRrd().getRra());
rrdRepository.setRrdBaseDir(new File(config.getRrdRepository()));
LOG.debug("Using RRD repository: {} for collection: {}", rrdRepository, collectionName);
return rrdRepository;
}
Aggregations