#!/bin/bash # get size of java process CPU% 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) cpuAll=0.0 count=0 for PID in ${arr[@]} do cpu=`pidstat -p $PID -u 3 1 | awk 'NR==4{print $7}'` cpuAll=$(awk 'BEGIN{print('$cpuAll'+'$cpu')}') done echo ${cpuAll} fi