Package com.lanyuan.entity

Examples of com.lanyuan.entity.ServerStatus


   */
  @ResponseBody
  @RequestMapping(value = "info")
  public Map<String, Object> serverBaseInfo() throws Exception {
    Map<String, Object> dataMap = new HashMap<String, Object>();
    ServerStatus status = Common.getServerStatus();
    dataMap.put("data", status);
    return dataMap;
  }
View Full Code Here


   * @throws Exception
   */
  @ResponseBody
  @RequestMapping("/warnInfo")
  public Map<String, Object> warnInfo(HttpServletRequest request) throws Exception {
    ServerStatus status = Common.getServerStatus();
    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;
  }
View Full Code Here

  /**
   * 返回服务系统信息
   * @throws Exception
   */
  public static ServerStatus getServerStatus() throws Exception {
    ServerStatus status = new ServerStatus();
    status.setServerTime(DateFormatUtils.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss"));
    status.setServerName(System.getenv().get("COMPUTERNAME"));

    Runtime rt = Runtime.getRuntime();
    //status.setIp(InetAddress.getLocalHost().getHostAddress());
    status.setJvmTotalMem(rt.totalMemory() / (1024 * 1024));
    status.setJvmFreeMem(rt.freeMemory() / (1024 * 1024));
    status.setJvmMaxMem(rt.maxMemory()/ (1024 * 1024));
    Properties props = System.getProperties();
    status.setServerOs(props.getProperty("os.name") + " " + props.getProperty("os.arch") + " " + props.getProperty("os.version"));
    status.setJavaHome(props.getProperty("java.home"));
    status.setJavaVersion(props.getProperty("java.version"));
    status.setJavaTmpPath(props.getProperty("java.io.tmpdir"));

    Sigar sigar = new Sigar();
    getServerCpuInfo(sigar, status);
    getServerDiskInfo(sigar, status);
    getServerMemoryInfo(sigar, status);
View Full Code Here

   *
   * @throws Exception
   */
  @Scheduled(cron = "1 * *  * * ? ")
  public void task() throws Exception {
    ServerStatus status = Common.getServerStatus();
    String cpuUsage = status.getCpuUsage();// CPU使用率
    String serverUsage = Common.fromUsage(status.getUsedMem(), status.getTotalMem());// 系统内存使用率
    String JvmUsage = Common.fromUsage(status.getJvmFreeMem(), status.getJvmTotalMem());// 计算JVM内存使用率
    Properties prop = PropertiesUtils.getProperties();
    String cpu = prop.getProperty("cpu");
    String jvm = prop.getProperty("jvm");
    String ram = prop.getProperty("ram");
    String email = prop.getProperty("toEmail");
View Full Code Here

TOP

Related Classes of com.lanyuan.entity.ServerStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.