feat:Server监控
fix:修改监控项同步策略
This commit is contained in:
parent
5b2ca8213b
commit
b1d989c9cf
|
@ -0,0 +1,16 @@
|
||||||
|
package org.jeecg.modules.base.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AlarmInfo {
|
||||||
|
|
||||||
|
private String alarmInfo;
|
||||||
|
|
||||||
|
private String alarmValue;
|
||||||
|
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date alarmStartDate;
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ public class ServerDto implements Serializable {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private String hostId;
|
||||||
|
|
||||||
private boolean online;
|
private boolean online;
|
||||||
|
|
||||||
private String serverInfo;
|
private String serverInfo;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.jeecg.common.system.base.entity.JeecgEntity;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -13,14 +14,7 @@ import java.time.LocalDate;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName(value = "sys_server")
|
@TableName(value = "sys_server")
|
||||||
public class SysServer implements Serializable {
|
public class SysServer extends JeecgEntity implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
|
@ -41,33 +35,4 @@ public class SysServer implements Serializable {
|
||||||
|
|
||||||
@TableField("host_id")
|
@TableField("host_id")
|
||||||
private String hostId;
|
private String hostId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
private LocalDate createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_by")
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改时间
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
private LocalDate updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改人
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_by")
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.controller;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||||
import org.jeecg.modules.service.IAlarmItemService;
|
import org.jeecg.modules.service.IAlarmItemService;
|
||||||
|
@ -11,15 +12,27 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Api(value = "监控项管理",tags = "监控项管理")
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Api(value = "监控项同步及管理",tags = "监控项同步及管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("alarmItem")
|
@RequestMapping("alarmItem")
|
||||||
public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemService> {
|
public class AlarmItemController extends JeecgController<AlarmItem, IAlarmItemService> {
|
||||||
|
|
||||||
@GetMapping("syncItem")
|
@GetMapping("syncServerItem")
|
||||||
@ApiOperation(value = "同步监控项信息",notes = "同步监控项信息")
|
@ApiOperation(value = "同步服务器监控项信息",notes = "同步服务器监控项信息")
|
||||||
public boolean syncItem(@RequestParam String type,
|
public boolean syncServerItem(){
|
||||||
@RequestParam String code){
|
return service.syncServerItem();
|
||||||
return service.syncItem(type,code);
|
}
|
||||||
|
|
||||||
|
@GetMapping("alarmItems")
|
||||||
|
@ApiOperation(value = "服务器所有监控项",notes = "服务器所有监控项")
|
||||||
|
public Result<?> alarmItems(@RequestParam String sourceId){
|
||||||
|
List<AlarmItem> alarmItems = service.alarmItems(sourceId);
|
||||||
|
Map<String, String> itemIds = alarmItems.stream()
|
||||||
|
.collect(Collectors.toMap(AlarmItem::getName, AlarmItem::getId));
|
||||||
|
return Result.OK(itemIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,4 +77,12 @@ public class SysServerController {
|
||||||
public Result<?> details_BasicInfo(@RequestParam String hostId){
|
public Result<?> details_BasicInfo(@RequestParam String hostId){
|
||||||
return sysServerService.details_BasicInfo(hostId);
|
return sysServerService.details_BasicInfo(hostId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("detailsAlarmInfo")
|
||||||
|
@ApiOperation(value = "ServerMonitor-Details-AlarmInfo",notes = "ServerMonitor-Details-AlarmInfo")
|
||||||
|
public Result<?> details_AlarmInfo(@RequestParam String sourceId,
|
||||||
|
@RequestParam(defaultValue = "1") Integer pageNo,
|
||||||
|
@RequestParam(defaultValue = "10") Integer pageSize){
|
||||||
|
return sysServerService.details_AlarmInfo(sourceId, pageNo, pageSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("systemMonitor")
|
@RequestMapping("systemMonitor")
|
||||||
@Api("系统监控信息查询")
|
@Api("系统监控信息管理")
|
||||||
public class SystemMonitorController {
|
public class SystemMonitorController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -15,10 +15,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
public interface MonitorAlarm {
|
public interface MonitorAlarm {
|
||||||
|
|
||||||
// --------------------后端专用-------------------
|
// --------------------后端专用-------------------
|
||||||
@GetMapping("list") // 获取指定服务器信息
|
@GetMapping("list") // 获取所有 服务器/数据库服务 信息
|
||||||
Result<Servers> listBack(@RequestParam("code") String code);
|
Result<Servers> listApp(@RequestParam("type") String type);
|
||||||
|
|
||||||
@GetMapping("list") // 获取所有在线服务器信息
|
@GetMapping("list") // 获取所有在线 服务器/数据库服务 信息
|
||||||
Result<Servers> listOnApp(@RequestParam("status") String status,
|
Result<Servers> listOnApp(@RequestParam("status") String status,
|
||||||
@RequestParam("type") String type);
|
@RequestParam("type") String type);
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,7 @@ package org.jeecg.modules.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.jeecg.modules.base.dto.IdCount;
|
import org.jeecg.modules.base.dto.*;
|
||||||
import org.jeecg.modules.base.dto.ServerDto;
|
|
||||||
import org.jeecg.modules.base.dto.SourceDto;
|
|
||||||
import org.jeecg.modules.base.dto.SourceItem;
|
|
||||||
import org.jeecg.modules.base.entity.postgre.SysServer;
|
import org.jeecg.modules.base.entity.postgre.SysServer;
|
||||||
import org.jeecg.modules.entity.AlarmHistory;
|
import org.jeecg.modules.entity.AlarmHistory;
|
||||||
|
|
||||||
|
@ -18,8 +15,7 @@ public interface SysServerMapper extends BaseMapper<SysServer> {
|
||||||
|
|
||||||
List<ServerDto> findPage(Map<String,Object> params);
|
List<ServerDto> findPage(Map<String,Object> params);
|
||||||
|
|
||||||
void saveOrUpdateHostId(@Param("hostId") String hostId,
|
|
||||||
@Param("sourceId") String sourceId);
|
|
||||||
|
|
||||||
List<SourceDto> pageAll(String itemName);
|
List<SourceDto> pageAll(String itemName);
|
||||||
|
|
||||||
|
List<AlarmInfo> alarmInfo(String sourceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
SELECT
|
SELECT
|
||||||
s.ID,
|
s.ID,
|
||||||
s.NAME,
|
s.NAME,
|
||||||
|
s.host_id,
|
||||||
s.ip_address,
|
s.ip_address,
|
||||||
COUNT (l.id) AS alarms
|
COUNT (l.id) AS alarms
|
||||||
FROM
|
FROM
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
LEFT JOIN alarm_rule r ON s.ID = r.source_id
|
LEFT JOIN alarm_rule r ON s.ID = r.source_id
|
||||||
LEFT JOIN alarm_log l ON r.ID = l.rule_id
|
LEFT JOIN alarm_log l ON r.ID = l.rule_id
|
||||||
AND l.alarm_start_date BETWEEN #{startDate} AND #{endDate}
|
AND l.alarm_start_date BETWEEN #{startDate} AND #{endDate}
|
||||||
GROUP BY s.ID, s.NAME, s.ip_address
|
GROUP BY s.ID, s.NAME, s.host_id, s.ip_address
|
||||||
<if test="pageFlag == null">
|
<if test="pageFlag == null">
|
||||||
LIMIT #{pageSize} OFFSET #{pageStart}
|
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||||
</if>
|
</if>
|
||||||
|
@ -60,7 +61,15 @@
|
||||||
s.status DESC,
|
s.status DESC,
|
||||||
s.NAME ASC
|
s.NAME ASC
|
||||||
</select>
|
</select>
|
||||||
<update id="saveOrUpdateHostId" parameterType="String">
|
<select id="alarmInfo" resultType="org.jeecg.modules.base.dto.AlarmInfo">
|
||||||
UPDATE sys_server SET host_id = #{hostId} WHERE id = #{sourceId}
|
SELECT
|
||||||
</update>
|
l.alarm_info,
|
||||||
|
l.alarm_value,
|
||||||
|
l.alarm_start_date
|
||||||
|
FROM
|
||||||
|
alarm_log l
|
||||||
|
INNER JOIN alarm_rule r ON l.rule_id = r.ID
|
||||||
|
WHERE r.source_id = #{sourceId}
|
||||||
|
ORDER BY l.alarm_start_date DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -7,7 +7,7 @@ import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface IAlarmItemService extends IService<AlarmItem> {
|
public interface IAlarmItemService extends IService<AlarmItem> {
|
||||||
boolean syncItem(String sourceType,String code);
|
boolean syncServerItem();
|
||||||
|
|
||||||
List<AlarmItem> alarmItems(String sourceId);
|
List<AlarmItem> alarmItems(String sourceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,5 @@ public interface ISysServerService extends IService<SysServer> {
|
||||||
|
|
||||||
Result<?> details_BasicInfo(String hostId);
|
Result<?> details_BasicInfo(String hostId);
|
||||||
|
|
||||||
void saveOrUpdateHostId(String sourceId, String hostId);
|
Result<?> details_AlarmInfo(String sourceId, Integer pageNo, Integer pageSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,13 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.constant.MonitorConstant;
|
||||||
import org.jeecg.common.constant.Prompt;
|
import org.jeecg.common.constant.Prompt;
|
||||||
import org.jeecg.modules.base.entity.monitor.Host;
|
import org.jeecg.modules.base.entity.monitor.Host;
|
||||||
import org.jeecg.modules.base.entity.monitor.Item;
|
import org.jeecg.modules.base.entity.monitor.Item;
|
||||||
import org.jeecg.modules.base.entity.monitor.Servers;
|
import org.jeecg.modules.base.entity.monitor.Servers;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
import org.jeecg.modules.base.entity.postgre.AlarmItem;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysServer;
|
||||||
import org.jeecg.modules.feignclient.MonitorAlarm;
|
import org.jeecg.modules.feignclient.MonitorAlarm;
|
||||||
import org.jeecg.modules.mapper.AlarmItemMapper;
|
import org.jeecg.modules.mapper.AlarmItemMapper;
|
||||||
import org.jeecg.modules.service.IAlarmItemService;
|
import org.jeecg.modules.service.IAlarmItemService;
|
||||||
|
@ -40,42 +42,38 @@ public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDatabaseService databaseService;
|
private ISysDatabaseService databaseService;
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean syncItem(String type,String code) {
|
* 同步所有服务器监控项信息
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public boolean syncServerItem() {
|
||||||
try {
|
try {
|
||||||
String sourceId = null;
|
// 获取所有服务器信息(不包括数据库服务)
|
||||||
if (SERVER.getType().equals(type)){
|
List<Host> hosts = monitorAlarm.listApp(MonitorConstant.SERVER_APP).getResult().getRecords();
|
||||||
sourceId = serverService.getByName(code);
|
// 获取所有服务器信息
|
||||||
} else if (DATABASE.getType().equals(type)) {
|
List<SysServer> servers = serverService.list();
|
||||||
|
for (SysServer server : servers) {
|
||||||
}else {
|
String name = server.getName();
|
||||||
return false;
|
String serverId = server.getId();
|
||||||
}
|
// 批量保存服务器对应的监控项信息
|
||||||
if (StrUtil.isBlank(sourceId))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Result<Servers> result = monitorAlarm.listBack(code);
|
|
||||||
List<Host> hosts = result.getResult().getRecords();
|
|
||||||
List<Item> items = new ArrayList<>();
|
|
||||||
String hostId = null;
|
|
||||||
for (Host host : hosts) {
|
for (Host host : hosts) {
|
||||||
boolean equals = host.getCode().equals(code);
|
String code = host.getCode();
|
||||||
if(!equals) continue;
|
if (!StrUtil.equals(name, code))
|
||||||
items = ListUtil.toList(host.getItems().values());
|
continue;
|
||||||
hostId = host.getHostId();
|
server.setHostId(host.getHostId());
|
||||||
}
|
List<Item> items = ListUtil.toList(host.getItems().values());
|
||||||
if (CollUtil.isEmpty(items))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
List<AlarmItem> alarmItems = new ArrayList<>();
|
List<AlarmItem> alarmItems = new ArrayList<>();
|
||||||
for (Item item : items) {
|
for (Item item : items) {
|
||||||
AlarmItem alarmItem = BeanUtil.copyProperties(item, AlarmItem.class);
|
AlarmItem alarmItem = BeanUtil.copyProperties(item, AlarmItem.class);
|
||||||
alarmItem.setId(item.getItemId());
|
alarmItem.setId(item.getItemId());
|
||||||
alarmItem.setSourceId(sourceId);
|
alarmItem.setSourceId(serverId);
|
||||||
alarmItems.add(alarmItem);
|
alarmItems.add(alarmItem);
|
||||||
}
|
}
|
||||||
serverService.saveOrUpdateHostId(sourceId, hostId);
|
saveOrUpdateBatch(alarmItems);
|
||||||
return saveOrUpdateBatch(alarmItems);
|
}
|
||||||
|
}
|
||||||
|
// 添加或更新SysServer的HostId
|
||||||
|
return serverService.updateBatchById(servers);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
@ -85,7 +83,7 @@ public class AlarmItemServiceImpl extends ServiceImpl<AlarmItemMapper, AlarmItem
|
||||||
@Override
|
@Override
|
||||||
public List<AlarmItem> alarmItems(String sourceId) {
|
public List<AlarmItem> alarmItems(String sourceId) {
|
||||||
if (StrUtil.isBlank(sourceId))
|
if (StrUtil.isBlank(sourceId))
|
||||||
return ListUtil.empty();
|
return new ArrayList<>();
|
||||||
LambdaQueryWrapper<AlarmItem> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AlarmItem> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(AlarmItem::getSourceId,sourceId);
|
wrapper.eq(AlarmItem::getSourceId,sourceId);
|
||||||
return list(wrapper);
|
return list(wrapper);
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class CalculateConcServiceImpl implements CalculateConcService {
|
||||||
String comma = SymbolConstant.COMMA;
|
String comma = SymbolConstant.COMMA;
|
||||||
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
List<AlarmAnalysisRule> analysisRules = analysisRuleService.allAnalysisRule();
|
||||||
Set<String> nuclideNames = analysisRules.stream()
|
Set<String> nuclideNames = analysisRules.stream()
|
||||||
.filter(rule -> StrUtil.isNotBlank(rule.getNuclides()))
|
|
||||||
.map(AlarmAnalysisRule::getNuclides)
|
.map(AlarmAnalysisRule::getNuclides)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
.flatMap(nuclides -> ListUtil.toList(nuclides.split(comma)).stream())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
Map<String,Object> params = new HashMap<>();
|
Map<String,Object> params = new HashMap<>();
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.jeecg.common.constant.MonitorConstant;
|
||||||
import org.jeecg.common.constant.Prompt;
|
import org.jeecg.common.constant.Prompt;
|
||||||
import org.jeecg.common.util.NumUtil;
|
import org.jeecg.common.util.NumUtil;
|
||||||
import org.jeecg.common.util.PageUtil;
|
import org.jeecg.common.util.PageUtil;
|
||||||
|
import org.jeecg.modules.base.dto.AlarmInfo;
|
||||||
import org.jeecg.modules.base.dto.BasicInfo;
|
import org.jeecg.modules.base.dto.BasicInfo;
|
||||||
import org.jeecg.modules.base.dto.ServerDto;
|
import org.jeecg.modules.base.dto.ServerDto;
|
||||||
import org.jeecg.modules.base.dto.SourceDto;
|
import org.jeecg.modules.base.dto.SourceDto;
|
||||||
|
@ -65,12 +66,12 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
List<Host> hosts = monitorAlarm.listOnApp(MonitorConstant.STATUS_ON,
|
List<Host> hosts = monitorAlarm.listOnApp(MonitorConstant.STATUS_ON,
|
||||||
MonitorConstant.SERVER_APP).getResult().getRecords();
|
MonitorConstant.SERVER_APP).getResult().getRecords();
|
||||||
for (ServerDto serverDto : serverDtos) {
|
for (ServerDto serverDto : serverDtos) {
|
||||||
String name = serverDto.getName();
|
|
||||||
int alarms = serverDto.getAlarms();
|
int alarms = serverDto.getAlarms();
|
||||||
|
String hostIdS = serverDto.getHostId();
|
||||||
serverDto.setAlarmRed(alarms > 0);
|
serverDto.setAlarmRed(alarms > 0);
|
||||||
for (Host host : hosts) {
|
for (Host host : hosts) {
|
||||||
String code = host.getCode();
|
String hostId = host.getHostId();
|
||||||
if (!StrUtil.equals(name, code)) continue;
|
if (!StrUtil.equals(hostIdS, hostId)) continue;
|
||||||
|
|
||||||
Map<String, Item> items = host.getItems();
|
Map<String, Item> items = host.getItems();
|
||||||
// cpu利用率
|
// cpu利用率
|
||||||
|
@ -246,9 +247,9 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
String status = host.getStatus();
|
String status = host.getStatus();
|
||||||
boolean online = StrUtil.equals(status, MonitorConstant.STATUS_ON);
|
boolean online = StrUtil.equals(status, MonitorConstant.STATUS_ON);
|
||||||
Map<String, Item> items = host.getItems();
|
Map<String, Item> items = host.getItems();
|
||||||
String upTime = items.get(MonitorConstant.ITEM_RUNTIME).getLastValue();
|
String runTime = items.get(MonitorConstant.ITEM_RUNTIME).getLastValue();
|
||||||
upTime = StrUtil.isBlank(upTime) ? "--" :
|
runTime = StrUtil.isBlank(runTime) ? "--" :
|
||||||
NumUtil.keepStr(Long.parseLong(upTime) / 3600.0, 1) + "h";
|
NumUtil.keepStr(Long.parseLong(runTime) / 3600.0, 1) + "h";
|
||||||
String ramSize = items.get(MonitorConstant.ITEM_RAMSIZE).getLastValue();
|
String ramSize = items.get(MonitorConstant.ITEM_RAMSIZE).getLastValue();
|
||||||
ramSize = StrUtil.isBlank(ramSize) ? "--" :
|
ramSize = StrUtil.isBlank(ramSize) ? "--" :
|
||||||
NumUtil.keepStr(Double.parseDouble(ramSize.replace("MB", "")) / 1024, 1) + "GB";
|
NumUtil.keepStr(Double.parseDouble(ramSize.replace("MB", "")) / 1024, 1) + "GB";
|
||||||
|
@ -285,7 +286,7 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
diskUsedValue.put("xData", xData);diskUsedValue.put("yData", yData);
|
diskUsedValue.put("xData", xData);diskUsedValue.put("yData", yData);
|
||||||
|
|
||||||
BasicInfo basicInfo = new BasicInfo();
|
BasicInfo basicInfo = new BasicInfo();
|
||||||
basicInfo.setRunningState(online).setRunTime(upTime).setRamSize(ramSize)
|
basicInfo.setRunningState(online).setRunTime(runTime).setRamSize(ramSize)
|
||||||
.setCpuCores(cpuCores).setTotalDiskPar(totalDiskPar).setHostName(hostName)
|
.setCpuCores(cpuCores).setTotalDiskPar(totalDiskPar).setHostName(hostName)
|
||||||
.setOsVersion(osVersion).setNetwork(netWork).setLocation(location).setIp(ip)
|
.setOsVersion(osVersion).setNetwork(netWork).setLocation(location).setIp(ip)
|
||||||
.setZone(zone).setOsName(osName).setStartTime(startTime).setCpuType(cpuType)
|
.setZone(zone).setOsName(osName).setStartTime(startTime).setCpuType(cpuType)
|
||||||
|
@ -294,7 +295,12 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveOrUpdateHostId(String sourceId, String hostId) {
|
public Result<?> details_AlarmInfo(String sourceId, Integer pageNo, Integer pageSize) {
|
||||||
baseMapper.saveOrUpdateHostId(hostId, sourceId);
|
List<AlarmInfo> alarmInfos = baseMapper.alarmInfo(sourceId);
|
||||||
|
int total = alarmInfos.size();
|
||||||
|
Page<AlarmInfo> page = new Page<>(pageNo, pageSize, total);
|
||||||
|
List<AlarmInfo> records = PageUtil.page(pageNo, pageSize, alarmInfos);
|
||||||
|
page.setRecords(records);
|
||||||
|
return Result.OK(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.jeecg.modules.feignclient;
|
package org.jeecg.modules.feignclient;
|
||||||
|
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
|
|
||||||
import org.jeecg.modules.base.entity.postgre.AlarmLog;
|
import org.jeecg.modules.base.entity.postgre.AlarmLog;
|
||||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
@ -38,7 +37,6 @@ public interface AbnormalAlarmClient {
|
||||||
boolean refreshParam();
|
boolean refreshParam();
|
||||||
|
|
||||||
/* AlarmItemController下相关接口 */
|
/* AlarmItemController下相关接口 */
|
||||||
@GetMapping("/alarmItem/syncItem")
|
@GetMapping("/alarmItem/syncServerItem")
|
||||||
boolean syncItem(@RequestParam String type,
|
boolean syncServerItem();
|
||||||
@RequestParam String code);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package org.jeecg.modules.quartz.job;
|
package org.jeecg.modules.quartz.job;
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
import org.jeecg.common.config.mqtoken.UserTokenContext;
|
||||||
import org.jeecg.common.util.SpringContextUtils;
|
import org.jeecg.common.util.SpringContextUtils;
|
||||||
import org.jeecg.modules.base.enums.SourceType;
|
|
||||||
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
import org.jeecg.modules.feignclient.AbnormalAlarmClient;
|
||||||
import org.quartz.*;
|
import org.quartz.*;
|
||||||
|
|
||||||
|
@ -14,13 +11,9 @@ import static org.jeecg.common.util.TokenUtils.getTempToken;
|
||||||
* 此处的同步是指:当定时任务的执行时间大于任务的时间
|
* 此处的同步是指:当定时任务的执行时间大于任务的时间
|
||||||
* 间隔时会等待第一个任务执行完成才会走第二个任务
|
* 间隔时会等待第一个任务执行完成才会走第二个任务
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* 监控项信息更新保存
|
|
||||||
*/
|
|
||||||
@DisallowConcurrentExecution
|
@DisallowConcurrentExecution
|
||||||
@PersistJobDataAfterExecution
|
@PersistJobDataAfterExecution
|
||||||
public class SyncItemJob implements Job {
|
public class SyncServerItemJob implements Job {
|
||||||
|
|
||||||
private AbnormalAlarmClient alarmClient;
|
private AbnormalAlarmClient alarmClient;
|
||||||
|
|
||||||
|
@ -30,7 +23,7 @@ public class SyncItemJob implements Job {
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
try {
|
try {
|
||||||
init();
|
init();
|
||||||
success = alarmClient.syncItem(SourceType.SERVER.getType(), "172.21.60.231");
|
success = alarmClient.syncServerItem();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
success = false;
|
success = false;
|
Loading…
Reference in New Issue
Block a user