From 1379150369ee9423d805ad4ce7913bfd090bfc02 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Tue, 7 May 2024 11:35:08 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++--- docs/README.md | 12 ++--- docs/about/change-log.md | 1 + .../src/main/resources/application.yaml | 2 +- .../asset/define/config/AppExecLogConfig.java | 2 +- .../handler/ExecCommandAnsiHandler.java | 50 +++++++++---------- .../impl/HostConnectLogServiceImpl.java | 4 +- .../spring-configuration-metadata.json | 2 +- pull.sh | 5 ++ 9 files changed, 48 insertions(+), 42 deletions(-) create mode 100644 pull.sh diff --git a/README.md b/README.md index a66c302c..b11d1f44 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ **github:** https://github.com/lijiahangmax/orion-ops-pro **gitee:** https://gitee.com/lijiahangmax/orion-ops-pro -**文档:** https://lijiahangmax.gitee.io/orion-ops-pro/#/ +**文档:** https://lijiahangmax.github.io/orion-ops-pro/#/ **demo:** http://101.43.254.243:1081/ 演示账号: `admin` @@ -53,11 +53,11 @@ ## 快速开始 -* [docker安装](https://lijiahangmax.gitee.io/orion-ops-pro/#/quickstart/docker-install) -* [普通安装](https://lijiahangmax.gitee.io/orion-ops-pro/#/quickstart/install) -* [更新日志](https://lijiahangmax.gitee.io/orion-ops-pro/#/about/change-log) -* [操作手册](https://lijiahangmax.gitee.io/orion-ops-pro/#/operator/asset) -* [常见问题](https://lijiahangmax.gitee.io/orion-ops-pro/#/quickstart/faq) +* [docker安装](https://lijiahangmax.github.io/orion-ops-pro/#/quickstart/docker-install) +* [普通安装](https://lijiahangmax.github.io/orion-ops-pro/#/quickstart/install) +* [更新日志](https://lijiahangmax.github.io/orion-ops-pro/#/about/change-log) +* [操作手册](https://lijiahangmax.github.io/orion-ops-pro/#/operator/asset) +* [常见问题](https://lijiahangmax.github.io/orion-ops-pro/#/quickstart/faq) ## 技术栈 diff --git a/docs/README.md b/docs/README.md index bd037eaf..c3193eda 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,7 +30,7 @@ **github:** https://github.com/lijiahangmax/orion-ops-pro **gitee:** https://gitee.com/lijiahangmax/orion-ops-pro -**文档:** https://lijiahangmax.gitee.io/orion-ops-pro/#/ +**文档:** https://lijiahangmax.github.io/orion-ops-pro/#/ **demo:** http://101.43.254.243:1081/ 演示账号: `admin` @@ -53,11 +53,11 @@ ## 快速开始 -* [docker安装](https://lijiahangmax.gitee.io/orion-ops-pro/#/quickstart/docker-install) -* [普通安装](https://lijiahangmax.gitee.io/orion-ops-pro/#/quickstart/install) -* [更新日志](https://lijiahangmax.gitee.io/orion-ops-pro/#/about/change-log) -* [操作手册](https://lijiahangmax.gitee.io/orion-ops-pro/#/operator/asset) -* [常见问题](https://lijiahangmax.gitee.io/orion-ops-pro/#/quickstart/faq) +* [docker安装](/quickstart/docker-install) +* [普通安装](/quickstart/install) +* [更新日志](/about/change-log) +* [操作手册](/operator/asset) +* [常见问题](/quickstart/faq) ## 技术栈 diff --git a/docs/about/change-log.md b/docs/about/change-log.md index cf2f3655..5e71518e 100644 --- a/docs/about/change-log.md +++ b/docs/about/change-log.md @@ -14,6 +14,7 @@ * 🐞 修复 查看计划任务日志时提示日志不存在 * 🩰 修改 命令执行日志 UI 修改 * 🌈 新增 文件传输列表添加操作栏 +* 🌈 新增 主机在线会话 * 🔨 优化 [如何升级](/update/v1.0.7.md) diff --git a/orion-ops-launch/src/main/resources/application.yaml b/orion-ops-launch/src/main/resources/application.yaml index 6a09d409..f2e67afe 100644 --- a/orion-ops-launch/src/main/resources/application.yaml +++ b/orion-ops-launch/src/main/resources/application.yaml @@ -184,7 +184,7 @@ app: # 自动清理执行文件 auto-clear: true # 保留周期 (天) - keep-period: 60 + keep-period: 30 # orion framework config orion: diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/config/AppExecLogConfig.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/config/AppExecLogConfig.java index 3f6ca69e..abd5231f 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/config/AppExecLogConfig.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/define/config/AppExecLogConfig.java @@ -34,7 +34,7 @@ public class AppExecLogConfig { public AppExecLogConfig() { this.appendAnsi = true; this.autoClear = true; - this.keepPeriod = 60; + this.keepPeriod = 30; } } diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java index 620399b0..42f1fd2e 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/handler/host/exec/command/handler/ExecCommandAnsiHandler.java @@ -31,16 +31,16 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler { super.initLogOutputStream(); // 拼接启动日志 AnsiAppender appender = AnsiAppender.create() - .append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "> 准备执行命令 ") + .append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "> 准备执行命令 ") .append(Dates.current()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "执行记录: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "执行记录: ") .append(execCommand.getLogId()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "执行描述: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "执行描述: ") .append(execCommand.getDescription()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "执行用户: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "执行用户: ") .append(execCommand.getUsername()); // 非系统用户执行添加 userId if (Const.SYSTEM_USER_ID.equals(execCommand.getUserId())) { @@ -53,35 +53,35 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler { } // 执行序列 if (execCommand.getExecSeq() != null) { - appender.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "执行序列: ") + appender.append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "执行序列: ") .append('#') .append(execCommand.getExecSeq()) .newLine(); } - appender.append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "执行主机: ") + appender.append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "执行主机: ") .append(execHostCommand.getHostName()) .append(" (") .append(execHostCommand.getHostId()) .append(")") .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "主机地址: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "主机地址: ") .append(execHostCommand.getHostAddress()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "超时时间: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "超时时间: ") .append(execCommand.getTimeout()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "脚本执行: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "脚本执行: ") .append(execCommand.getScriptExec()) .newLine() .newLine() - .append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "> 执行命令 ") + .append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "> 执行命令 ") .newLine() .append(execHostCommand.getCommand()) .newLine() .newLine(); // 非脚本执行拼接开始执行日志 if (!Booleans.isTrue(execCommand.getScriptExec())) { - appender.append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "> 开始执行命令 ") + appender.append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "> 开始执行命令 ") .append(Dates.current()) .newLine(); } @@ -94,10 +94,10 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler { // 拼接上传日志 AnsiAppender startAppender = AnsiAppender.create() .newLine() - .append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "> 准备上传脚本 ") + .append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "> 准备上传脚本 ") .append(Dates.current()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "文件路径: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "文件路径: ") .append(execHostCommand.getScriptPath()) .newLine(); this.appendLog(startAppender); @@ -105,18 +105,18 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler { super.uploadScriptFile(); // 拼接完成日志 AnsiAppender finishAppender = AnsiAppender.create() - .append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "< 脚本上传成功 ") + .append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "< 脚本上传成功 ") .append(Dates.current()) .newLine() .newLine() - .append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "> 开始执行脚本 ") + .append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "> 开始执行脚本 ") .append(Dates.current()) .newLine(); this.appendLog(finishAppender); } catch (Exception e) { // 拼接失败日志 AnsiAppender errorAppender = AnsiAppender.create() - .append(AnsiForeground.BRIGHT_RED.and(AnsiFont.BOLD), "< 脚本上传失败 ") + .append(AnsiForeground.RED.and(AnsiFont.BOLD), "< 脚本上传失败 ") .append(Dates.current()) .newLine(); this.appendLog(errorAppender); @@ -133,37 +133,37 @@ public class ExecCommandAnsiHandler extends BaseExecCommandHandler { .newLine(); if (this.status == ExecHostStatusEnum.INTERRUPTED) { // 中断执行 - appender.append(AnsiForeground.BRIGHT_YELLOW.and(AnsiFont.BOLD), "< 命令执行中断 ") + appender.append(AnsiForeground.YELLOW.and(AnsiFont.BOLD), "< 命令执行中断 ") .append(Dates.current()) .newLine(); } else if (this.status == ExecHostStatusEnum.FAILED) { // 执行失败 - appender.append(AnsiForeground.BRIGHT_RED.and(AnsiFont.BOLD), "< 命令执行失败 ") + appender.append(AnsiForeground.RED.and(AnsiFont.BOLD), "< 命令执行失败 ") .append(Dates.current()) .newLine() - .append(AnsiForeground.BRIGHT_RED.and(AnsiFont.BOLD), "错误原因: ") + .append(AnsiForeground.RED.and(AnsiFont.BOLD), "错误原因: ") .append(this.getErrorMessage(e)) .newLine(); } else if (this.status == ExecHostStatusEnum.TIMEOUT) { // 更新执行超时 - appender.append(AnsiForeground.BRIGHT_YELLOW.and(AnsiFont.BOLD), "< 命令执行超时 ") + appender.append(AnsiForeground.YELLOW.and(AnsiFont.BOLD), "< 命令执行超时 ") .append(Dates.current()) .newLine(); } else { long ms = this.updateRecord.getFinishTime().getTime() - this.updateRecord.getStartTime().getTime(); Integer exitStatus = this.updateRecord.getExitStatus(); // 执行完成 - appender.append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), "< 命令执行完成 ") + appender.append(AnsiForeground.GREEN.and(AnsiFont.BOLD), "< 命令执行完成 ") .append(Dates.current()) .newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "exit: "); + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "exit: "); if (ExitCode.isSuccess(exitStatus)) { - appender.append(AnsiForeground.BRIGHT_GREEN.and(AnsiFont.BOLD), exitStatus); + appender.append(AnsiForeground.GREEN.and(AnsiFont.BOLD), exitStatus); } else { - appender.append(AnsiForeground.BRIGHT_RED.and(AnsiFont.BOLD), exitStatus); + appender.append(AnsiForeground.RED.and(AnsiFont.BOLD), exitStatus); } appender.newLine() - .append(AnsiForeground.BRIGHT_BLUE.and(AnsiFont.BOLD), "used: ") + .append(AnsiForeground.BLUE.and(AnsiFont.BOLD), "used: ") .append(Dates.interval(ms, false, "d ", "h ", "m ", "s")) .append(" (") .append(ms) diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostConnectLogServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostConnectLogServiceImpl.java index e6c063fd..e0a85552 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostConnectLogServiceImpl.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/HostConnectLogServiceImpl.java @@ -113,7 +113,7 @@ public class HostConnectLogServiceImpl implements HostConnectLogService { @Override public Integer updateStatusById(Long id, HostConnectStatusEnum status, Map partial) { - log.info("HostConnectLogService-updateStatusByToken start id: {}, status: {}", id, status); + log.info("HostConnectLogService-updateStatusById start id: {}, status: {}", id, status); // 查询 HostConnectLogDO record = hostConnectLogDAO.of() .createWrapper() @@ -122,7 +122,7 @@ public class HostConnectLogServiceImpl implements HostConnectLogService { .then() .getOne(); if (record == null) { - log.info("HostConnectLogService-updateStatusByToken no record id: {}", id); + log.info("HostConnectLogService-updateStatusById no record id: {}", id); return Const.N_0; } return this.updateStatus(record, status, partial); diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/META-INF/spring-configuration-metadata.json b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/META-INF/spring-configuration-metadata.json index 210f2c39..d57010f6 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/META-INF/spring-configuration-metadata.json +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/resources/META-INF/spring-configuration-metadata.json @@ -63,7 +63,7 @@ "name": "app.exec-log.keep-period", "type": "java.lang.Integer", "description": "保留周期 (天)", - "defaultValue": "60" + "defaultValue": "30" } ] } \ No newline at end of file diff --git a/pull.sh b/pull.sh new file mode 100644 index 00000000..457127c2 --- /dev/null +++ b/pull.sh @@ -0,0 +1,5 @@ +#/bin/bash +git clean -df +git reset --hard HEAD +git pull +git log -n 1