|
@ -1,16 +1,17 @@
|
|
|
package com.yihu.hos.scheduler;
|
|
|
package com.yihu.hos.common.scheduler;
|
|
|
|
|
|
import com.yihu.hos.common.MongodbUtil;
|
|
|
import com.yihu.hos.common.SigarUtil;
|
|
|
import com.yihu.hos.common.util.MongodbUtil;
|
|
|
import com.yihu.hos.common.util.SigarUtil;
|
|
|
import com.yihu.hos.core.datatype.DateUtil;
|
|
|
import com.yihu.hos.core.log.Logger;
|
|
|
import com.yihu.hos.core.log.LoggerFactory;
|
|
|
import com.yihu.hos.crawler.service.DataCollectDispatcher;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.bson.Document;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@ -23,7 +24,6 @@ import java.util.List;
|
|
|
public class EnvScheduler {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(EnvScheduler.class);
|
|
|
private static DataCollectDispatcher dispatch = DataCollectDispatcher.getInstance();
|
|
|
|
|
|
@Scheduled(cron="0 0/1 * * * ?") //每分钟执行一次
|
|
|
public void statusCheck() {
|
|
@ -36,8 +36,9 @@ public class EnvScheduler {
|
|
|
public String collectEnvHealth(){
|
|
|
MongodbUtil monoEnv = new MongodbUtil("envHealth");
|
|
|
try {
|
|
|
JSONObject result = new JSONObject();
|
|
|
Document result = new Document();
|
|
|
result.put("create_date", DateUtil.getCurrentString(DateUtil.DEFAULT_YMDHMSDATE_FORMAT));
|
|
|
result.put("create_time", new Date());
|
|
|
|
|
|
//cpu
|
|
|
JSONObject cpu = JSONObject.fromObject( SigarUtil.cpu());
|