コード例 #1
0
 /**
  * Get the system properties
  *
  * @return
  */
 private JsonValue getSystemProperties() {
   JsonObject report = JsonValueBuilder.jsonValue();
   Properties sysProps = System.getProperties();
   for (String propertyName : sysProps.stringPropertyNames()) {
     report.put(propertyName, sysProps.getProperty(propertyName));
   }
   return report.build();
 }
コード例 #2
0
  /**
   * Creates a JSON field for a callback.
   *
   * @param name The name of the field.
   * @param values The array value of the field.
   * @return The JSON field object.
   */
  final JsonValue createJsonField(String name, Object[] values) {
    JsonArray jsonArray =
        JsonValueBuilder.jsonValue().put("name", name == null ? "" : name).array("value");

    if (values != null) {
      for (Object value : values) {
        jsonArray.add(value);
      }
    }
    JsonObject jsonObject = jsonArray.build();

    return jsonObject.build();
  }
コード例 #3
0
  /**
   * Create the infoReport
   *
   * @param record
   * @return
   */
  public JsonValue infoReport(Record record) {
    JsonObject report = JsonValueBuilder.jsonValue();

    report.put(GLOBAL_INFO_LABEL, globalInformationReport(record).asMap());
    report.put(RECORD_LABEL, RecordProperties.toJson(record.getRecordProperties()).asMap());
    report.put(JVM_LABEL, getJVMInformation().asMap());
    report.put(SYSTEM_PROPERTIES_LABEL, getSystemProperties().asMap());

    return report.build();
  }
コード例 #4
0
  /** Create the global information report * @return */
  private JsonValue globalInformationReport(Record record) {

    JsonObject report = JsonValueBuilder.jsonValue();
    synchronized (dateFormat) {
      report.put(DATE_LABEL, dateFormat.format(new Date()));
    }
    report.put(OPENAM_VERSION_LABEL, SystemPropertiesManager.get(Constants.AM_VERSION));

    // OpenAM properties contain a part of the OpenAM configuration, we need to have the config
    // export enable
    if (record.getRecordProperties().isConfigExportEnabled()) {
      JsonObject openAMPropertiesJson = JsonValueBuilder.jsonValue();
      Properties sysProps = SystemProperties.getProperties();
      for (String propertyName : sysProps.stringPropertyNames()) {
        report.put(propertyName, sysProps.getProperty(propertyName));
      }
      report.put(OPENAM_PROPERTIES_LABEL, openAMPropertiesJson.build().asMap());
    }

    return report.build();
  }
コード例 #5
0
  /**
   * Create the JVM information
   *
   * @return
   */
  private JsonValue getJVMInformation() {
    JsonObject report = JsonValueBuilder.jsonValue();

    // Arguments
    List<String> arguments = runtimeMxBean.getInputArguments();
    JsonArray argumentsJson = report.array(JVM_ARGUMENTS_LABEL);
    for (String argument : arguments) {
      argumentsJson.add(argument);
    }

    // some useful jvm properties
    JsonObject propertiesJson = JsonValueBuilder.jsonValue();

    propertiesJson.put("java.vm.info", System.getProperty("java.vm.info"));
    propertiesJson.put("java.vm.name", System.getProperty("java.vm.info"));
    propertiesJson.put(
        "java.vm.specification.name", System.getProperty("java.vm.specification.name"));
    propertiesJson.put(
        "java.vm.specification.vendor", System.getProperty("java.vm.specification.vendor"));
    propertiesJson.put(
        "java.vm.specification.version", System.getProperty("java.vm.specification.version"));
    propertiesJson.put("java.vm.vendor", System.getProperty("java.vm.vendor"));
    propertiesJson.put("java.vm.version", System.getProperty("java.vm.version"));

    report.put(JVM_PROPERTIES_LABEL, propertiesJson.build().asMap());

    report.put(JVM_JAVA_VERSION_LABEL, System.getProperty("java.version"));

    // Memory
    JsonObject memoryJson = JsonValueBuilder.jsonValue();
    memoryJson.put(JVM_UNIT_MEMORY_LABEL, FileSizeUnit.MB);

    // Getting the runtime reference from system
    Runtime runtime = Runtime.getRuntime();

    // Print used memory
    memoryJson.put(
        JVM_USED_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.totalMemory() - runtime.freeMemory()));

    // Print free memory
    memoryJson.put(JVM_FREE_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.freeMemory()));

    // Print total available memory
    memoryJson.put(JVM_TOTAL_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.totalMemory()));

    // Print Maximum available memory
    memoryJson.put(JVM_MAX_MEMORY_LABEL, FileSizeUnit.B.toMB(runtime.maxMemory()));

    // GNU systems don't support the "sun.arch.data.model" property, so we print both
    memoryJson.put(JVM_BIT_SIZE_GNU_LABEL, System.getProperty("sun.arch.data.model"));
    memoryJson.put(JVM_BIT_SIZE_LABEL, System.getProperty("os.arch"));

    report.put(JVM_MEMORY_LABEL, memoryJson.build().asMap());

    return report.build();
  }