|
@@ -4,9 +4,11 @@ import api.common.pojo.dto.Host;
|
|
import api.common.pojo.po.home.SystemServerPO;
|
|
import api.common.pojo.po.home.SystemServerPO;
|
|
import api.common.util.SshUtil;
|
|
import api.common.util.SshUtil;
|
|
import api.common.util.StringUtil;
|
|
import api.common.util.StringUtil;
|
|
|
|
+import com.css.simulation.resource.monitor.mappper.SystemServerMapper;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import org.apache.sshd.client.SshClient;
|
|
import org.apache.sshd.client.SshClient;
|
|
import org.apache.sshd.client.session.ClientSession;
|
|
import org.apache.sshd.client.session.ClientSession;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -20,6 +22,10 @@ public class MyScheduler {
|
|
|
|
|
|
List<Host> hostList;
|
|
List<Host> hostList;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ SystemServerMapper systemServerManager;
|
|
|
|
+
|
|
|
|
+
|
|
@Scheduled(fixedDelay = 60 * 60 * 1000)
|
|
@Scheduled(fixedDelay = 60 * 60 * 1000)
|
|
public void server() {
|
|
public void server() {
|
|
|
|
|
|
@@ -35,12 +41,11 @@ public class MyScheduler {
|
|
try {
|
|
try {
|
|
SshClient sshClient = SshUtil.getClient();
|
|
SshClient sshClient = SshUtil.getClient();
|
|
ClientSession session = SshUtil.getSession(sshClient, ip, username, password);
|
|
ClientSession session = SshUtil.getSession(sshClient, ip, username, password);
|
|
-// if ("gpu".equals(type)){
|
|
|
|
-// List<GpuDTO> gpuList = SshUtil.gpuInfo(session);
|
|
|
|
-// gpuList.forEach(gpu -> {
|
|
|
|
-// gpu.get
|
|
|
|
-// });
|
|
|
|
-// }
|
|
|
|
|
|
+ int taskNumber = 0;
|
|
|
|
+ if ("gpu".equals(type)) {
|
|
|
|
+ String podList = SshUtil.execute(session, "kubectl get pod | grep project");
|
|
|
|
+ taskNumber = StringUtil.countSubString(podList, "project");
|
|
|
|
+ }
|
|
|
|
|
|
SystemServerPO systemServerPO = SystemServerPO.builder()
|
|
SystemServerPO systemServerPO = SystemServerPO.builder()
|
|
.id(StringUtil.getRandomUUID())
|
|
.id(StringUtil.getRandomUUID())
|
|
@@ -49,16 +54,18 @@ public class MyScheduler {
|
|
.serverType(type)
|
|
.serverType(type)
|
|
.memoryUsage(SshUtil.memoryUsage(session))
|
|
.memoryUsage(SshUtil.memoryUsage(session))
|
|
.memoryAvailable(SshUtil.memoryAvailable(session))
|
|
.memoryAvailable(SshUtil.memoryAvailable(session))
|
|
- .memoryTotal( SshUtil.memoryTotal(session))
|
|
|
|
- .diskUsage( SshUtil.diskUsage(session))
|
|
|
|
|
|
+ .memoryTotal(SshUtil.memoryTotal(session))
|
|
|
|
+ .diskUsage(SshUtil.diskUsage(session))
|
|
.diskAvailable(SshUtil.diskAvailable(session))
|
|
.diskAvailable(SshUtil.diskAvailable(session))
|
|
.diskTotal(SshUtil.diskTotal(session))
|
|
.diskTotal(SshUtil.diskTotal(session))
|
|
.cpuUsage(SshUtil.cpuUsage(session))
|
|
.cpuUsage(SshUtil.cpuUsage(session))
|
|
.cpuTotal(SshUtil.cpuTotal(session))
|
|
.cpuTotal(SshUtil.cpuTotal(session))
|
|
.gpuUsage(SshUtil.gpuUsage(session))
|
|
.gpuUsage(SshUtil.gpuUsage(session))
|
|
.gpuTotal(SshUtil.gpuTotal(session))
|
|
.gpuTotal(SshUtil.gpuTotal(session))
|
|
-// .taskNumber()
|
|
|
|
|
|
+ .taskNumber(taskNumber)
|
|
.build();
|
|
.build();
|
|
|
|
+
|
|
|
|
+ systemServerManager.insert(systemServerPO);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|