public static void getServerMemoryInfo(Sigar sigar, ServerStatus status) {
    try {
      Mem mem = sigar.getMem();
      status.setTotalMem(mem.getTotal() / (1024 * 1024));
      status.setUsedMem(mem.getUsed() / (1024 * 1024));
      status.setFreeMem(mem.getFree() / (1024 * 1024));
      // 交换区
      Swap swap = sigar.getSwap();
      status.setTotalSwap(swap.getTotal() / (1024 * 1024));
      status.setUsedSwap(swap.getUsed() / (1024 * 1024));
      status.setFreeSwap(swap.getFree() / (1024 * 1024));
    } catch (Exception e) {

    }
  }
 private boolean isSwapEnabled() {
   try {
     Swap swap = sigar.getSwap();
     long swapSize = swap.getTotal();
     if (swapSize > 0) {
       return true;
     } else {
       return false;
     }
   } catch (SigarException sigarException) {
     logger.warn(
         "Could not determine if swap configuration is acceptable. Error message: {}",
         sigarException);
     return false;
   }
 }
  public static ServerInfoFormMap memory(Sigar sigar) {
    ServerInfoFormMap monitorMap = new ServerInfoFormMap();
    try {
      Runtime r = Runtime.getRuntime();
      monitorMap.put("jvmTotal", Common.div(r.totalMemory(), (1024 * 1024), 2) + "M"); // java总内存
      monitorMap.put(
          "jvmUse",
          Common.div(r.totalMemory() - r.freeMemory(), (1024 * 1024), 2) + "M"); // JVM使用内存
      monitorMap.put("jvmFree", Common.div(r.freeMemory(), (1024 * 1024), 2) + "M"); // JVM剩余内存
      monitorMap.put(
          "jvmUsage", Common.div(r.totalMemory() - r.freeMemory(), r.totalMemory(), 2)); // JVM使用率

      Mem mem = sigar.getMem();
      // 内存总量
      monitorMap.put("ramTotal", Common.div(mem.getTotal(), (1024 * 1024 * 1024), 2) + "G"); // 内存总量
      monitorMap.put("ramUse", Common.div(mem.getUsed(), (1024 * 1024 * 1024), 2) + "G"); // 当前内存使用量
      monitorMap.put(
          "ramFree", Common.div(mem.getFree(), (1024 * 1024 * 1024), 2) + "G"); // 当前内存剩余量
      monitorMap.put("ramUsage", Common.div(mem.getUsed(), mem.getTotal(), 2)); // 内存使用率

      Swap swap = sigar.getSwap();
      // 交换区总量
      monitorMap.put("swapTotal", Common.div(swap.getTotal(), (1024 * 1024 * 1024), 2) + "G");
      // 当前交换区使用量
      monitorMap.put("swapUse", Common.div(swap.getUsed(), (1024 * 1024 * 1024), 2) + "G");
      // 当前交换区剩余量
      monitorMap.put("swapFree", Common.div(swap.getFree(), (1024 * 1024 * 1024), 2) + "G");
      monitorMap.put("swapUsage", Common.div(swap.getUsed(), swap.getTotal(), 2)); //

    } catch (Exception e) {
    }
    return monitorMap;
  }