Java Code Examples for org.rrd4j.core.RrdDef#setStartTime()
The following examples show how to use
org.rrd4j.core.RrdDef#setStartTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricsHistoryHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
private RrdDef createDef(String registry, Group group) { registry = SolrMetricManager.enforcePrefix(registry); // base sampling period is collectPeriod - samples more frequent than // that will be dropped, samples less frequent will be interpolated RrdDef def = new RrdDef(URI_PREFIX + registry, collectPeriod); // set the start time early enough so that the first sample is always later // than the start of the archive def.setStartTime(TimeUnit.SECONDS.convert(timeSource.getEpochTimeNs(), TimeUnit.NANOSECONDS) - def.getStep()); // add datasources List<Group> groups = new ArrayList<>(); groups.add(group); if (group == Group.collection) { groups.add(Group.core); } for (Group g : groups) { // use NaN when more than 1 sample is missing counters.get(g.toString()).forEach(name -> def.addDatasource(name, DsType.COUNTER, collectPeriod * 2, Double.NaN, Double.NaN)); gauges.get(g.toString()).forEach(name -> def.addDatasource(name, DsType.GAUGE, collectPeriod * 2, Double.NaN, Double.NaN)); } if (groups.contains(Group.node)) { // add nomNodes gauge def.addDatasource(NUM_NODES_KEY, DsType.GAUGE, collectPeriod * 2, Double.NaN, Double.NaN); } // add archives // use AVERAGE consolidation, // use NaN when >50% samples are missing def.addArchive(ConsolFun.AVERAGE, 0.5, 1, 240); // 4 hours def.addArchive(ConsolFun.AVERAGE, 0.5, 10, 288); // 48 hours def.addArchive(ConsolFun.AVERAGE, 0.5, 60, 336); // 2 weeks def.addArchive(ConsolFun.AVERAGE, 0.5, 240, 180); // 2 months def.addArchive(ConsolFun.AVERAGE, 0.5, 1440, 365); // 1 year return def; }
Example 2
Source File: SolrRrdBackendFactoryTest.java From lucene-solr with Apache License 2.0 | 5 votes |
private RrdDef createDef(long startTime) { RrdDef def = new RrdDef("solr:foo", 60); def.setStartTime(startTime); def.addDatasource("one", DsType.COUNTER, 120, Double.NaN, Double.NaN); def.addDatasource("two", DsType.GAUGE, 120, Double.NaN, Double.NaN); def.addArchive(ConsolFun.AVERAGE, 0.5, 1, 120); // 2 hours def.addArchive(ConsolFun.AVERAGE, 0.5, 10, 288); // 48 hours def.addArchive(ConsolFun.AVERAGE, 0.5, 60, 336); // 2 weeks def.addArchive(ConsolFun.AVERAGE, 0.5, 240, 180); // 2 months return def; }
Example 3
Source File: RRD4jService.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
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; }