src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/web/NamenodeAnalyticsMethods.java
@GET
  @Path("/system")
  @Produces({MediaType.TEXT_PLAIN})
  public Response system() {
    try {
      before();
      Runtime runtime = Runtime.getRuntime();
      OperatingSystemMXBean systemMxBean =
          (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
      RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
      MemoryMXBean mb = ManagementFactory.getMemoryMXBean();
      MemoryUsage memNonHeap = mb.getNonHeapMemoryUsage();
      MemoryUsage memHeap = mb.getHeapMemoryUsage();

      StringBuilder sb = new StringBuilder();
      int availableCores = runtime.availableProcessors();
      double cpuLoad = systemMxBean.getSystemCpuLoad();
      double procLoad = systemMxBean.getProcessCpuLoad();

      sb.append("Server uptime (ms): ").append(rb.getUptime()).append("\n\n");

      sb.append("Available Processor Cores: ").append(availableCores).append("\n");
      sb.append("System CPU Load: ").append(cpuLoad).append("\n");
      sb.append("Process CPU Load: ").append(procLoad).append("\n\n");

      sb.append("Non-Heap Used Memory (KB): ").append(memNonHeap.getUsed() / 1024).append("\n");
      sb.append("Non-Heap Committed Memory (KB): ")
          .append((memNonHeap.getCommitted() / 1024))
          .append("\n");
      sb.append("Non-Heap Max Memory (KB): ").append((memNonHeap.getMax() / 1024)).append("\n\n");

      sb.append("Heap Used Memory (KB): ").append(memHeap.getUsed() / 1024).append("\n");
      sb.append("Heap Committed Memory (KB): ")
          .append((memHeap.getCommitted() / 1024))
          .append("\n");
      sb.append("Heap Max Memory (KB): ").append((memHeap.getMax() / 1024)).append("\n\n");

      sb.append("Max Memory (KB): ").append((runtime.maxMemory() / 1024)).append("\n");

      return Response.ok(sb.toString(), MediaType.TEXT_PLAIN).build();
    } catch (RuntimeException rtex) {
      return handleException(rtex);
    } catch (Exception ex) {
      return handleException(ex);
    } finally {
      after();
    }
  }
/**
   * SYSTEM endpoint is meant to show the system resource usage of the NNA instance in PLAINTEXT
   * form. TODO: Convert the output to JSON form.
   */
SYSTEM endpoint is meant to show the system resource usage of the NNA instance in PLAINTEXT
form. TODO: Convert the output to JSON form.
SYSTEM endpoint is meant to show the system resource usage of the NNA instance in PLAINTEXT form . TODO : Convert the output to JSON form .
@GET
  @Path("/system")
  @Produces({MediaType.TEXT_PLAIN})
  public Response system() {
    try {
      before();
      Runtime runtime = Runtime.getRuntime();
      OperatingSystemMXBean systemMxBean =
          (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
      RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
      MemoryMXBean mb = ManagementFactory.getMemoryMXBean();
      MemoryUsage memNonHeap = mb.getNonHeapMemoryUsage();
      MemoryUsage memHeap = mb.getHeapMemoryUsage();
      StringBuilder sb = new StringBuilder();
      int availableCores = runtime.availableProcessors();
      double cpuLoad = systemMxBean.getSystemCpuLoad();
      double procLoad = systemMxBean.getProcessCpuLoad();
      sb.append("Server uptime (ms): ").append(rb.getUptime()).append("\n\n");
      sb.append("Available Processor Cores: ").append(availableCores).append("\n");
      sb.append("System CPU Load: ").append(cpuLoad).append("\n");
      sb.append("Process CPU Load: ").append(procLoad).append("\n\n");
      sb.append("Non-Heap Used Memory (KB): ").append(memNonHeap.getUsed() / 1024).append("\n");
      sb.append("Non-Heap Committed Memory (KB): ")
          .append((memNonHeap.getCommitted() / 1024))
          .append("\n");
      sb.append("Non-Heap Max Memory (KB): ").append((memNonHeap.getMax() / 1024)).append("\n\n");
      sb.append("Heap Used Memory (KB): ").append(memHeap.getUsed() / 1024).append("\n");
      sb.append("Heap Committed Memory (KB): ")
          .append((memHeap.getCommitted() / 1024))
          .append("\n");
      sb.append("Heap Max Memory (KB): ").append((memHeap.getMax() / 1024)).append("\n\n");
      sb.append("Max Memory (KB): ").append((runtime.maxMemory() / 1024)).append("\n");
      return Response.ok(sb.toString(), MediaType.TEXT_PLAIN).build();
    } catch (RuntimeException rtex) {
      return handleException(rtex);
    } catch (Exception ex) {
      return handleException(ex);
    } finally {
      after();
    }
  }
@ GET @ Path ( "/system" ) @ Produces ( { MediaType . TEXT_PLAIN } ) public Response system ( ) { try { before ( ) ; Runtime runtime = Runtime . getRuntime ( ) ; OperatingSystemMXBean systemMxBean = ( OperatingSystemMXBean ) ManagementFactory . getOperatingSystemMXBean ( ) ; RuntimeMXBean rb = ManagementFactory . getRuntimeMXBean ( ) ; MemoryMXBean mb = ManagementFactory . getMemoryMXBean ( ) ; MemoryUsage memNonHeap = mb . getNonHeapMemoryUsage ( ) ; MemoryUsage memHeap = mb . getHeapMemoryUsage ( ) ; StringBuilder sb = new StringBuilder ( ) ; int availableCores = runtime . availableProcessors ( ) ; double cpuLoad = systemMxBean . getSystemCpuLoad ( ) ; double procLoad = systemMxBean . getProcessCpuLoad ( ) ; sb . append ( "Server uptime (ms): " ) . append ( rb . getUptime ( ) ) . append ( "\n\n" ) ; sb . append ( "Available Processor Cores: " ) . append ( availableCores ) . append ( "\n" ) ; sb . append ( "System CPU Load: " ) . append ( cpuLoad ) . append ( "\n" ) ; sb . append ( "Process CPU Load: " ) . append ( procLoad ) . append ( "\n\n" ) ; sb . append ( "Non-Heap Used Memory (KB): " ) . append ( memNonHeap . getUsed ( ) / 1024 ) . append ( "\n" ) ; sb . append ( "Non-Heap Committed Memory (KB): " ) . append ( ( memNonHeap . getCommitted ( ) / 1024 ) ) . append ( "\n" ) ; sb . append ( "Non-Heap Max Memory (KB): " ) . append ( ( memNonHeap . getMax ( ) / 1024 ) ) . append ( "\n\n" ) ; sb . append ( "Heap Used Memory (KB): " ) . append ( memHeap . getUsed ( ) / 1024 ) . append ( "\n" ) ; sb . append ( "Heap Committed Memory (KB): " ) . append ( ( memHeap . getCommitted ( ) / 1024 ) ) . append ( "\n" ) ; sb . append ( "Heap Max Memory (KB): " ) . append ( ( memHeap . getMax ( ) / 1024 ) ) . append ( "\n\n" ) ; sb . append ( "Max Memory (KB): " ) . append ( ( runtime . maxMemory ( ) / 1024 ) ) . append ( "\n" ) ; return Response . ok ( sb . toString ( ) , MediaType . TEXT_PLAIN ) . build ( ) ; } catch ( RuntimeException rtex ) { return handleException ( rtex ) ; } catch ( Exception ex ) { return handleException ( ex ) ; } finally { after ( ) ; } }
SYSTEM endpoint is meant to show the system resource usage of the NNA instance in PLAINTEXT
 form.
SYSTEM endpoint is meant to show the system resource usage of the NNA instance in PLAINTEXT form .