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();
    }
    }

  • 相关阅读:
    内置函数
    map,reduce和filter函数
    函数式编程和尾调用
    函数作用域,匿名函数
    全局变量和局部变量
    函数和过程
    百分号字符串拼接
    集合关系运算交,差,并集
    C#基础-压缩文件及故障排除
    【QQ】前端实现QQ会话功能
  • 原文地址:https://www.cnblogs.com/swite/p/10141900.html
Copyright © 2011-2022 走看看