📄 checkmain.java.svn-base
字号:
package collector.checkts;
import java.util.*;
import collector.common.*;
import pbs.service.vo.*;
import pbs.service.function.*;
public class CheckMain
extends Thread {
process_info pinfo = null;
processFunc pfunc = null;
public CheckMain() {
}
public static void main(String[] args) {
CFunction.getProperties();
CheckProcess m_process = new CheckProcess();
m_process.start();
CheckMain m_CheckMain = new CheckMain();
m_CheckMain.init();
m_CheckMain.start();
}
public int init() {
pfunc = new processFunc(CheckDefine.DEBUG_NO);
pinfo = (new processFunc(CheckDefine.DEBUG_NO)).getProcessInfo("checkts"); //检测终端服务器process_name
double factor = Math.random();
pfunc.setProcessInfoStartTime(pinfo,commonFunc.getCurTime());
System.out.println(" 开始进程监测: "+this.getTimeStr(commonFunc.getCurTime()));
return 1;
}
public void run() {
try {
while (true) {
pfunc.setProcessInfoLastRefreshTime(pinfo, commonFunc.getCurTime());
pfunc.updateProcessInfo(pinfo);
System.out.println(" 进程监测时间: " + this.getTimeStr(commonFunc.getCurTime()));
try {
try {
Thread.sleep(60 * 1000 * 5); //五分钟监测一次
}
catch (Exception ee) {
System.out.println("error while Thread.sleep()");
}
}
catch (Exception ee) {
System.out.println("error while Thread.sleep()");
}
}
}
catch (Exception ee) {
ee.printStackTrace();
}
}
public static String getTimeStr(long time) {//秒
try {
if (time > 0) {
Date m_date = new java.util.Date(time*1000);
int year = m_date.getYear();
int month = m_date.getMonth() + 1;
int date = m_date.getDate();
int hour = m_date.getHours();
int min = m_date.getMinutes();
int sec = m_date.getSeconds();
m_date = null;
StringBuffer string = new StringBuffer("");
Integer integer = new Integer(year + 1900);
string.append(integer.toString());
string.append("年");
integer = new Integer(month);
string.append(integer.toString());
string.append("月");
integer = new Integer(date);
string.append(integer.toString());
string.append("日");
integer = new Integer(hour);
string.append(integer.toString());
string.append("时");
integer = new Integer(min);
string.append(integer.toString());
string.append("分");
integer = new Integer(sec);
string.append(integer.toString());
string.append("秒");
return string.toString();
}
else {
return "未定";
}
}
catch (Exception exception) {
return " ##";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -