Przeglądaj źródła

多余日志去除,日期转换监听器添加

demon 8 lat temu
rodzic
commit
eff0d84665

+ 5 - 5
hos-broker/src/main/java/com/yihu/hos/common/scheduler/EnvScheduler.java

@ -23,14 +23,14 @@ import java.util.List;
@Component
public class EnvScheduler {
    private static Logger logger = LoggerFactory.getLogger(EnvScheduler.class);
    static private final Logger logger = LoggerFactory.getLogger(EnvScheduler.class);
    @Scheduled(cron="0 0/1 * * * ?") //每分钟执行一次
    public void statusCheck() {
        System.out.println("每分钟执行一次。开始============================================");
        logger.info("每分钟执行一次。开始============================================");
        //TODO 采集服务器健康监控指标数据 statusTask.healthCheck();
        collectEnvHealth();
        System.out.println("每分钟执行一次。结束。");
        logger.info("每分钟执行一次。结束。");
    }
    public String collectEnvHealth(){
@ -73,9 +73,9 @@ public class EnvScheduler {
//    @Scheduled(fixedRate=10000)
//    public void testTasks() {
//        System.out.println("每10秒执行一次。开始……");
//        logger.info("每10秒执行一次。开始……");
//        //statusTask.healthCheck();
//        System.out.println("每10秒执行一次。结束。");
//        logger.info("每10秒执行一次。结束。");
//    }
}

+ 61 - 60
hos-broker/src/main/java/com/yihu/hos/common/util/SigarUtil.java

@ -15,7 +15,8 @@ import java.util.*;
 * Created at 2016/10/10.
 */
public class SigarUtil {
    
    static private final Logger logger = LoggerFactory.getLogger(SigarUtil.class);
    public final static Sigar sigar = initSigar();
    private static Sigar initSigar() {
@ -49,7 +50,7 @@ public class SigarUtil {
//        double d = 0;
//        String f = df.format(d);
//        double e = Double.parseDouble(String.format("%.2f", d));
//        System.out.println(e);
//        logger.info(e);
//    }
    /**
@ -81,41 +82,41 @@ public class SigarUtil {
        String userName = map.get("USERNAME");// 获取用户名
        String computerName = map.get("COMPUTERNAME");// 获取计算机名
        String userDomain = map.get("USERDOMAIN");// 获取计算机域名
        System.out.println("用户名:    " + userName);
        System.out.println("计算机名:    " + computerName);
        System.out.println("计算机域名:    " + userDomain);
        System.out.println("本地ip地址:    " + ip);
        System.out.println("本地主机名:    " + addr.getHostName());
        System.out.println("JVM可以使用的总内存:    " + r.totalMemory());
        System.out.println("JVM可以使用的剩余内存:    " + r.freeMemory());
        System.out.println("JVM可以使用的处理器个数:    " + r.availableProcessors());
        System.out.println("Java的运行环境版本:    " + props.getProperty("java.version"));
        System.out.println("Java的运行环境供应商:    " + props.getProperty("java.vendor"));
        System.out.println("Java供应商的URL:    " + props.getProperty("java.vendor.url"));
        System.out.println("Java的安装路径:    " + props.getProperty("java.home"));
        System.out.println("Java的虚拟机规范版本:    " + props.getProperty("java.vm.specification.version"));
        System.out.println("Java的虚拟机规范供应商:    " + props.getProperty("java.vm.specification.vendor"));
        System.out.println("Java的虚拟机规范名称:    " + props.getProperty("java.vm.specification.name"));
        System.out.println("Java的虚拟机实现版本:    " + props.getProperty("java.vm.version"));
        System.out.println("Java的虚拟机实现供应商:    " + props.getProperty("java.vm.vendor"));
        System.out.println("Java的虚拟机实现名称:    " + props.getProperty("java.vm.name"));
        System.out.println("Java运行时环境规范版本:    " + props.getProperty("java.specification.version"));
        System.out.println("Java运行时环境规范供应商:    " + props.getProperty("java.specification.vender"));
        System.out.println("Java运行时环境规范名称:    " + props.getProperty("java.specification.name"));
        System.out.println("Java的类格式版本号:    " + props.getProperty("java.class.version"));
        System.out.println("Java的类路径:    " + props.getProperty("java.class.path"));
        System.out.println("加载库时搜索的路径列表:    " + props.getProperty("java.library.path"));
        System.out.println("默认的临时文件路径:    " + props.getProperty("java.io.tmpdir"));
        System.out.println("一个或多个扩展目录的路径:    " + props.getProperty("java.ext.dirs"));
        System.out.println("操作系统的名称:    " + props.getProperty("os.name"));
        System.out.println("操作系统的构架:    " + props.getProperty("os.arch"));
        System.out.println("操作系统的版本:    " + props.getProperty("os.version"));
        System.out.println("文件分隔符:    " + props.getProperty("file.separator"));
        System.out.println("路径分隔符:    " + props.getProperty("path.separator"));
        System.out.println("行分隔符:    " + props.getProperty("line.separator"));
        System.out.println("用户的账户名称:    " + props.getProperty("user.name"));
        System.out.println("用户的主目录:    " + props.getProperty("user.home"));
        System.out.println("用户的当前工作目录:    " + props.getProperty("user.dir"));
        logger.info("用户名:    " + userName);
        logger.info("计算机名:    " + computerName);
        logger.info("计算机域名:    " + userDomain);
        logger.info("本地ip地址:    " + ip);
        logger.info("本地主机名:    " + addr.getHostName());
        logger.info("JVM可以使用的总内存:    " + r.totalMemory());
        logger.info("JVM可以使用的剩余内存:    " + r.freeMemory());
        logger.info("JVM可以使用的处理器个数:    " + r.availableProcessors());
        logger.info("Java的运行环境版本:    " + props.getProperty("java.version"));
        logger.info("Java的运行环境供应商:    " + props.getProperty("java.vendor"));
        logger.info("Java供应商的URL:    " + props.getProperty("java.vendor.url"));
        logger.info("Java的安装路径:    " + props.getProperty("java.home"));
        logger.info("Java的虚拟机规范版本:    " + props.getProperty("java.vm.specification.version"));
        logger.info("Java的虚拟机规范供应商:    " + props.getProperty("java.vm.specification.vendor"));
        logger.info("Java的虚拟机规范名称:    " + props.getProperty("java.vm.specification.name"));
        logger.info("Java的虚拟机实现版本:    " + props.getProperty("java.vm.version"));
        logger.info("Java的虚拟机实现供应商:    " + props.getProperty("java.vm.vendor"));
        logger.info("Java的虚拟机实现名称:    " + props.getProperty("java.vm.name"));
        logger.info("Java运行时环境规范版本:    " + props.getProperty("java.specification.version"));
        logger.info("Java运行时环境规范供应商:    " + props.getProperty("java.specification.vender"));
        logger.info("Java运行时环境规范名称:    " + props.getProperty("java.specification.name"));
        logger.info("Java的类格式版本号:    " + props.getProperty("java.class.version"));
        logger.info("Java的类路径:    " + props.getProperty("java.class.path"));
        logger.info("加载库时搜索的路径列表:    " + props.getProperty("java.library.path"));
        logger.info("默认的临时文件路径:    " + props.getProperty("java.io.tmpdir"));
        logger.info("一个或多个扩展目录的路径:    " + props.getProperty("java.ext.dirs"));
        logger.info("操作系统的名称:    " + props.getProperty("os.name"));
        logger.info("操作系统的构架:    " + props.getProperty("os.arch"));
        logger.info("操作系统的版本:    " + props.getProperty("os.version"));
        logger.info("文件分隔符:    " + props.getProperty("file.separator"));
        logger.info("路径分隔符:    " + props.getProperty("path.separator"));
        logger.info("行分隔符:    " + props.getProperty("line.separator"));
        logger.info("用户的账户名称:    " + props.getProperty("user.name"));
        logger.info("用户的主目录:    " + props.getProperty("user.home"));
        logger.info("用户的当前工作目录:    " + props.getProperty("user.dir"));
    }
    /**
@ -182,37 +183,37 @@ public class SigarUtil {
    private static void os() {
        OperatingSystem OS = OperatingSystem.getInstance();
        // 操作系统内核类型如: 386、486、586等x86
        System.out.println("操作系统:    " + OS.getArch());
        System.out.println("操作系统CpuEndian():    " + OS.getCpuEndian());//
        System.out.println("操作系统DataModel():    " + OS.getDataModel());//
        logger.info("操作系统:    " + OS.getArch());
        logger.info("操作系统CpuEndian():    " + OS.getCpuEndian());//
        logger.info("操作系统DataModel():    " + OS.getDataModel());//
        // 系统描述
        System.out.println("操作系统的描述:    " + OS.getDescription());
        logger.info("操作系统的描述:    " + OS.getDescription());
        // 操作系统类型
        // System.out.println("OS.getName():    " + OS.getName());
        // System.out.println("OS.getPatchLevel():    " + OS.getPatchLevel());//
        // logger.info("OS.getName():    " + OS.getName());
        // logger.info("OS.getPatchLevel():    " + OS.getPatchLevel());//
        // 操作系统的卖主
        System.out.println("操作系统的卖主:    " + OS.getVendor());
        logger.info("操作系统的卖主:    " + OS.getVendor());
        // 卖主名称
        System.out.println("操作系统的卖主名:    " + OS.getVendorCodeName());
        logger.info("操作系统的卖主名:    " + OS.getVendorCodeName());
        // 操作系统名称
        System.out.println("操作系统名称:    " + OS.getVendorName());
        logger.info("操作系统名称:    " + OS.getVendorName());
        // 操作系统卖主类型
        System.out.println("操作系统卖主类型:    " + OS.getVendorVersion());
        logger.info("操作系统卖主类型:    " + OS.getVendorVersion());
        // 操作系统的版本号
        System.out.println("操作系统的版本号:    " + OS.getVersion());
        logger.info("操作系统的版本号:    " + OS.getVersion());
    }
    private static void who() throws SigarException {
        Who who[] = sigar.getWhoList();
        if (who != null && who.length > 0) {
            for (int i = 0; i < who.length; i++) {
                // System.out.println("当前系统进程表中的用户名" + String.valueOf(i));
                // logger.info("当前系统进程表中的用户名" + String.valueOf(i));
                Who _who = who[i];
                System.out.println("用户控制台:    " + _who.getDevice());
                System.out.println("用户host:    " + _who.getHost());
                // System.out.println("getTime():    " + _who.getTime());
                logger.info("用户控制台:    " + _who.getDevice());
                logger.info("用户host:    " + _who.getHost());
                // logger.info("getTime():    " + _who.getTime());
                // 当前系统进程表中的用户名
                System.out.println("当前系统进程表中的用户名:    " + _who.getUser());
                logger.info("当前系统进程表中的用户名:    " + _who.getUser());
            }
        }
    }
@ -307,12 +308,12 @@ public class SigarUtil {
                    || NetFlags.NULL_HWADDR.equals(cfg.getHwaddr())) {
                continue;
            }
            System.out.println(cfg.getName() + "IP地址:" + cfg.getAddress());// IP地址
            System.out.println(cfg.getName() + "网关广播地址:" + cfg.getBroadcast());// 网关广播地址
            System.out.println(cfg.getName() + "网卡MAC地址:" + cfg.getHwaddr());// 网卡MAC地址
            System.out.println(cfg.getName() + "子网掩码:" + cfg.getNetmask());// 子网掩码
            System.out.println(cfg.getName() + "网卡描述信息:" + cfg.getDescription());// 网卡描述信息
            System.out.println(cfg.getName() + "网卡类型" + cfg.getType());//
            logger.info(cfg.getName() + "IP地址:" + cfg.getAddress());// IP地址
            logger.info(cfg.getName() + "网关广播地址:" + cfg.getBroadcast());// 网关广播地址
            logger.info(cfg.getName() + "网卡MAC地址:" + cfg.getHwaddr());// 网卡MAC地址
            logger.info(cfg.getName() + "子网掩码:" + cfg.getNetmask());// 子网掩码
            logger.info(cfg.getName() + "网卡描述信息:" + cfg.getDescription());// 网卡描述信息
            logger.info(cfg.getName() + "网卡类型" + cfg.getType());//
        }
@ -341,7 +342,7 @@ public class SigarUtil {
            long txbps = ((txBytesEnd - txBytesStart) * 8 / 1024) / ((end - start) / 1000);
            bps.put("rxbps", rxbps);
            bps.put("txbps", txbps);
            System.out.println("#######rxbps: " + rxbps + " txbps: " + txbps);
            logger.info("#######rxbps: " + rxbps + " txbps: " + txbps);
        } catch (SigarException e) {
        } catch (Exception e) {
        }

+ 5 - 1
hos-rest/src/main/java/com/yihu/hos/rest/services/crawler/DatapushService.java

@ -1,6 +1,8 @@
package com.yihu.hos.rest.services.crawler;
import com.yihu.ehr.dbhelper.mongodb.MongodbHelper;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.rest.common.dao.DatacollectDao;
import com.yihu.hos.rest.common.dao.DatacollectLogDao;
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
@ -23,6 +25,8 @@ import java.util.List;
@Service
public class DatapushService {
    static private final Logger logger = LoggerFactory.getLogger(DatapushService.class);
    @Autowired
    private DatacollectDao datacollect;
@ -129,7 +133,7 @@ public class DatapushService {
                {
                    if(mongo.errorMessage!=null && mongo.errorMessage.length()>0)
                    {
                        System.out.print(mongo.errorMessage);
                        logger.debug(mongo.errorMessage);
                        msg = "Mongodb保存失败!(表:"+datasetCode+",数据:"+dataString+")"+mongo.errorMessage;
                    }
                    else {

+ 1 - 3
src/main/java/com/yihu/hos/ESBApplication.java

@ -3,14 +3,12 @@ package com.yihu.hos;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.jms.annotation.EnableJms;
import javax.jms.Queue;
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@SpringBootApplication
@EnableJms
public class ESBApplication {

+ 6 - 0
src/main/java/com/yihu/hos/config/WebMvcConfig.java

@ -1,6 +1,7 @@
package com.yihu.hos.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.hos.common.ApplicationStart;
import com.yihu.hos.filter.HibernateFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -64,6 +65,11 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
        return new ObjectMapper();
    }
    @Bean
    public ApplicationStart applicationStart() {
        return new ApplicationStart();
    }
    /* hibernate配置 */
//    @Bean

+ 0 - 1
src/main/java/com/yihu/hos/crawler/storage/DocumentStorage.java

@ -50,7 +50,6 @@ public class DocumentStorage extends MongodbStorage {
        if (jsonObject != null) {
            String dataSetCode = jsonObject.get(getKey()).asText();
            String documentId = jsonObject.path(getKey()).asText();
            System.out.println(documentId);
            String patientId = jsonObject.get(PATIENT_ID).asText();
            String eventNo = jsonObject.get(EVENT_NO).asText();

+ 2 - 0
src/main/java/com/yihu/hos/datacollect/controller/DataCollectController.java

@ -185,6 +185,7 @@ public class DataCollectController extends BaseController {
        try {
            RsJobConfig obj = new RsJobConfig();
//            ConvertUtils.register(new DateLocaleConverter(), Date.class);
            BeanUtils.populate(obj, request.getParameterMap());
            String time=request.getParameter("jobNextTime");
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -195,6 +196,7 @@ public class DataCollectController extends BaseController {
            String jobDataset = request.getParameter("jobDataset");
            return datacollect.updateJob(obj, cron, jobDataset);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error("修改任务失败!");
        }
    }

+ 1 - 1
src/main/java/com/yihu/hos/datacollect/service/DatacollectService.java

@ -546,7 +546,7 @@ public class DatacollectService implements IDatacollectService {
                b = mongo.insert(stdDatasetCode, list);
                if (!b) {
                    if (mongo.errorMessage != null && mongo.errorMessage.length() > 0) {
                        System.out.print(mongo.errorMessage);
                        logger.debug(mongo.errorMessage);
                        return mongo.errorMessage;
                    } else {
                        return "Mongodb保存失败!(表:" + stdDatasetCode + ")";

+ 5 - 1
src/main/java/com/yihu/hos/datacollect/service/DatapushService.java

@ -2,6 +2,8 @@ package com.yihu.hos.datacollect.service;
import com.yihu.ehr.dbhelper.mongodb.MongodbHelper;
import com.yihu.hos.common.Services;
import com.yihu.hos.core.log.Logger;
import com.yihu.hos.core.log.LoggerFactory;
import com.yihu.hos.datacollect.dao.intf.IDatacollectDao;
import com.yihu.hos.datacollect.dao.intf.IDatacollectLogDao;
import com.yihu.hos.datacollect.service.intf.IDatapushService;
@ -25,6 +27,8 @@ import java.util.List;
@Service(Services.DatapushService)
public class DatapushService implements IDatapushService {
    static private final Logger logger = LoggerFactory.getLogger(DatapushService.class);
    @Autowired
    private IDatacollectDao datacollect;
@ -132,7 +136,7 @@ public class DatapushService implements IDatapushService {
                {
                    if(mongo.errorMessage!=null && mongo.errorMessage.length()>0)
                    {
                        System.out.print(mongo.errorMessage);
                        logger.debug(mongo.errorMessage);
                        msg = "Mongodb保存失败!(表:"+datasetCode+",数据:"+dataString+")"+mongo.errorMessage;
                    }
                    else {

+ 24 - 2
hos-broker/src/main/java/com/yihu/hos/controllers/ServerEnvironmentController.java

@ -1,10 +1,12 @@
package com.yihu.hos.controllers;
package com.yihu.hos.server.controller;
import com.yihu.hos.services.ServerEnvironmentService;
import com.yihu.hos.server.services.ServerEnvironmentService;
import com.yihu.hos.web.framework.model.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -24,6 +26,26 @@ public class ServerEnvironmentController {
    @Resource(name = ServerEnvironmentService.BEAN_ID)
    private ServerEnvironmentService serverEnvironmentService;
    @RequestMapping("/initial")
    public String resourceBrowse(
            Model model,
            @ApiParam(name = "type", value = "类型", required = true)
            @RequestParam(value = "type") String type,
            @ApiParam(name = "beginTime", value = "开始时间", required = true)
            @RequestParam(value = "beginTime") String beginTime,
            @ApiParam(name = "endTime", value = "结束时间", required = true)
            @RequestParam(value = "endTime") String endTime) {
        try {
            JSONArray array = serverEnvironmentService.getMonitorInfoTest(type, beginTime, endTime);
                model.addAttribute("monitorModel", array);
            model.addAttribute("contentPage", "server/monitor");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "partView";
    }
    @RequestMapping(value = "/usage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取服务器使用率", produces = "application/json", notes = "获取服务器硬件使用率")

+ 22 - 1
hos-broker/src/main/java/com/yihu/hos/services/ServerEnvironmentService.java

@ -1,4 +1,4 @@
package com.yihu.hos.services;
package com.yihu.hos.server.services;
import com.mongodb.*;
import com.yihu.hos.core.datatype.DateUtil;
@ -105,6 +105,27 @@ public class ServerEnvironmentService {
        return actionResult;
    }
    public JSONArray getMonitorInfoTest(String table,String beginTime, String endTime) {
        mongoOperations = new MongoTemplate(mongo, envHealth);
        DBCollection envCollection = mongoOperations.getCollection(table);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
                new BasicDBObject[]{
                        new BasicDBObject().append("create_time",
                                new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
                        new BasicDBObject().append("create_time",
                                new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
        JSONArray result = new JSONArray();
        DBCursor cursor = envCollection.find(queryObject);
        while(cursor.hasNext()) {
            DBObject dbObject = cursor.next();
            dbObject.removeField("_id");
            result.put(dbObject);
            System.out.println(dbObject.toString());
        }
        return result;
    }