Search in sources :

Example 1 with SystemMonitorLog

use of io.jpom.model.log.SystemMonitorLog in project Jpom by dromara.

the class NodeWelcomeController method getList.

private List<SystemMonitorLog> getList() {
    NodeModel node = getNode();
    String startDateStr = getParameter("time[0]");
    String endDateStr = getParameter("time[1]");
    if (StrUtil.hasEmpty(startDateStr, endDateStr)) {
        SystemMonitorLog systemMonitorLog = new SystemMonitorLog();
        systemMonitorLog.setNodeId(node.getId());
        return dbSystemMonitorLogService.queryList(systemMonitorLog, 500, new Order("monitorTime", Direction.DESC));
    }
    // 处理时间
    DateTime startDate = DateUtil.parse(startDateStr);
    long startTime = startDate.getTime();
    DateTime endDate = DateUtil.parse(endDateStr);
    if (startDate.equals(endDate)) {
        // 时间相等
        endDate = DateUtil.endOfDay(endDate);
    }
    long endTime = endDate.getTime();
    // 开启了节点信息采集
    Page pageObj = new Page(1, 5000);
    pageObj.addOrder(new Order("monitorTime", Direction.DESC));
    Entity entity = Entity.create();
    entity.set("nodeId", node.getId());
    entity.set(" MONITORTIME", ">= " + startTime);
    entity.set("MONITORTIME", "<= " + endTime);
    return dbSystemMonitorLogService.listPageOnlyResult(entity, pageObj);
}
Also used : Order(cn.hutool.db.sql.Order) Entity(cn.hutool.db.Entity) NodeModel(io.jpom.model.data.NodeModel) SystemMonitorLog(io.jpom.model.log.SystemMonitorLog) Page(cn.hutool.db.Page) DateTime(cn.hutool.core.date.DateTime)

Example 2 with SystemMonitorLog

use of io.jpom.model.log.SystemMonitorLog in project Jpom by dromara.

the class NodeStatService method saveSystemMonitor.

private void saveSystemMonitor(List<NodeModel> modelList, JSONObject systemMonitor) {
    if (systemMonitor != null) {
        List<SystemMonitorLog> monitorLogs = modelList.stream().map(nodeModel -> {
            SystemMonitorLog log = new SystemMonitorLog();
            log.setOccupyMemory(systemMonitor.getDouble("memory"));
            log.setOccupyMemoryUsed(systemMonitor.getDouble("memoryUsed"));
            log.setOccupyDisk(systemMonitor.getDouble("disk"));
            log.setOccupyCpu(systemMonitor.getDouble("cpu"));
            log.setMonitorTime(systemMonitor.getLongValue("time"));
            log.setNetworkTime(systemMonitor.getIntValue("networkTime"));
            log.setNodeId(nodeModel.getId());
            return log;
        }).collect(Collectors.toList());
        // 
        dbSystemMonitorLogService.insert(monitorLogs);
    }
}
Also used : ObjectUtil(cn.hutool.core.util.ObjectUtil) DefaultSystemLog(cn.jiangzeyin.common.DefaultSystemLog) DbSystemMonitorLogService(io.jpom.service.dblog.DbSystemMonitorLogService) IAsyncLoad(io.jpom.cron.IAsyncLoad) JsonMessage(cn.jiangzeyin.common.JsonMessage) Service(org.springframework.stereotype.Service) NodeService(io.jpom.service.node.NodeService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BaseWorkspaceService(io.jpom.service.h2db.BaseWorkspaceService) NodeForward(io.jpom.common.forward.NodeForward) Collection(java.util.Collection) NodeModel(io.jpom.model.data.NodeModel) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) NodeStatModel(io.jpom.model.stat.NodeStatModel) NodeUrl(io.jpom.common.forward.NodeUrl) SystemMonitorLog(io.jpom.model.log.SystemMonitorLog) TimeUnit(java.util.concurrent.TimeUnit) CollUtil(cn.hutool.core.collection.CollUtil) StrUtil(cn.hutool.core.util.StrUtil) AuthorizeException(io.jpom.system.AuthorizeException) List(java.util.List) SystemClock(cn.hutool.core.date.SystemClock) JSONObject(com.alibaba.fastjson.JSONObject) Entity(cn.hutool.db.Entity) ThreadUtil(cn.hutool.core.thread.ThreadUtil) UserModel(io.jpom.model.data.UserModel) BaseServerController(io.jpom.common.BaseServerController) ServerExtConfigBean(io.jpom.system.ServerExtConfigBean) SystemMonitorLog(io.jpom.model.log.SystemMonitorLog)

Aggregations

Entity (cn.hutool.db.Entity)2 NodeModel (io.jpom.model.data.NodeModel)2 SystemMonitorLog (io.jpom.model.log.SystemMonitorLog)2 CollUtil (cn.hutool.core.collection.CollUtil)1 DateTime (cn.hutool.core.date.DateTime)1 SystemClock (cn.hutool.core.date.SystemClock)1 ThreadUtil (cn.hutool.core.thread.ThreadUtil)1 ObjectUtil (cn.hutool.core.util.ObjectUtil)1 StrUtil (cn.hutool.core.util.StrUtil)1 Page (cn.hutool.db.Page)1 Order (cn.hutool.db.sql.Order)1 DefaultSystemLog (cn.jiangzeyin.common.DefaultSystemLog)1 JsonMessage (cn.jiangzeyin.common.JsonMessage)1 JSONObject (com.alibaba.fastjson.JSONObject)1 BaseServerController (io.jpom.common.BaseServerController)1 NodeForward (io.jpom.common.forward.NodeForward)1 NodeUrl (io.jpom.common.forward.NodeUrl)1 IAsyncLoad (io.jpom.cron.IAsyncLoad)1 UserModel (io.jpom.model.data.UserModel)1 NodeStatModel (io.jpom.model.stat.NodeStatModel)1