#!/bin/bash
#
# Get the virtual address space size for the main JVM.
#
#
# Change Activity:
#   02/11/2008 P. Callaghan - initial version
#
# Parameters:
#   None.
#
# Exit status codes:
#   0: the size was successfully written to stdout.
#

EXIT_STATUS=1

PSLine=$(ps -Aww -o vsize,args| grep 'com.ibm.hwmca.fw.startup.UnifiedStartup' | grep -v grep)
if [[ -n ${PSLine} ]] ; then
    kiloBytes=$(echo ${PSLine} | cut -d' ' -f1)
    #echo ${kiloBytes}
    if [[ -n ${kiloBytes} ]] ; then
        #bytes=$(echo ${kiloBytes}*1024 | bc -l)
        bytes=$(expr ${kiloBytes} \* 1024)
        #Eventually use the /proc filesystem to get the exact bytes
        if [[ -n ${bytes} ]] ; then
            echo ${bytes}
            EXIT_STATUS=0
        else
           echo 'bytes is empty' 1>&2
        fi
    else
       echo 'kiloBytes is empty' 1>&2
    fi
else
   echo 'The JVM was not found' 1>&2
fi

exit $EXIT_STATUS


