LingxinMeng vor 6 Monaten
Ursprung
Commit
465dc90cb7

+ 1 - 1
api-common/src/main/java/api/common/util/SshUtil.java

@@ -77,7 +77,7 @@ public class SshUtil {
      * @throws IOException 异常
      */
     public static String execute(ClientSession session, String command) throws IOException {
-        log.info("SshUtil--execute 通过远程链接执行命令:" + command);
+        log.info("SshUtil--execute 通过远程链接执行命令:{}", command);
         String result;
         ChannelExec execChannel = session.createExecChannel(command);
         // 创建输出流

+ 10 - 5
simulation-resource-monitor/src/main/java/com/css/simulation/resource/monitor/infra/scheduler/ServerScheduler.java

@@ -49,7 +49,7 @@ public class ServerScheduler {
     public void server() {
         try {
             List<SystemServerPO> systemServerPOList = new ArrayList<>();
-            log.info("服务器列表为:" + hostList);
+            log.info("服务器列表为:{}", hostList);
             for (Host host : hostList) {
                 int taskNumber = 0;
                 SshClient sshClient = SshClient.setUpDefaultClient();
@@ -61,7 +61,12 @@ public class ServerScheduler {
                 double gpuUsage = 0.0;
                 long gpuTotal = 0L;
                 if ("gpu".equals(type)) {
-                    gpuUsage = SshUtil.gpuUsage(session);
+                    try {
+                        gpuUsage = SshUtil.gpuUsage(session);
+                    } catch (Exception e) {
+                        log.info("服务器 {} 可能没有安装显卡驱动,报异常:{}", host, e.getMessage());
+                        continue;
+                    }
                     gpuTotal = SshUtil.gpuTotal(session);
                     String podList = SshUtil.execute(session, "kubectl get pod | grep project");
                     taskNumber = StringUtil.countSubString(podList, "project");
@@ -94,7 +99,7 @@ public class ServerScheduler {
                 session.close();
                 sshClient.stop();
             }
-            log.info("获取服务器信息。" + systemServerPOList);
+            log.info("获取服务器信息。{}", systemServerPOList);
             systemServerDomainService.deleteAndInsert(systemServerPOList);
         } catch (IOException | DocumentException | InterruptedException e) {
             throw new RuntimeException(e);
@@ -117,7 +122,7 @@ public class ServerScheduler {
             });
             //3 查询不在id列表中的所有泛化数据
             List<GeneralEntity> generalEntities = scenePackageSublistMapper.selectGeneralDataNotIn(sceneGeneralizationIdList);
-            log.info("准备删除:" + generalEntities);
+            log.info("准备删除:{}", generalEntities);
             generalEntities.forEach(
                     generalEntity -> {
                         if (StringUtil.isNotEmpty(generalEntity.getOsgbAddress())) {
@@ -133,7 +138,7 @@ public class ServerScheduler {
                     }
             );
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage());
             throw new RuntimeException(e);
         }