Esempio n. 1
0
 private void createInvalidRrdFile(String expected) throws IOException {
   // create invalid rrd
   File rrd = new File(expected);
   RrdDef rrdDef = new RrdDef(rrd.getAbsolutePath(), 3000);
   rrdDef.addDatasource("test", DsType.GAUGE, 1, NaN, NaN);
   rrdDef.addArchive(ConsolFun.AVERAGE, 0.2, 1, 1600);
   RrdDb r = new RrdDb(rrdDef);
   r.close();
 }
Esempio n. 2
0
 private void parseRra(String word) {
   // RRA:cfun:xff:steps:rows
   String[] tokens = new ColonSplitter(word).split();
   if (tokens.length < 5) {
     throw new IllegalArgumentException("Invalid RRA definition: " + word);
   }
   ConsolFun cf = ConsolFun.valueOf(tokens[1]);
   double xff = parseDouble(tokens[2]);
   int steps = parseInt(tokens[3]);
   int rows = parseInt(tokens[4]);
   rrdDef.addArchive(cf, xff, steps, rows);
 }
Esempio n. 3
0
  @BeforeClass
  public static void createRrd() throws IOException {
    startTime = start - start % step;
    endTime = startTime + 200 * step;

    RrdDef def = new RrdDef(fileName, startTime - 3 * step, step);

    def.addArchive(ConsolFun.AVERAGE, 0.5, 1, 215);
    def.addDatasource("bar", DsType.GAUGE, 3000, Double.NaN, Double.NaN);

    RrdDb db = new RrdDb(def, RrdBackendFactory.getFactory(backend));

    db.createSample((startTime - step)).setValue(0, 0.0).update();

    long sampleTime = startTime;
    for (double val : vals) {
      db.createSample(sampleTime).setValue(0, val).update();
      sampleTime += step;
    }

    if (dorrdtool) {
      String xmlfile = System.getProperty("java.io.tmpdir") + File.separator + "variabletest.xml";
      String rrdfile = System.getProperty("java.io.tmpdir") + File.separator + "variabletest.rrd";
      db.dumpXml(xmlfile);
      System.out.println("rrdtool restore " + xmlfile + " " + rrdfile);
      String cmd =
          "rrdtool graph /dev/null "
              + String.format("--start=%d ", startTime)
              + String.format("--end=%d ", endTime)
              + String.format("DEF:baz=%s:bar:AVERAGE ", rrdfile)
              + "VDEF:min=baz,MINIMUM "
              + "PRINT:min:\"mininum %1.15le\" "
              + "VDEF:max=baz,MAXIMUM "
              + "PRINT:max:\"maximum %1.15le\" "
              + "VDEF:avg=baz,AVERAGE "
              + "PRINT:avg:\"average %1.15le\" "
              + "VDEF:stdev=baz,STDEV "
              + "PRINT:stdev:\"stdev %1.15le\" "
              + "VDEF:first=baz,FIRST "
              + "PRINT:first:\"first %1.15le\" "
              + "VDEF:last=baz,LAST "
              + "PRINT:last:\"last %1.15le\" "
              + "VDEF:total=baz,TOTAL "
              + "PRINT:total:\"total %1.15le\" "
              + "VDEF:percent=baz,95,PERCENT "
              + "PRINT:percent:\"95-th percent %1.15le\" "
              + "VDEF:percentnan=baz,95,PERCENTNAN "
              + "PRINT:percentnan:\"95-th percentnan %1.15le\" "
              + "VDEF:lslope=baz,LSLSLOPE "
              + "PRINT:lslope:\"lslope %1.15le\" "
              + "VDEF:lslint=baz,LSLINT "
              + "PRINT:lslint:\"lslintn %1.15le\" "
              + "VDEF:lslcorrel=baz,LSLCORREL "
              + "PRINT:lslcorrel:\"lslcorrel %1.15le\" ";
      System.out.println(cmd);
      long interval = (endTime - startTime) / 3;
      String cmd2 =
          "rrdtool graph /dev/null "
              + String.format("--start=%d ", startTime + interval)
              + String.format("--end=%d ", endTime - interval)
              + String.format("DEF:baz=%s:bar:AVERAGE ", rrdfile)
              + "VDEF:min=baz,MINIMUM "
              + "PRINT:min:\"mininum %1.15le\" "
              + "VDEF:max=baz,MAXIMUM "
              + "PRINT:max:\"maximum %1.15le\" "
              + "VDEF:avg=baz,AVERAGE "
              + "PRINT:avg:\"average %1.15le\" "
              + "VDEF:stdev=baz,STDEV "
              + "PRINT:stdev:\"stdev %1.15le\" "
              + "VDEF:first=baz,FIRST "
              + "PRINT:first:\"first %1.15le\" "
              + "VDEF:last=baz,LAST "
              + "PRINT:last:\"last %1.15le\" "
              + "VDEF:total=baz,TOTAL "
              + "PRINT:total:\"total %1.15le\" "
              + "VDEF:percent=baz,95,PERCENT "
              + "PRINT:percent:\"95-th percent %1.15le\" "
              + "VDEF:percentnan=baz,95,PERCENTNAN "
              + "PRINT:percentnan:\"95-th percentnan %1.15le\" "
              + "VDEF:lslope=baz,LSLSLOPE "
              + "PRINT:lslope:\"lslope %1.15le\" "
              + "VDEF:lslint=baz,LSLINT "
              + "PRINT:lslint:\"lslintn %1.15le\" "
              + "VDEF:lslcorrel=baz,LSLCORREL "
              + "PRINT:lslcorrel:\"lslcorrel %1.15le\" ";
      System.out.println(cmd2);

      String cmd3 =
          "rrdtool graph /dev/null "
              + String.format("--start=%d ", startTime - 10 * step)
              + String.format("--end=%d ", endTime + 2 * step)
              + String.format("DEF:baz=%s:bar:AVERAGE ", rrdfile)
              + "VDEF:min=baz,MINIMUM "
              + "PRINT:min:\"mininum %1.15le\" "
              + "VDEF:max=baz,MAXIMUM "
              + "PRINT:max:\"maximum %1.15le\" "
              + "VDEF:avg=baz,AVERAGE "
              + "PRINT:avg:\"average %1.15le\" "
              + "VDEF:stdev=baz,STDEV "
              + "PRINT:stdev:\"stdev %1.15le\" "
              + "VDEF:first=baz,FIRST "
              + "PRINT:first:\"first %1.15le\" "
              + "VDEF:last=baz,LAST "
              + "PRINT:last:\"last %1.15le\" "
              + "VDEF:total=baz,TOTAL "
              + "PRINT:total:\"total %1.15le\" "
              + "VDEF:percent=baz,95,PERCENT "
              + "PRINT:percent:\"95-th percent %1.15le\" "
              + "VDEF:percentnan=baz,95,PERCENTNAN "
              + "PRINT:percentnan:\"95-th percentnan %1.15le\" "
              + "VDEF:lslope=baz,LSLSLOPE "
              + "PRINT:lslope:\"lslope %1.15le\" "
              + "VDEF:lslint=baz,LSLINT "
              + "PRINT:lslint:\"lslintn %1.15le\" "
              + "VDEF:lslcorrel=baz,LSLCORREL "
              + "PRINT:lslcorrel:\"lslcorrel %1.15le\" ";
      System.out.println(cmd3);
    }
  }
Esempio n. 4
0
 private void addArchive(RrdDef rrdDef, ConsolFun fun, long length, long resolution) {
   rrdDef.addArchive(
       fun, 0.2, (int) (resolution * STEP_SIZE), (int) (length / (resolution * STEP_SIZE)));
 }