Omaha #3245 altered utility scripts to account for cave subprocess
Change-Id: I085432b0aab9224bc0a9ffdf2d6c58301dd94dcd Former-commit-id:3b71bedd14
[formerly0f25ac3b5b
[formerly aceeff1e02c896ff27794755eb10fc275718a68c]] Former-commit-id:0f25ac3b5b
Former-commit-id:27a0d3fb28
This commit is contained in:
parent
37d6f292f1
commit
bb9ea8688b
2 changed files with 65 additions and 18 deletions
|
@ -32,6 +32,7 @@
|
||||||
# Feb 20, 2014 #2780 bclement added site type ini file check
|
# Feb 20, 2014 #2780 bclement added site type ini file check
|
||||||
#
|
#
|
||||||
# Mar 13 2014 #15348 kjohnson added function to remove logs
|
# Mar 13 2014 #15348 kjohnson added function to remove logs
|
||||||
|
# Jun 20, 2014 #3245 bclement forEachRunningCave now accounts for child processes
|
||||||
|
|
||||||
|
|
||||||
source /awips2/cave/iniLookup.sh
|
source /awips2/cave/iniLookup.sh
|
||||||
|
@ -135,17 +136,23 @@ function copyVizShutdownUtilIfNecessary()
|
||||||
function forEachRunningCave()
|
function forEachRunningCave()
|
||||||
{
|
{
|
||||||
local user=`whoami`
|
local user=`whoami`
|
||||||
local caveProcs=`ps -ef | grep -E "(/awips2/cave|/usr/local/viz)/cave " | grep -v "grep" | grep $user`
|
|
||||||
|
|
||||||
# preserve IFS and set it to line feed only
|
for parent in $(pgrep -u $user '^cave$')
|
||||||
local PREV_IFS=$IFS
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
for caveProc in $caveProcs
|
|
||||||
do
|
do
|
||||||
"$@" $caveProc
|
# the cave process starts a new JVM as a child process
|
||||||
|
# find all children of the cave process
|
||||||
|
children=$(pgrep -P $parent)
|
||||||
|
if [[ -z $children ]]
|
||||||
|
then
|
||||||
|
# no children, assume that this is a main cave process
|
||||||
|
"$@" $(ps --no-header -fp $parent)
|
||||||
|
else
|
||||||
|
for child in $children
|
||||||
|
do
|
||||||
|
"$@" $(ps --no-header -fp $child)
|
||||||
|
done
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
IFS=$PREV_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# takes in ps string of cave process, stores pid in _pids and increments _numPids
|
# takes in ps string of cave process, stores pid in _pids and increments _numPids
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
# base path to save capture data to, will create subdirectory for each workstation
|
# base path to save capture data to, will create subdirectory for each workstation
|
||||||
basePath="/data/fxa/cave"
|
basePath="/data/fxa/cave"
|
||||||
|
|
||||||
# the grep string to find the cave processes
|
|
||||||
grepString="(/awips2/cave/cave|/usr/local/viz/cave)"
|
|
||||||
|
|
||||||
edexGrepString="edex.run.mode="
|
edexGrepString="edex.run.mode="
|
||||||
|
|
||||||
xorgLogPath="/var/log"
|
xorgLogPath="/var/log"
|
||||||
|
@ -59,9 +56,6 @@ usage() {
|
||||||
echo -e "-f {y/n}\t\tdefault [$FORCE]"
|
echo -e "-f {y/n}\t\tdefault [$FORCE]"
|
||||||
echo " Force a jstack/jmap by default"
|
echo " Force a jstack/jmap by default"
|
||||||
echo
|
echo
|
||||||
echo -e "-g {grep string}\tdefault [$grepString]"
|
|
||||||
echo " The grep string used to find the processes"
|
|
||||||
echo
|
|
||||||
echo -e "-l {y/n}\t\tdefault [$GRAB_CAVE_AND_ALERTVIZ_LOGS]"
|
echo -e "-l {y/n}\t\tdefault [$GRAB_CAVE_AND_ALERTVIZ_LOGS]"
|
||||||
echo " Captures the cave and alertviz logs. If run for a specific pid the only cave log captured will be for that pid"
|
echo " Captures the cave and alertviz logs. If run for a specific pid the only cave log captured will be for that pid"
|
||||||
echo
|
echo
|
||||||
|
@ -420,6 +414,35 @@ runVersions() {
|
||||||
$cmd >> ${dataPath}/versions.log 2>&1
|
$cmd >> ${dataPath}/versions.log 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# take in pid, output process name without args
|
||||||
|
getCommandName() {
|
||||||
|
ps --no-header c -p $1 -o cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
# take in pid, output parent process id
|
||||||
|
getParentPid() {
|
||||||
|
ps --no-header -p $1 -o ppid
|
||||||
|
}
|
||||||
|
|
||||||
|
# take in pid, output associated cave executable pid if found, otherwise output given pid
|
||||||
|
determineCaveProcess() {
|
||||||
|
local RVAL=$1
|
||||||
|
# check if supplied PID is for the cave executable
|
||||||
|
local CMD_NAME=$(getCommandName $1)
|
||||||
|
if [[ ! $CMD_NAME =~ cave ]]
|
||||||
|
then
|
||||||
|
# worker pid probably provided, check parent
|
||||||
|
RVAL=$(getParentPid $1)
|
||||||
|
if [[ ! $(getCommandName $RVAL) =~ cave ]]
|
||||||
|
then
|
||||||
|
# parent wasn't cave either... continue on using PID provided
|
||||||
|
echo "${t1}: Unable to find cave process for pid $1, proceeding with provided PID" >> $processFile
|
||||||
|
RVAL=$1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo $RVAL
|
||||||
|
}
|
||||||
|
|
||||||
# parse command line
|
# parse command line
|
||||||
while [ ! -z "$1" ]; do
|
while [ ! -z "$1" ]; do
|
||||||
arg=$1
|
arg=$1
|
||||||
|
@ -430,7 +453,6 @@ while [ ! -z "$1" ]; do
|
||||||
-d) RUN_JMAP="$1"; shift 1;;
|
-d) RUN_JMAP="$1"; shift 1;;
|
||||||
-e) EDEX_MODE="Y"; edexProcs[$edexProcCount]="$1"; shift 1; let "edexProcCount+=1";;
|
-e) EDEX_MODE="Y"; edexProcs[$edexProcCount]="$1"; shift 1; let "edexProcCount+=1";;
|
||||||
-f) FORCE="$1"; shift 1;;
|
-f) FORCE="$1"; shift 1;;
|
||||||
-g) grepString="$1"; shift 1;;
|
|
||||||
-l) GRAB_CAVE_AND_ALERTVIZ_LOGS="$1"; shift 1;;
|
-l) GRAB_CAVE_AND_ALERTVIZ_LOGS="$1"; shift 1;;
|
||||||
-m) MOVE_ALL_HS_ERR_PID="$1"; shift 1;;
|
-m) MOVE_ALL_HS_ERR_PID="$1"; shift 1;;
|
||||||
-p) cavePid="$1"; shift 1;;
|
-p) cavePid="$1"; shift 1;;
|
||||||
|
@ -537,9 +559,26 @@ if [ "$EDEX_MODE" == "y" ]; then
|
||||||
done
|
done
|
||||||
|
|
||||||
grepString="${grepString}) "
|
grepString="${grepString}) "
|
||||||
|
procs=`ps -ef | grep -E "$grepString" | grep -v "grep"`
|
||||||
|
else
|
||||||
|
#list of cave process ids to get ps output for
|
||||||
|
caveProcNums=""
|
||||||
|
for parent in $(pgrep '^cave$')
|
||||||
|
do
|
||||||
|
# the cave process starts a new JVM as a child process
|
||||||
|
# find all children of the cave process
|
||||||
|
children=$(pgrep -P $parent)
|
||||||
|
if [[ -z $children ]]
|
||||||
|
then
|
||||||
|
# no children, assume that this is a main cave process
|
||||||
|
caveProcNums="$caveProcNums $parent"
|
||||||
|
else
|
||||||
|
# otherwise, only get ps output for children
|
||||||
|
caveProcNums="$caveProcNums $children"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
procs=$(ps --no-header -fp $caveProcNums)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
procs=`ps -ef | grep -E "$grepString" | grep -v "grep" | grep -v "cave.sh"`
|
|
||||||
|
|
||||||
if [ ! -z "$cavePid" ]; then
|
if [ ! -z "$cavePid" ]; then
|
||||||
# limit cave procs to the requested PID
|
# limit cave procs to the requested PID
|
||||||
|
@ -670,7 +709,8 @@ if [ "${GRAB_CAVE_AND_ALERTVIZ_LOGS}" == "y" ]; then
|
||||||
echo "${t1}: Capturing cave logs" >> $processFile
|
echo "${t1}: Capturing cave logs" >> $processFile
|
||||||
mkdir -p ${dataPath}/consoleLogs
|
mkdir -p ${dataPath}/consoleLogs
|
||||||
if [ ! -z ${cavePid} ]; then
|
if [ ! -z ${cavePid} ]; then
|
||||||
find $dir -type f -name "*${cavePid}*" -exec cp {} ${dataPath}/consoleLogs \;
|
# logs have cave executable pid in the name, not worker pid
|
||||||
|
find $dir -type f -name "*$(determineCaveProcess ${cavePid})*" -exec cp {} ${dataPath}/consoleLogs \;
|
||||||
else
|
else
|
||||||
find $dir -type f -mmin -120 -exec cp {} ${dataPath}/consoleLogs \;
|
find $dir -type f -mmin -120 -exec cp {} ${dataPath}/consoleLogs \;
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue