#!/bin/bash echo "Usage: this util expects to receive /proc/user_beancounters via command line pipe." # array field constants: param_name=0;held=1; maxheld=2; barrier=3; limit=4; failcnt=5 # a couple handy functions: Return_Val= # Global variable to hold oversize return value of function. kilos () { Return_Val=$(($1 / 1024)) return } megas () { kilos $1 Return_Val=$(($Return_Val / 1024)) return } # read the UBC data: while read myline do \ printf "." case `echo $myline |wc -w` in 6) UBC_param="$(echo $myline |cut -d " " -f 1)" declare -a $UBC_param let $UBC_param[1]="$(echo $myline |cut -d " " -f 2)" let $UBC_param[2]="$(echo $myline |cut -d " " -f 3)" let $UBC_param[3]="$(echo $myline |cut -d " " -f 4)" let $UBC_param[4]="$(echo $myline |cut -d " " -f 5)" let $UBC_param[5]="$(echo $myline |cut -d " " -f 6)" # echo debug: ${UBC_param[0]} ;; 7) UBC_param="$(echo $myline |cut -d " " -f 2)" declare -a $UBC_param veid="$(echo $myline |cut -d " " -f 1)" let $UBC_param[1]="$(echo $myline |cut -d " " -f 3)" let $UBC_param[2]="$(echo $myline |cut -d " " -f 4)" let $UBC_param[3]="$(echo $myline |cut -d " " -f 5)" let $UBC_param[4]="$(echo $myline |cut -d " " -f 6)" let $UBC_param[5]="$(echo $myline |cut -d " " -f 7)" ;; 2) UBCversion="$(echo $myline |cut -d " " -f 2)" ;; esac # echo "debug :: $UBC_param : ${UBC_param[0]} : ${UBC_param[1]} :" done #declare -a printf "\r" # Output whatever interests you: echo 'Processing UBC version '$UBCversion' for VEID: '$veid printf "%4d MB Allocation Guarantee [vmguarpages barrier]\n" $((${vmguarpages[$barrier]} / 256)) printf "%4d MB Memory Guarantee [oomguarpages barrier]\n" $((${oomguarpages[$barrier]} / 256)) printf "%4d MB page memory allocated [privvmpages held]\n" $((${privvmpages[$held]} / 256)) printf "%4d MB page memory used [physpages held]\n" $((${physpages[$held]} / 256)) printf "%4d MB memory + swap used [oomguarpages held]\n" $((${oomguarpages[$held]} / 256)) megas ${kmemsize[$held]} printf "%4d MB kernel memory used [kmemsize held]" $Return_Val kilos ${kmemsize[$held]} printf "(%6d KB)\n" $Return_Val bufmem=$((${tcpsndbuf[$held]} + ${tcprcvbuf[$held]} + ${othersockbuf[$held]} + ${dgramrcvbuf[$held]})) megas $bufmem printf "%4d MB buffer memory used [*buf held]" $Return_Val kilos $bufmem printf "(%6d KB)\n" $Return_Val echo '-----------------------------------------------' echo 'Used : Max_Used : Limit for Other Resources' echo "debug:vmguarpages barrier:${vmguarpages[$barrier]}" echo "debug:numproc held: ${numproc[1]}" # declare -a for eachone in numproc avnumproc numtcpsock numothersock numfile numflock numpty numsiginfo do \ each=$eachone echo each: $each .... ${$each[*]} # printf "%6d : %6d : %6d %s\n" ${!each[$held]} ${!each[$maxheld]} ${!each[$barrier]} ${!each[$limit]} ${!each[0]} done exit 0