Exemple #1
0
 private void parseXGrid(String xgrid) {
   if (xgrid == null) {
     return;
   }
   if (xgrid.equalsIgnoreCase("none")) {
     gdef.setDrawXGrid(false);
     return;
   }
   String[] tokens = new ColonSplitter(xgrid).split();
   if (tokens.length != 8) {
     throw new IllegalArgumentException("Invalid XGRID settings: " + xgrid);
   }
   int minorUnit = resolveUnit(tokens[0]),
       majorUnit = resolveUnit(tokens[2]),
       labelUnit = resolveUnit(tokens[4]);
   int minorUnitCount = parseInt(tokens[1]),
       majorUnitCount = parseInt(tokens[3]),
       labelUnitCount = parseInt(tokens[5]);
   int labelSpan = parseInt(tokens[6]);
   String fmt = tokens[7];
   gdef.setTimeAxis(
       minorUnit,
       minorUnitCount,
       majorUnit,
       majorUnitCount,
       labelUnit,
       labelUnitCount,
       labelSpan,
       fmt);
 }
Exemple #2
0
  public RrdGraphDef getGraphDef(
      long nowInSeconds, SourceIdentifier sourceIdentifier, boolean showMax) {
    String absoluteRrdPath = getRrdFile(sourceIdentifier).getAbsolutePath();

    RrdGraphDef graphDef = new RrdGraphDef();

    graphDef.setColor(RrdGraphConstants.COLOR_CANVAS, new Color(0xcc, 0xcc, 0xcc));
    graphDef.setNoMinorGrid(true);
    graphDef.setShowSignature(false);
    graphDef.setMinValue(0);
    graphDef.setAltAutoscaleMax(true);
    graphDef.setAltYGrid(false);
    graphDef.setTimeAxis(
        RrdGraphConstants.HOUR,
        1,
        RrdGraphConstants.HOUR,
        6,
        RrdGraphConstants.DAY,
        1,
        0,
        "yyyy-MM-dd");
    graphDef.setFilename("-");
    graphDef.setImageFormat("PNG");

    ConsolFun consolFun;
    String description;
    if (showMax) {
      consolFun = ConsolFun.MAX;
      description = " (max.)";
    } else {
      consolFun = ConsolFun.AVERAGE;
      description = " (avg.)";
    }
    graphDef.setVerticalLabel("Events/s" + description);

    graphDef.datasource(
        RrdLoggingEventHandler.TRACE,
        absoluteRrdPath,
        RrdLoggingEventHandler.TRACE_DS_NAME,
        consolFun);
    graphDef.datasource(
        RrdLoggingEventHandler.DEBUG,
        absoluteRrdPath,
        RrdLoggingEventHandler.DEBUG_DS_NAME,
        consolFun);
    graphDef.datasource(
        RrdLoggingEventHandler.INFO,
        absoluteRrdPath,
        RrdLoggingEventHandler.INFO_DS_NAME,
        consolFun);
    graphDef.datasource(
        RrdLoggingEventHandler.WARN,
        absoluteRrdPath,
        RrdLoggingEventHandler.WARN_DS_NAME,
        consolFun);
    graphDef.datasource(
        RrdLoggingEventHandler.ERROR,
        absoluteRrdPath,
        RrdLoggingEventHandler.ERROR_DS_NAME,
        consolFun);

    graphDef.area(
        RrdLoggingEventHandler.TRACE, new Color(0x00, 0x00, 0xff), RrdLoggingEventHandler.TRACE);
    graphDef.stack(
        RrdLoggingEventHandler.DEBUG, new Color(0x00, 0xff, 0x00), RrdLoggingEventHandler.DEBUG);
    graphDef.stack(
        RrdLoggingEventHandler.INFO, new Color(0xff, 0xff, 0xff), RrdLoggingEventHandler.INFO);
    graphDef.stack(
        RrdLoggingEventHandler.WARN, new Color(0xff, 0xff, 0x00), RrdLoggingEventHandler.WARN);
    graphDef.stack(
        RrdLoggingEventHandler.ERROR, new Color(0xff, 0x00, 0x00), RrdLoggingEventHandler.ERROR);

    if (showMax) {
      graphDef.datasource(
          RrdLoggingEventHandler.TOTAL,
          absoluteRrdPath,
          RrdLoggingEventHandler.TOTAL_DS_NAME,
          consolFun);
      graphDef.line(RrdLoggingEventHandler.TOTAL, Color.BLACK, RrdLoggingEventHandler.TOTAL);
    }

    graphDef.setAntiAliasing(true);
    graphDef.setLazy(false);

    String sourceTitle = createGraphTitle(sourceIdentifier);
    long before = nowInSeconds - 7 * 24 * 60 * 60;
    graphDef.setTimeSpan(before, nowInSeconds);
    graphDef.setTitle(sourceTitle);
    graphDef.setWidth(graphSize.width);
    graphDef.setHeight(graphSize.height);

    return graphDef;
  }