コード例 #1
0
  /**
   * 预警监控信息
   *
   * @return
   * @throws Exception
   */
  @ResponseBody
  @RequestMapping("/warnInfo")
  public Map<String, Object> warnInfo(HttpServletRequest request) throws Exception {
    ServerStatus status = ServerStatus.findServerStatus();
    Map<String, Object> dataMap = new HashMap<String, Object>();

    String cpuUsage = status.getCpuUsage();
    long FreeMem = status.getFreeMem();
    long useMem = status.getUsedMem();
    long TotalMem = status.getTotalMem();
    String serverUsage = Common.fromUsage(useMem, TotalMem);
    dataMap.put("cpuUsage", cpuUsage);
    dataMap.put("FreeMem", FreeMem);
    dataMap.put("TotalMem", TotalMem);
    dataMap.put("serverUsage", serverUsage);
    long JvmFreeMem = status.getJvmFreeMem();
    long JvmTotalMem = status.getJvmTotalMem();
    String JvmUsage = Common.fromUsage(JvmTotalMem - JvmFreeMem, JvmTotalMem);
    dataMap.put("JvmFreeMem", JvmFreeMem);
    dataMap.put("JvmTotalMem", JvmTotalMem);
    dataMap.put("JvmUsage", JvmUsage);
    dataMap.put("cpu", PropertiesUtils.findPropertiesKey("cpu"));
    dataMap.put("jvm", PropertiesUtils.findPropertiesKey("jvm"));
    dataMap.put("ram", PropertiesUtils.findPropertiesKey("ram"));
    dataMap.put("toEmail", PropertiesUtils.findPropertiesKey("toEmail"));
    dataMap.put("diskInfos", status.getDiskInfos());
    return dataMap;
  }
コード例 #2
0
 /**
  * 获取服务器基本信息
  *
  * @return
  * @throws Exception
  */
 @ResponseBody
 @RequestMapping("info")
 public Map<String, Object> serverBaseInfo() throws Exception {
   Map<String, Object> dataMap = new HashMap<String, Object>();
   ServerStatus status = ServerStatus.findServerStatus();
   ;
   dataMap.put("data", status);
   return dataMap;
 }