From c6624e9001f9f000b74d02762321a868e8a940cc Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 29 Sep 2022 00:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B5=84=E6=BA=90=E5=8D=A0?= =?UTF-8?q?=E7=94=A8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/task.sh | 17 +++++++++-------- src/pages/setting/checkUpdate.tsx | 6 ++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/shell/task.sh b/shell/task.sh index 02e9492b..a5dec65b 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -119,24 +119,25 @@ handle_log_path() { } check_server() { - cpu_idle=$(top -b -n 1 | grep Cpu | awk '{print $8}' | cut -f 1 -d "%") - eval echo -e "当前CPU占用 $cpu_use " $cmd + cpu_use=$(top -b -n 1 | grep Cpu | awk '{print $8}' | cut -f 1 -d "%") + + mem_free=$(free -m | grep "Mem" | awk '{print $3}') + mem_total=$(free -m | grep "Mem" | awk '{print $2}') + mem_use=$(printf "%d%%" $((mem_free * 100 / mem_total)) | cut -f 1 -d "%") + + disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%") + + eval echo "当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use% \\\n" $cmd if [[ $cpu_use -gt $cpu_warn ]]; then notify_api "CPU异常警告" "当前CPU占用 $cpu_use%" exit 1 fi - mem_free=$(free -m | grep "Mem" | awk '{print $3}') - mem_total=$(free -m | grep "Mem" | awk '{print $2}') - mem_use=$(printf "%d%%" $((mem_free * 100 / mem_total)) | cut -f 1 -d "%") - eval echo -e "内存剩余 $mem_use% " $cmd if [[ $mem_free -lt $mem_warn ]]; then notify_api "内存异常警告" "当前内存占用 $mem_use%" exit 1 fi - disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%") - eval echo -e "磁盘占用 $disk_use% \\\n" $cmd if [[ $disk_use -gt $disk_warn ]]; then notify_api "磁盘异常警告" "当前磁盘占用 $disk_use%" exit 1 diff --git a/src/pages/setting/checkUpdate.tsx b/src/pages/setting/checkUpdate.tsx index b166ac79..73c93a95 100644 --- a/src/pages/setting/checkUpdate.tsx +++ b/src/pages/setting/checkUpdate.tsx @@ -102,6 +102,7 @@ const CheckUpdate = ({ socketMessage }: any) => { }; const showUpdatingModal = () => { + setValue(''); modalRef.current = Modal.info({ width: 600, maskClosable: false, @@ -159,12 +160,13 @@ const CheckUpdate = ({ socketMessage }: any) => { ), }); - setValue(newMessage); - if (updateFailed) { + if (updateFailed && !value.includes('失败,请检查')) { message.error('更新失败,请检查网络及日志或稍后再试'); } + setValue(newMessage); + document.getElementById('log-identifier') && document .getElementById('log-identifier')!