From ec37ba83573aa15d5c20864993c96845d9655dfb Mon Sep 17 00:00:00 2001 From: "Qin, Bo" Date: Tue, 22 Apr 2014 17:05:14 +0800 Subject: [PATCH] use percentage in swap modified: get_max_mem_process.sh Signed-off-by: Qin, Bo --- install_shell/get_max_mem_process.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install_shell/get_max_mem_process.sh b/install_shell/get_max_mem_process.sh index 439caf3..588a44c 100755 --- a/install_shell/get_max_mem_process.sh +++ b/install_shell/get_max_mem_process.sh @@ -1,9 +1,9 @@ #!/bin/bash -swap=$(free -g|grep "^Swap:"|awk '{print $3}') +swap_percentage=$( free | grep '^Swap:' | awk '{ if ($2 != 0) {print ($3/$2*100)} else {print 0} }') thread_num=$( top -b -H -n 1|grep "^Tasks:"|awk '{print $2}') -# swap >= 3G or thread_num >= 1800 -if [ ${swap} -ge 3 -o ${thread_num} -ge 1800 ];then +# swap >= 10% or thread_num >= 1800 +if [ $(echo ${swap_percentage} '>' 10 |bc ) -eq 1 -o ${thread_num} -ge 1800 ];then date>>/var/log/messages echo "rss(KB) pmem%M pcpu%C vsize(SWAP+RES,KB) process ">>/var/log/messages ps -eo rss,pmem,pcpu,vsize,args | sort -k 1 -r -n|head -10>>/var/log/messages