use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class HttpCollectionConfigFactory method getRrdRepository.
/**
* <p>getRrdRepository</p>
*
* @param collectionName a {@link java.lang.String} object.
* @return a {@link org.opennms.netmgt.rrd.RrdRepository} object.
*/
public RrdRepository getRrdRepository(String collectionName) {
RrdRepository repo = new RrdRepository();
repo.setRrdBaseDir(new File(getRrdPath()));
repo.setRraList(getRRAList(collectionName));
repo.setStep(getStep(collectionName));
repo.setHeartBeat((2 * getStep(collectionName)));
return repo;
}
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;
}
Aggregations