Search in sources :

Example 6 with RrdRepository

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;
}
Also used : RrdRepository(org.opennms.netmgt.rrd.RrdRepository)

Example 7 with RrdRepository

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()));
}
Also used : Datasource(org.jrobin.core.Datasource) XmlDataCollectionConfig(org.opennms.protocols.xml.config.XmlDataCollectionConfig) HashMap(java.util.HashMap) CollectionSetVisitor(org.opennms.netmgt.collection.api.CollectionSetVisitor) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) XmlDataCollection(org.opennms.protocols.xml.config.XmlDataCollection) RrdDb(org.jrobin.core.RrdDb) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) File(java.io.File) Test(org.junit.Test) JUnitHttpServer(org.opennms.core.test.http.annotations.JUnitHttpServer)

Example 8 with RrdRepository

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;
}
Also used : RrdRepository(org.opennms.netmgt.rrd.RrdRepository)

Example 9 with RrdRepository

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;
}
Also used : XmlRrd(org.opennms.protocols.xml.config.XmlRrd) RrdRepository(org.opennms.netmgt.rrd.RrdRepository)

Example 10 with RrdRepository

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;
}
Also used : RrdRepository(org.opennms.netmgt.rrd.RrdRepository) File(java.io.File)

Aggregations

RrdRepository (org.opennms.netmgt.rrd.RrdRepository)51 File (java.io.File)26 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)17 HashMap (java.util.HashMap)11 Test (org.junit.Test)11 CollectionSetVisitor (org.opennms.netmgt.collection.api.CollectionSetVisitor)9 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)6 XmlDataCollection (org.opennms.protocols.xml.config.XmlDataCollection)6 Datasource (org.jrobin.core.Datasource)5 RrdDb (org.jrobin.core.RrdDb)5 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)5 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)5 XmlDataCollectionConfig (org.opennms.protocols.xml.config.XmlDataCollectionConfig)5 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)4 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)4 RrdPersistOperationBuilder (org.opennms.netmgt.collection.persistence.rrd.RrdPersistOperationBuilder)4 MibObject (org.opennms.netmgt.config.datacollection.MibObject)4 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)4 SnmpResult (org.opennms.netmgt.snmp.SnmpResult)4 XmlRrd (org.opennms.protocols.xml.config.XmlRrd)4