【12】进程监控脚本-getMemPer.sh

# get size of java process mem%

PName=$1
#echo $PName

    if [ "$PName" != "" ];then   
       a=`ps aux | grep $PName | grep -v grep | grep -v zabbix |awk '{print $2}'` 
       #echo $a
       arr=($a)
       memAll=0
       count=0
       for PID in ${arr[@]}
       do          
          mem=`pidstat -r -p $PID 3 1 | awk 'NR==4{print $8}'`
          memAll=$(awk 'BEGIN{print('$memAll'+'$mem')}')
       done
       echo ${memAll}
   fi 

 

posted on 2018-10-19 14:33  长林夕雨  阅读(160)  评论(0编辑  收藏  举报