zoukankan      html  css  js  c++  java
  • 日志监听

    package com.ods.common.listener;


    import javax.servlet.http.HttpServletRequest;

    import org.apache.struts2.ServletActionContext;

    import com.ods.common.util.FileUtil;
    import com.ods.common.util.PropUtil;
    import com.ods.common.util.TimeUtil;
    import com.opensymphony.xwork2.ActionContext;


    /**
    * ODS使用日志监听
    *
    * @author MeiHaiPing
    *
    */
    public class ShowSystemListener extends Thread {

    public void run() {
    try {
    int sleeptime = Integer.parseInt(PropUtil.getPropertyValue("ods.sys.port.sleep.time", "1"));
    String sysShow = PropUtil.getPropertyValue("ods.sys.show", "1");
    String systemPath = FileUtil.getSystemPath().toLowerCase();
    if(!sysShow.equals("1"))
    return;
    if(systemPath.indexOf("tomcat")>=0 && systemPath.indexOf("webapps")>=0)
    systemPath = systemPath.substring(systemPath.indexOf("tomcat")+8,systemPath.indexOf("webapps")-1);
    // 1分钟后再启动
    // Thread.sleep(1*sleeptime*60*1000);
    int i = 1;
    Runtime rt=Runtime.getRuntime();
    long totalMemory = rt.totalMemory()/1000/1000;
    long freeMemory = rt.freeMemory( )/1000/1000;
    while(i>0)
    {
    System.out.println(TimeUtil.getCurrentTime()+"===>"+sleeptime+"分钟===>"+systemPath+"===>TotalM:"+totalMemory+"M===>FreeM:"+freeMemory+"M");
    Thread.sleep(1*sleeptime*60*1000);
    }

    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    static public void listener() {
    ShowSystemListener listener = new ShowSystemListener();
    listener.start();
    }
    }

  • 相关阅读:
    Confluence 6 快捷键
    Confluence 6 快捷键
    【转】Linux常用命令
    【转】Linux常用命令
    【转】Linux常用命令
    互联网分布式微服务云平台规划分析--服务监控中心
    .NET Framework基础知识(五)(转载)
    Windows 下安装mysql
    kvm
    s5-6 Linux 标准输出 系统优化 目录结构
  • 原文地址:https://www.cnblogs.com/swite/p/10141900.html
Copyright © 2011-2022 走看看