# 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