use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class HttpDataCollectionIT method createRrdRepository.
/**
* Creates the RRD repository.
*
* @return the RRD repository
* @throws IOException Signals that an I/O exception has occurred.
*/
private RrdRepository createRrdRepository(XmlRrd rrd) throws IOException {
RrdRepository repository = new RrdRepository();
repository.setRrdBaseDir(getSnmpRoot());
repository.setHeartBeat(rrd.getStep() * 2);
repository.setStep(rrd.getStep());
repository.setRraList(rrd.getXmlRras());
return repository;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class NMS7963IT method testHttpCollection.
/**
* Test HTTP Data Collection with XPath
*
* @throws Exception the exception
*/
@Test
@JUnitHttpServer(port = 10342, https = false, webapps = { @Webapp(context = "/junit", path = "src/test/resources/test-webapp") })
public void testHttpCollection() throws Exception {
File configFile = new File("src/test/resources/http-datacollection-config.xml");
XmlDataCollectionConfig config = JaxbUtils.unmarshal(XmlDataCollectionConfig.class, configFile);
XmlDataCollection collection = config.getDataCollectionByName("NMS-7963");
RrdRepository repository = createRrdRepository(collection.getXmlRrd());
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("collection", "NMS-7963");
DefaultXmlCollectionHandler collector = new DefaultXmlCollectionHandler();
collector.setRrdRepository(repository);
collector.setServiceName("HTTP");
CollectionSet collectionSet = XmlCollectorTestUtils.doCollect(m_nodeDao, collector, m_collectionAgent, collection, parameters);
Assert.assertEquals(CollectionStatus.SUCCEEDED, collectionSet.getStatus());
ServiceParameters serviceParams = new ServiceParameters(new HashMap<String, Object>());
CollectionSetVisitor persister = m_persisterFactory.createGroupPersister(serviceParams, repository, false, false);
collectionSet.visit(persister);
RrdDb jrb = new RrdDb(new File(getSnmpRoot(), "1/xml-retrv-wipo-data.jrb"));
Assert.assertNotNull(jrb);
Assert.assertEquals(1, jrb.getDsCount());
Datasource ds = jrb.getDatasource("xml-wipo-paco");
Assert.assertNotNull(ds);
Assert.assertEquals(new Double(903), Double.valueOf(ds.getLastValue()));
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class NMS7963IT method createRrdRepository.
/**
* Creates the RRD repository.
*
* @return the RRD repository
* @throws IOException Signals that an I/O exception has occurred.
*/
private RrdRepository createRrdRepository(XmlRrd rrd) throws IOException {
RrdRepository repository = new RrdRepository();
repository.setRrdBaseDir(getSnmpRoot());
repository.setHeartBeat(rrd.getStep() * 2);
repository.setStep(rrd.getStep());
repository.setRraList(rrd.getXmlRras());
return repository;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class XmlCollectorITCase method createRrdRepository.
/**
* Creates the RRD repository.
*
* @return the RRD repository
* @throws IOException Signals that an I/O exception has occurred.
*/
private RrdRepository createRrdRepository(String collection) throws IOException {
XmlRrd rrd = m_xmlCollectionDao.getDataCollectionByName(collection).getXmlRrd();
RrdRepository repository = new RrdRepository();
repository.setRrdBaseDir(getSnmpRootDirectory());
repository.setHeartBeat(rrd.getStep() * 2);
repository.setStep(rrd.getStep());
repository.setRraList(rrd.getXmlRras());
return repository;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class TcaDataCollectionConfig method buildRrdRepository.
/**
* Builds the RRD repository.
*
* @param collectionName the collection name
* @return the RRD repository
*/
public RrdRepository buildRrdRepository(final String collectionName) {
final TcaDataCollection collection = getDataCollectionByName(collectionName);
if (collection == null) {
return null;
}
final TcaRrd rrd = collection.getRrd();
final RrdRepository repo = new RrdRepository();
repo.setRrdBaseDir(new File(getRrdRepository()));
repo.setRraList(rrd.getRras());
// Step should be 1 second
repo.setStep(rrd.getStep());
// Heartbeat should be equal to the step.
repo.setHeartBeat(rrd.getStep());
return repo;
}
Aggregations