From 648ffac146396860a8cb18594e0486d605574f52 Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Wed, 2 Jul 2014 14:19:08 -0500 Subject: [PATCH] Omaha #3245 caveUtil.sh handle memory overide in vm args Change-Id: I7525cd9d62acbc3a6ac44913c7c856ae5b6760fc Former-commit-id: 013292ce9d384b03868dd692497efac1bf58b55b [formerly 26ee019a0cf71f31732ce0983fd6c0fe28e63d6c] Former-commit-id: 2773cf89355c476e778db66934f86a9c88d369f9 --- cave/build/static/linux/cave/caveUtil.sh | 31 ++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/cave/build/static/linux/cave/caveUtil.sh b/cave/build/static/linux/cave/caveUtil.sh index f7955d7302..bc60e1e04e 100644 --- a/cave/build/static/linux/cave/caveUtil.sh +++ b/cave/build/static/linux/cave/caveUtil.sh @@ -33,6 +33,7 @@ # # Mar 13 2014 #15348 kjohnson added function to remove logs # Jun 20, 2014 #3245 bclement forEachRunningCave now accounts for child processes +# Jul 02, 2014 #3245 bclement account for memory override in vm arguments source /awips2/cave/iniLookup.sh @@ -145,11 +146,11 @@ function forEachRunningCave() if [[ -z $children ]] then # no children, assume that this is a main cave process - "$@" $(ps --no-header -fp $parent) + "$@" "$(ps --no-header -fp $parent)" else for child in $children do - "$@" $(ps --no-header -fp $child) + "$@" "$(ps --no-header -fp $child)" done fi done @@ -186,6 +187,14 @@ function readMemFromIni() break fi done < "$inifile" + convertMemToBytes $mem $unit +} + +# takes in integer amount and string units (K|M|G), echos the amount converted to bytes +function convertMemToBytes() +{ + local mem=$1 + local unit=$2 # convert to bytes case "$unit" in [kK]) @@ -213,14 +222,22 @@ function addMemOfCave() { local inifile # get ini file from process string - local regex='--launcher.ini\s(.+\.ini)' - if [[ $1 =~ $regex ]] + local iniRegex='--launcher.ini\s(.+\.ini)' + local xmxRegex='-Xmx([0-9]*)([^\s]*)' + if [[ $1 =~ $xmxRegex ]] then - inifile="${BASH_REMATCH[1]}" + local mem="${BASH_REMATCH[1]}" + local unit="${BASH_REMATCH[2]}" + let "_totalRunningMem+=$(convertMemToBytes $mem $unit)" else - inifile="/awips2/cave/cave.ini" + if [[ $1 =~ $iniRegex ]] + then + inifile="${BASH_REMATCH[1]}" + else + inifile="/awips2/cave/cave.ini" + fi + let "_totalRunningMem+=$(readMemFromIni "$inifile")" fi - let "_totalRunningMem+=$(readMemFromIni "$inifile")" } # finds total max memory of running caves in bytes and places it in _totalRunningMem