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