use percentage in swap
modified: get_max_mem_process.sh Signed-off-by: Qin, Bo <bqin@linx-info.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user