private SystemInfoDTO getSystemInfo()

in alpha/alpha-ui/src/main/java/org/apache/servicecomb/pack/alpha/ui/controller/IndexController.java [72:112]


  private SystemInfoDTO getSystemInfo() {
    SystemInfoDTO systemInfoDTO = new SystemInfoDTO();

    //uptime
    long startTime = metricsEndpoint.metric("process.start.time", null).getMeasurements().get(0)
        .getValue().longValue();
    long seconds = System.currentTimeMillis() / 1000 - startTime;
    int day = (int) TimeUnit.SECONDS.toDays(seconds);
    long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24);
    long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
    long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60);
    systemInfoDTO.setUpTime(String.format("%dd %dh %dm %ds", day, hours, minute, second));

    //cpus
    systemInfoDTO.setCpus(
        metricsEndpoint.metric("system.cpu.count", null).getMeasurements().get(0).getValue()
            .intValue());

    //system load window os not support
    MetricResponse metricResponse = metricsEndpoint.metric("system.load.average.1m", null);
    if (metricResponse != null) {
      systemInfoDTO.setSystemLoad(Math.round(metricResponse.getMeasurements().get(0).getValue().floatValue() * 100) / (float) 100);
    }

    //thread
    systemInfoDTO.setThreadsLive(
        metricsEndpoint.metric("jvm.threads.live", null).getMeasurements().get(0).getValue()
            .intValue());
    systemInfoDTO.setThreadsDaemon(
        metricsEndpoint.metric("jvm.threads.daemon", null).getMeasurements().get(0).getValue()
            .intValue());
    systemInfoDTO.setThreadsPeak(
        metricsEndpoint.metric("jvm.threads.peak", null).getMeasurements().get(0).getValue()
            .intValue());

    //gc
    List<Sample> samples = metricsEndpoint.metric("jvm.gc.pause", null).getMeasurements();
    systemInfoDTO.setGcCount(samples.get(0).getValue().intValue());
    systemInfoDTO.setGcTime(samples.get(1).getValue().floatValue());
    return systemInfoDTO;
  }