From 73c6fd18ed97c8265070c0abff7e3013226523dd Mon Sep 17 00:00:00 2001 From: whyour Date: Thu, 3 Nov 2022 13:42:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/otask.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/otask.sh b/shell/otask.sh index 4fd2be71..54864fbb 100644 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -84,7 +84,7 @@ check_server() { disk_use=$(df -P | grep /dev | grep -v -E '(tmp|boot|shm)' | awk '{print $5}' | cut -f 1 -d "%" | head -n 1) if [[ $cpu_use -gt $cpu_warn ]] || [[ $mem_free -lt $mem_warn ]] || [[ $disk_use -gt $disk_warn ]]; then - local resource=$(top -b -n 1 | grep -v -E 'grep|Mem|idle|Load' | awk '{$2="";$3="";$4="";$5="";$7="";print $0}' | head -n 10) + local resource=$(top -b -n 1 | grep -v -E 'grep|Mem|idle|Load|tr' | awk '{$2="";$3="";$4="";$5="";$7="";print $0}' | head -n 10 | tr '\n' '|' | sed s/\|/\\\\n/g) notify_api "服务器资源异常警告" "当前CPU占用 $cpu_use% 内存占用 $mem_use% 磁盘占用 $disk_use% \n资源占用详情 \n\n $resource" fi }