Search in sources :

Example 11 with RrdDef

use of org.jrobin.core.RrdDef in project opennms by OpenNMS.

the class JRobinRrdStrategy method createDefinition.

/**
 * {@inheritDoc}
 */
@Override
public RrdDef createDefinition(final String creator, final String directory, final String rrdName, int step, final List<RrdDataSource> dataSources, final List<String> rraList) throws Exception {
    File f = new File(directory);
    f.mkdirs();
    String fileName = directory + File.separator + rrdName + getDefaultFileExtension();
    if (new File(fileName).exists()) {
        LOG.debug("createDefinition: filename [{}] already exists returning null as definition", fileName);
        return null;
    }
    RrdDef def = new RrdDef(fileName);
    // def.setStartTime(System.currentTimeMillis()/1000L - 2592000L);
    def.setStartTime(1000);
    def.setStep(step);
    for (RrdDataSource dataSource : dataSources) {
        String dsMin = dataSource.getMin();
        String dsMax = dataSource.getMax();
        double min = (dsMin == null || "U".equals(dsMin) ? Double.NaN : Double.parseDouble(dsMin));
        double max = (dsMax == null || "U".equals(dsMax) ? Double.NaN : Double.parseDouble(dsMax));
        def.addDatasource(dataSource.getName(), dataSource.getType().toString(), dataSource.getHeartBeat(), min, max);
    }
    for (String rra : rraList) {
        def.addArchive(rra);
    }
    return def;
}
Also used : RrdDef(org.jrobin.core.RrdDef) RrdDataSource(org.opennms.netmgt.rrd.RrdDataSource) File(java.io.File)

Aggregations

RrdDef (org.jrobin.core.RrdDef)11 RrdDb (org.jrobin.core.RrdDb)7 File (java.io.File)6 RrdDataSource (org.opennms.netmgt.rrd.RrdDataSource)4 IOException (java.io.IOException)2 RrdDefTemplate (org.jrobin.core.RrdDefTemplate)2 Result (com.googlecode.jmxtrans.model.Result)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 RateStat (net.i2p.stat.RateStat)1 SecureFile (net.i2p.util.SecureFile)1 ArcDef (org.jrobin.core.ArcDef)1 Archive (org.jrobin.core.Archive)1 DsDef (org.jrobin.core.DsDef)1 RrdBackendFactory (org.jrobin.core.RrdBackendFactory)1 RrdException (org.jrobin.core.RrdException)1 Test (org.junit.Test)1 JUnitCollector (org.opennms.core.collection.test.JUnitCollector)1