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

  • 相关阅读:
    备忘录模式---行为型
    观察者模式(Observer)---行为型
    Hadoop基础
    centos执行-查看,复制,删除-命令的脚本
    权限问题
    12月centos单词
    配置集群遇到的问题
    SSH--完全分布式主机设置【克隆过安装过Hadoop的主机后】
    java随机排座位
    NewWord
  • 原文地址:https://www.cnblogs.com/swite/p/10141900.html
Copyright © 2011-2022 走看看