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;
}
Aggregations