Merge branch 'station' into mdc
This commit is contained in:
commit
b2b778e425
|
@ -1,67 +0,0 @@
|
|||
package org.jeecg.modules;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.jeecg.common.email.EmailServiceManager;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class Demo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Executor executor = Executors.newFixedThreadPool(3);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
CompletableFuture.runAsync(Demo::test2, executor);
|
||||
}
|
||||
}
|
||||
|
||||
public static void test(){
|
||||
SysEmail email1 = new SysEmail();
|
||||
email1.setEmailServerAddress("imap.qiye.163.com");
|
||||
email1.setUsername("cnndc.rn.ng@ndc.org.cn");
|
||||
email1.setPassword("cnndc66367220");
|
||||
email1.setPort(993);
|
||||
|
||||
/*SysEmail email2 = new SysEmail();
|
||||
email2.setEmailServerAddress("imap.qiye.163.com");
|
||||
email2.setUsername("cnndc.rn.ng@ndc.org.cn");
|
||||
email2.setPassword("cnndc66367220");
|
||||
email2.setPort(993);*/
|
||||
|
||||
SysEmail email2 = new SysEmail();
|
||||
email2.setEmailServerAddress("imap.exmail.qq.com");
|
||||
email2.setUsername("xiaoguangbin@hivekion.com");
|
||||
email2.setPassword("Ans9sLY4kVnux7ai");
|
||||
email2.setPort(143);
|
||||
|
||||
List<SysEmail> list = ListUtil.toList(email1, email2);
|
||||
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
Executor executor = Executors.newFixedThreadPool(5);
|
||||
EmailServiceManager manager = EmailServiceManager.getInstance();
|
||||
for (SysEmail email : list) {
|
||||
manager.init(email);
|
||||
CompletableFuture.supplyAsync(manager::canReceive, executor)
|
||||
.thenAccept(status -> FileUtil.writeUtf8Lines(ListUtil.toList(status), "C:\\Users\\a\\Desktop\\"+ email.getUsername() + ".txt"));
|
||||
}
|
||||
/*CompletableFuture<?> allFutures = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
|
||||
try {
|
||||
allFutures.get(); // 等待所有任务完成
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
|
||||
public static void test2(){
|
||||
throw new RuntimeException("测试异常");
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package org.jeecg.modules.aspect;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
@ -44,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jeecg.modules.base.enums.Qiye.IS;
|
||||
|
||||
|
@ -140,11 +142,10 @@ public class StatusAspect {
|
|||
// 更新该服务器的HostId
|
||||
serverService.updateById(server);
|
||||
// 同步服务器监控项
|
||||
Page<Item> itemPage = monitorAlarm.allItems(hostId,
|
||||
MonitorConstant.pageNo, MonitorConstant.pageSize, token).getResult();
|
||||
if (ObjectUtil.isNull(itemPage) || CollUtil.isEmpty(itemPage.getRecords()))
|
||||
Map<String, Item> itemMap = host.getItems();
|
||||
if (MapUtil.isEmpty(itemMap) || CollUtil.isEmpty(itemMap.values()))
|
||||
return;
|
||||
List<Item> items = itemPage.getRecords();
|
||||
Collection<Item> items = itemMap.values();
|
||||
List<AlarmItem> alarmItems = new ArrayList<>();
|
||||
items.forEach(item -> {
|
||||
AlarmItem alarmItem = BeanUtil.copyProperties(item, AlarmItem.class);
|
||||
|
|
|
@ -43,12 +43,6 @@ public interface MonitorAlarm {
|
|||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestHeader("X-Access-Token") String token);
|
||||
|
||||
@GetMapping("/omms/device/monitor/queryAllItems")
|
||||
Result<Page<Item>> allItems(@RequestParam("hostId") String hostId,
|
||||
@RequestParam("pageNo") Integer pageNo,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestHeader("X-Access-Token") String token);
|
||||
|
||||
@GetMapping("/omms/device/monitor/queryHostDetails") // 获取服务器摘要信息
|
||||
Result<Host> summary(@RequestParam("hostId") String hostId,
|
||||
@RequestParam("pageName") String pageName,
|
||||
|
|
|
@ -109,17 +109,19 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
if (ObjectUtil.isNull(host))
|
||||
continue;
|
||||
Map<String, Item> items = host.getItems();
|
||||
// cpu利用率
|
||||
// CPU利用率
|
||||
Item cpuItem = items.getOrDefault(MonitorConstant.ITEM_CPUUSED, new Item());
|
||||
String cpuValue = cpuItem.getLastValue();
|
||||
String cpu = StrUtil.isBlank(cpuValue) ? "--" :
|
||||
NumberUtil.formatPercent(Double.parseDouble(cpuValue), 1);
|
||||
NumUtil.keepStr(cpuValue, 1) + "%";
|
||||
// 内存使用率
|
||||
Item memoryItem = items.getOrDefault(MonitorConstant.ITEM_MEMORYUSED, new Item());
|
||||
String memoryValue = memoryItem.getLastValue();
|
||||
String memory = StrUtil.isBlank(memoryValue) ? "--" :
|
||||
NumUtil.keepStr(memoryValue, 1) + "%";
|
||||
// 磁盘使用率
|
||||
|
||||
|
||||
serverDto.setOnline(true).setCpuUutilzation(cpu)
|
||||
.setMemoryUsage(memory).setDiskUsage("--");
|
||||
}
|
||||
|
@ -309,17 +311,19 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
empty = items.get(MonitorConstant.ITEM_CPUTYPE);
|
||||
String cpuType = ObjectUtil.isNull(empty) ? "--" : empty.getLastValue();
|
||||
|
||||
/* CPU MEMORY LOADS DISK */
|
||||
// CPU利用率
|
||||
empty = items.get(MonitorConstant.ITEM_CPUUSED);
|
||||
String cpuUsed = ObjectUtil.isNull(empty) ? null : empty.getLastValue(); // 0.24
|
||||
Double cpuUsedValue = NumUtil.keep(cpuUsed, 3);
|
||||
cpuUsedValue = ObjectUtil.isNull(cpuUsedValue) ? 0 : cpuUsedValue * 100;
|
||||
String cpuUsed = ObjectUtil.isNull(empty) ? null : empty.getLastValue(); // 23.34
|
||||
Double cpuUsedValue = NumUtil.keep(cpuUsed, 1);
|
||||
cpuUsedValue = ObjectUtil.isNull(cpuUsedValue) ? 0 : cpuUsedValue;
|
||||
|
||||
// 内存利用率
|
||||
empty = items.get(MonitorConstant.ITEM_MEMORYUSED);
|
||||
String memoryUsed = ObjectUtil.isNull(empty) ? null : empty.getLastValue(); // 16.64927
|
||||
Double memoryUsedValue = NumUtil.keep(memoryUsed, 1);
|
||||
memoryUsedValue = ObjectUtil.isNull(memoryUsedValue) ? 0 : memoryUsedValue;
|
||||
|
||||
// 磁盘使用情况
|
||||
Map<String, String> diskUsedMap = items.entrySet().stream() // 6.540206
|
||||
.filter(entry -> entry.getKey().contains(MonitorConstant.PRIFIX_DISKUSED))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, item -> item.getValue().getLastValue()));
|
||||
|
|
Loading…
Reference in New Issue
Block a user