Examples of RrdDb


Examples of org.jrobin.core.RrdDb

    String[] words = getRemainingWords();
    if (words.length != 2) {
      throw new RrdException("Invalid rrdlast syntax");
    }
    String path = words[1];
    RrdDb rrdDb = getRrdDbReference(path);
    try {
      long lastUpdateTime = rrdDb.getLastUpdateTime();
      println(lastUpdateTime + "");
      return lastUpdateTime;
    }
    finally {
      releaseRrdDbReference(rrdDb);
View Full Code Here

Examples of org.jrobin.core.RrdDb

    int rows = parseInt(tokens[4]);
    rrdDef.addArchive(cf, xff, steps, rows);
  }

  private String createRrdDb() throws IOException, RrdException {
    RrdDb rrdDb = getRrdDbReference(rrdDef);
    releaseRrdDbReference(rrdDb);
    return rrdDef.getPath();
  }
View Full Code Here

Examples of org.jrobin.core.RrdDb

      File rrdFile = new File(path);
      print(countFormatter.format(totalCount) + "/" + countFormatter.format(files.length) +
          " " + rrdFile.getName() + " ");
      String sourcePath = rrdFile.getCanonicalPath();
      String destPath = sourcePath + SUFFIX;
      RrdDb rrd = new RrdDb(destPath, RrdDb.PREFIX_RRDTool + sourcePath);
      rrd.close();
      goodCount++;
      double seconds = (System.currentTimeMillis() - start) / 1000.0;
      println("[OK, " + secondsFormatter.format(seconds) + " sec]");
    }
    catch (Exception e) {
View Full Code Here

Examples of org.jrobin.core.RrdDb

    if (words.length != 3) {
      throw new RrdException("Invalid rrdrestore syntax");
    }
    String xmlPath = words[1];
    String rrdPath = words[2];
    RrdDb rrdDb = getRrdDbReference(rrdPath, xmlPath);
    try {
      if (check) {
        int dsCount = rrdDb.getHeader().getDsCount();
        for (int i = 0; i < dsCount; i++) {
          Datasource ds = rrdDb.getDatasource(i);
          double minValue = ds.getMinValue();
          double maxValue = ds.getMaxValue();
          // this will perform range check
          ds.setMinMaxValue(minValue, maxValue, true);
        }
View Full Code Here

Examples of org.jrobin.core.RrdDb

    }
    if (words.length > 2) {
      throw new RrdException("Unexpected token encountered: " + words[2]);
    }
    String path = words[1];
    RrdDb rrd = getRrdDbReference(path);
    try {
      // heartbeat
      for (String heartbeat : heartbeats) {
        tuneHeartbeat(rrd, heartbeat);
      }
View Full Code Here

Examples of org.jrobin.core.RrdDb

    if (dsIndex != newDsIndex) {
      dsIndex = newDsIndex;
      values = null;
      if (dsIndex >= 0) {
        try {
          RrdDb rrd = new RrdDb(file.getAbsolutePath(), true);
          try {
            Datasource ds = rrd.getDatasource(dsIndex);
            values = new Object[] {
                ds.getDsName(),
                ds.getDsType(),
                "" + ds.getHeartbeat(),
                InspectorModel.formatDouble(ds.getMinValue()),
                InspectorModel.formatDouble(ds.getMaxValue()),
                InspectorModel.formatDouble(ds.getLastValue()),
                InspectorModel.formatDouble(ds.getAccumValue()),
                "" + ds.getNanSeconds()
            };
          }
          finally {
            rrd.close();
          }
        }
        catch (IOException e) {
          Util.error(null, e);
        }
View Full Code Here

Examples of org.jrobin.core.RrdDb

  public void validateSetup(Server server, Query query) throws ValidationException {
  }

  public void doWrite(Server server, Query query, ImmutableList<Result> results) throws Exception {
    RrdDb db = null;
    try {
      db = createOrOpenDatabase();
      Sample sample = db.createSample();
      List<String> dsNames = Arrays.asList(db.getDsNames());

      // go over all the results and look for datasource names that map to
      // keys from the result values
      for (Result res : results) {
        Map<String, Object> values = res.getValues();
        if (values != null) {
          for (Entry<String, Object> entry : values.entrySet()) {
            if (dsNames.contains(entry.getKey()) && NumberUtils.isNumeric(entry.getValue())) {
              sample.setValue(entry.getKey(), Double.valueOf(entry.getValue().toString()));
            }
          }
        }
      }
      sample.update();
    } finally {
      if (db != null) {
        db.close();
      }
    }
  }
View Full Code Here

Examples of org.jrobin.core.RrdDb

  /**
   * If the database file doesn't exist, it'll get created, otherwise, it'll
   * be returned in r/w mode.
   */
  protected RrdDb createOrOpenDatabase() throws Exception {
    RrdDb result;
    if (!this.outputFile.exists()) {
      FileUtils.forceMkdir(this.outputFile.getParentFile());
      RrdDefTemplate t = new RrdDefTemplate(this.templateFile);
      t.setVariable("database", this.outputFile.getCanonicalPath());
      RrdDef def = t.getRrdDef();
      result = new RrdDb(def);
    } else {
      result = new RrdDb(this.outputFile.getCanonicalPath());
    }
    return result;
  }
View Full Code Here

Examples of org.jrobin.core.RrdDb

    super(INVALID_NODE);
  }

  boolean setFile(File file) {
    try {
      RrdDb rrd = new RrdDb(file.getAbsolutePath(), true);
      try {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RrdNode(rrd));
        int dsCount = rrd.getRrdDef().getDsCount();
        int arcCount = rrd.getRrdDef().getArcCount();
        for (int dsIndex = 0; dsIndex < dsCount; dsIndex++) {
          DefaultMutableTreeNode dsNode =
              new DefaultMutableTreeNode(new RrdNode(rrd, dsIndex));
          for (int arcIndex = 0; arcIndex < arcCount; arcIndex++) {
            DefaultMutableTreeNode arcNode =
                new DefaultMutableTreeNode(new RrdNode(rrd, dsIndex, arcIndex));
            dsNode.add(arcNode);
          }
          root.add(dsNode);
        }
        setRoot(root);
      }
      finally {
        rrd.close();
      }
      return true;
    }
    catch (IOException e) {
      setRoot(INVALID_NODE);
View Full Code Here

Examples of org.jrobin.core.RrdDb

  void setFile(File file) {
    try {
      values = null;
      String path = file.getAbsolutePath();
      RrdDb rrd = new RrdDb(path, true);
      try {
        Header header = rrd.getHeader();
        String signature = header.getSignature();
        String step = "" + header.getStep();
        String lastTimestamp = header.getLastUpdateTime() + " [" +
            new Date(header.getLastUpdateTime() * 1000L) + "]";
        String datasources = "" + header.getDsCount();
        String archives = "" + header.getArcCount();
        String size = rrd.getRrdBackend().getLength() + " bytes";
        values = new Object[] {
            path, signature, step, lastTimestamp, datasources, archives, size
        };
      }
      finally {
        rrd.close();
      }
      fireTableDataChanged();
    }
    catch (IOException e) {
      Util.error(null, e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.