本文整理汇总了Java中org.rrd4j.core.RrdDef类的典型用法代码示例。如果您正苦于以下问题:Java RrdDef类的具体用法?Java RrdDef怎么用?Java RrdDef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RrdDef类属于org.rrd4j.core包,在下文中一共展示了RrdDef类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUnitDb
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
public static RrdDb createUnitDb(int cores, int clusterId, int unitId) throws IOException {
Logger.getLogger(RrdDbFactory.class.getName()).info("Creating new RRD file: "
+ RrdHelper.getDbPath(clusterId, unitId));
RrdDef rrdDef = new RrdDef(RrdHelper.getDbPath(clusterId, unitId));
rrdDef.setStep(STEP);
rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.CPU_SPEED).getStringId(),
DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
for (int i = 0; i < cores; i++) {
rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.CPU_USAGE, i).getStringId(),
DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
}
rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.MEMORY).getStringId(),
DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
RrdHelper.getSampleSize(RrdDbResolution.EXACT),
RrdHelper.getSampleWindow(RrdDbResolution.EXACT));
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
RrdHelper.getSampleSize(RrdDbResolution.LOW),
RrdHelper.getSampleWindow(RrdDbResolution.LOW));
RrdDb rrdDb = new RrdDb(rrdDef);
return rrdDb;
}
示例2: createGpuDb
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
public static RrdDb createGpuDb(int clusterId, int unitId, int deviceId) throws IOException {
Logger.getLogger(RrdDbFactory.class.getName()).info("Creating new GPU RRD file: "
+ RrdHelper.getDbPath(clusterId, unitId, deviceId));
RrdDef rrdDef = new RrdDef(RrdHelper.getDbPath(clusterId, unitId, deviceId));
rrdDef.setStep(STEP);
rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.GPU_USAGE).getStringId(),
DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.GPU_GLOBAL_MEMORY).getStringId(),
DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.FAN).getStringId(),
DsType.GAUGE, TIMEOUT, 0, 100);
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
RrdHelper.getSampleSize(RrdDbResolution.EXACT),
RrdHelper.getSampleWindow(RrdDbResolution.EXACT));
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
RrdHelper.getSampleSize(RrdDbResolution.LOW),
RrdHelper.getSampleWindow(RrdDbResolution.LOW));
RrdDb rrdDb = new RrdDb(rrdDef);
return rrdDb;
}
示例3: init
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
@Before
public void init() throws IOException {
CassandraBackendFactory factory = new CassandraBackendFactory("localhost:9160");
TimeTrace timeTrace = new TimeTrace();
timeTrace.begin();
for (int i = 0; i < rrdCount; i++) {
RrdDef rrdDef = new RrdDef("pt-5m-" + i, 0, 300);
rrdDef.setVersion(2);
rrdDef.addDatasource("ds", GAUGE, 3600, -5, 30);
rrdDef.addArchive(AVERAGE, 0.5, 300, 1000);
rrdDbs.add(new RrdDb(rrdDef, factory));
}
timeTrace.end();
System.out.printf("init time(Total):%s,count:%s\r\n", timeTrace.getMills(), rrdDbs.size());
System.out.printf("init time(Avg):%s\r\n", timeTrace.getMills() / rrdDbs.size());
}
示例4: build
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
@Override
public MetricsDatabase build() {
checkNotNull(metricName, METRIC_NAME_MSG);
checkNotNull(resourceName, RESOURCE_NAME_MSG);
checkArgument(!dsDefs.isEmpty(), METRIC_TYPE_MSG);
// define the resolution of monitored metrics
rrdDef = new RrdDef(DB_PATH + SPLITTER + metricName +
SPLITTER + resourceName, RESOLUTION_IN_SECOND);
try {
DsDef[] dsDefArray = new DsDef[dsDefs.size()];
IntStream.range(0, dsDefs.size()).forEach(i -> dsDefArray[i] = dsDefs.get(i));
rrdDef.addDatasource(dsDefArray);
rrdDef.setStep(RESOLUTION_IN_SECOND);
// raw archive, no aggregation is required
ArcDef rawArchive = new ArcDef(CONSOL_FUNCTION, XFF_VALUE,
STEP_VALUE, ROW_VALUE);
rrdDef.addArchive(rawArchive);
// always store the metric data in memory...
rrdDb = new RrdDb(rrdDef, RrdBackendFactory.getFactory(STORING_METHOD));
} catch (IOException e) {
log.warn("Failed to create a new round-robin database due to {}", e);
}
return new DefaultMetricsDatabase(metricName, resourceName, rrdDb);
}
示例5: getRrdDef
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
private RrdDef getRrdDef(String itemName, File file) {
RrdDef rrdDef = new RrdDef(file.getAbsolutePath());
RrdDefConfig useRdc = getRrdDefConfig(itemName);
rrdDef.setStep(useRdc.step);
rrdDef.setStartTime(System.currentTimeMillis()/1000-1);
rrdDef.addDatasource(DATASOURCE_STATE, useRdc.dsType, useRdc.heartbeat, useRdc.min, useRdc.max);
for (RrdArchiveDef rad : useRdc.archives) {
rrdDef.addArchive(rad.fcn, rad.xff, rad.steps, rad.rows);
}
return rrdDef;
}
示例6: RRD
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
/**
* Constructs the RRD logger object with a name and a physical quantity.
*
* @param name
* the name of the data series to be logged and displayed in the
* PNG.
* @param physicalQuantity
* the physical quanitity of the data.
* @throws IOException
*/
public RRD(String name, PhysicalQuantity physicalQuantity) throws IOException {
this.name = name;
this.physicalQuantity = physicalQuantity;
rrdPath = name + ".rrd";
RrdDef rrdDef = new RrdDef(rrdPath, 1);
rrdDef.addDatasource(name, DsType.GAUGE, 60, 0D, 110D);
rrdDef.addArchive(ConsolFun.MAX, 0.5, 1, 60 * 60 * 12);
RrdDb rrdDb = new RrdDb(rrdDef);
startTime = Util.getTimestamp();
log.info("Created RRD database in " + rrdPath + ".");
rrdDb.close();
}
示例7: createThreadRrd
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
private void createThreadRrd() {
logger.info("Initialzing Thread RRD data at: {}", rrdPath(THREAD_RRD));
RrdDef rrdDef = new RrdDef(rrdPath(THREAD_RRD), 60);
rrdDef.addArchive(AVERAGE, 0.5, 1, 1440);
rrdDef.addArchive(AVERAGE, 0.5, 5, 288);
rrdDef.addArchive(MAX, 0.5, 1, 1440);
rrdDef.addArchive(MAX, 0.5, 5, 288);
rrdDef.addDatasource("nodeThreads", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("nodeActiveThreads", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("nodeExecuted", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("nodeWaiting", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("nodeCapacity", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procThreads", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procActiveThreads", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procExecuted", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procWaiting", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procCapacity", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("asyncThreads", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("asyncActiveThreads", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("asyncExecuted", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("asyncWaiting", GAUGE, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("asyncCapacity", GAUGE, 600, Double.NaN, Double.NaN);
saveRrdDef(rrdDef);
}
示例8: createPlowRrd
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
private void createPlowRrd() {
logger.info("Initialzing Plow RRD data at: {}", rrdPath(PLOW_RRD));
RrdDef rrdDef = new RrdDef(rrdPath(PLOW_RRD), 60);
rrdDef.addArchive(AVERAGE, 0.5, 1, 1440);
rrdDef.addArchive(AVERAGE, 0.5, 5, 288);
rrdDef.addArchive(MAX, 0.5, 1, 1440);
rrdDef.addArchive(MAX, 0.5, 5, 288);
rrdDef.addDatasource("nodeDispatchHit", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("nodeDispatchMiss", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("nodeDispatchFail", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procDispatchHit", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procDispatchMiss", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procDispatchFail", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procAllocCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procUnallocCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procAllocFailCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procUnallocFailCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("procOrphan", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("taskStartedCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("taskStartedFailCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("taskStoppedCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("taskStoppedFailCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("jobLaunchCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("jobLaunchFailCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("jobFinishCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("jobKillCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("rndPingCount", COUNTER, 600, Double.NaN, Double.NaN);
rrdDef.addDatasource("rndTaskComplete", COUNTER, 600, Double.NaN, Double.NaN);
saveRrdDef(rrdDef);
}
示例9: getRrdDef
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
private RrdDef getRrdDef(String itemName, File file) {
RrdDef rrdDef = new RrdDef(file.getAbsolutePath());
RrdDefConfig useRdc = getRrdDefConfig(itemName);
rrdDef.setStep(useRdc.step);
rrdDef.setStartTime(System.currentTimeMillis() / 1000 - 1);
rrdDef.addDatasource(DATASOURCE_STATE, useRdc.dsType, useRdc.heartbeat, useRdc.min, useRdc.max);
for (RrdArchiveDef rad : useRdc.archives) {
rrdDef.addArchive(rad.fcn, rad.xff, rad.steps, rad.rows);
}
return rrdDef;
}
示例10: initDatabase
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
protected void initDatabase() throws IOException {
if (!new File(dataBaseFile).exists()) {
if (step <= 0) {
logger.debug("Provided step is invalid, forcing it to " + DEFAULT_STEP_IN_SECONDS);
step = DEFAULT_STEP_IN_SECONDS;
}
logger.info("Node's statistics are saved in " + dataBaseFile);
RrdDef rrdDef = new RrdDef(dataBaseFile, System.currentTimeMillis() / 1000, step);
for (String dataSource : dataSources.keySet()) {
rrdDef.addDatasource(dataSource, DsType.GAUGE, 600, 0, Double.NaN);
}
// for step equals 4 seconds
// Archive of 10 minutes = 600 seconds (4 * 1 * 150) of completely detailed data
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 1, 150);
// An archive of 1 hour = 3600 seconds (4 * 5 * 180) i.e. 180 averages of 5 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 5, 180);
// An archive of 4 hours = 14400 seconds (4 * 10 * 360) i.e. 360 averages of 10 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 10, 360);
// An archive of 8 hours = 28800 seconds (4 * 20 * 360) i.e. 360 averages of 20 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 20, 360);
// An archive of 24 hours = 86400 seconds (4 * 30 * 720) i.e. 720 averages of 30 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 30, 720);
// An archive of 1 week = 604800 seconds (4 * 210 * 720) i.e. 720 averages of 210 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 210, 720);
// An archive of 1 month ~= 28 days = 604800 seconds (4 * 840 * 720) i.e. 720 averages of 840 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 840, 720);
// An archive of 1 year = 364 days = 31449600 seconds (4 * 10920 * 720) i.e. 720 averages of 10920 steps
rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 10920, 720);
RrdDb dataBase = new RrdDb(rrdDef);
dataBase.close();
} else {
logger.info("Using existing RRD database: " + new File(dataBaseFile).getAbsolutePath());
}
}
示例11: testSpike
import org.rrd4j.core.RrdDef; //导入依赖的package包/类
@Test
public void testSpike() throws IOException {
RrdDef rrdDef = new RrdDef("testSpike.rrd", 0, 60);
rrdDef.setVersion(2);
rrdDef.addDatasource("ds", GAUGE, 3600, -5, 30);
rrdDef.addArchive(AVERAGE, 0.5, 60, 999);
RrdDb rrdDb = new RrdDb(rrdDef,factory);
Calendar testTime = Calendar.getInstance();
testTime.set(Calendar.MINUTE, 0);
testTime.set(Calendar.SECOND, 0);
testTime.set(Calendar.MILLISECOND, 0);
System.out.println(testTime);
//testTime.add(Calendar.HOUR, -1);
long start = Util.getTimestamp(testTime);
long timeStamp = start;
for(int i = 0; i < 180; i++) {
long sampleTime = timeStamp;
if(i == 117) {
sampleTime += -1;
}
rrdDb.createSample(sampleTime).setValue("ds", 30).update();
timeStamp += 60;
}
long end = timeStamp;
FetchData f = rrdDb.createFetchRequest(AVERAGE, start, end).fetchData();
System.out.println(f.dump());
double[] values = f.getValues("ds");
assertTrue("Data before first entry", Double.isNaN(values[0]));
assertEquals("Bad average in point 1", 30, values[1], 1e-3);
assertEquals("Bad average in point 2", 30, values[2], 1e-3);
assertTrue("Data after last entry", Double.isNaN(values[3]));
rrdDb.close();
RrdDb rrdDbForRead = new RrdDb("testSpike.rrd",factory);
FetchData result = rrdDbForRead.createFetchRequest(AVERAGE, start, end).fetchData();
System.out.println(f.dump());
double[] resultData = result.getValues("ds");
assertTrue("Data before first entry", Double.isNaN(resultData[0]));
assertEquals("Bad average in point 1", 30, resultData[1], 1e-3);
assertEquals("Bad average in point 2", 30, resultData[2], 1e-3);
assertTrue("Data after last entry", Double.isNaN(resultData[3]));
rrdDbForRead.close();
}