|
|
@@ -12,6 +12,7 @@ import cn.reghao.devops.mgr.mgr.machine.model.po.NetworkInfo;
|
|
|
import cn.reghao.devops.mgr.mgr.machine.model.po.SshAuth;
|
|
|
import cn.reghao.devops.mgr.mgr.machine.model.vo.MachineHostVO;
|
|
|
import cn.reghao.devops.mgr.mgr.machine.model.vo.MachineSshAuth;
|
|
|
+import cn.reghao.devops.mgr.mgr.machine.model.vo.MachineStat;
|
|
|
import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
@@ -51,20 +52,37 @@ public class MachineQueryImpl implements MachineQuery {
|
|
|
MachineInfo machineInfo = machineHost.getMachineInfo();
|
|
|
long bootTime = machineInfo.getBootTime();
|
|
|
String bootTimeStr = DateTimeConverter.format(bootTime*1000);
|
|
|
- String status = NodeStatus.Online.name();
|
|
|
- int stat = machineInfo.getStat();
|
|
|
- if (stat == NodeStatus.Offline.getCode()) {
|
|
|
- status = NodeStatus.Offline.name();
|
|
|
- } else if (stat == NodeStatus.Timeout.getCode()) {
|
|
|
- status = NodeStatus.Timeout.name();
|
|
|
- } else if (stat == NodeStatus.Deprecated.getCode()) {
|
|
|
- status = NodeStatus.Deprecated.name();
|
|
|
- }
|
|
|
-
|
|
|
+ String status = getMachineStat(machineInfo);
|
|
|
return new MachineHostVO(machineHost, bootTimeStr, status, used);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public void getMachineStats() {
|
|
|
+ List<MachineStat> list = machineHostRepository.findAll().stream().map(machineHost -> {
|
|
|
+ String machineId = machineHost.getMachineId();
|
|
|
+ String machineIpv4 = machineHost.getMachineIpv4();
|
|
|
+ String env = machineHost.getEnv();
|
|
|
+
|
|
|
+ MachineInfo machineInfo = machineHost.getMachineInfo();
|
|
|
+ String status = getMachineStat(machineInfo);
|
|
|
+ return new MachineStat(machineId, machineIpv4, env, status);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getMachineStat(MachineInfo machineInfo) {
|
|
|
+ String status = NodeStatus.Online.name();
|
|
|
+ int stat = machineInfo.getStat();
|
|
|
+ if (stat == NodeStatus.Offline.getCode()) {
|
|
|
+ status = NodeStatus.Offline.name();
|
|
|
+ } else if (stat == NodeStatus.Timeout.getCode()) {
|
|
|
+ status = NodeStatus.Timeout.name();
|
|
|
+ } else if (stat == NodeStatus.Deprecated.getCode()) {
|
|
|
+ status = NodeStatus.Deprecated.name();
|
|
|
+ }
|
|
|
+
|
|
|
+ return status;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public MachineHost getMachineHost(String machineId) {
|
|
|
return machineHostRepository.findByMachineId(machineId);
|