@@ -76,33 +76,39 @@ echo "====================================== Collection for for all process ====
7676SIGNAL_FILE=" /tmp/nso_collect_start_signal_$$ "
7777rm -f " $SIGNAL_FILE "
7878
79+ rm -rf " /tmp/signalback"
80+ mkdir " /tmp/signalback"
81+
7982# Find and collect for each process type
8083echo " Starting collection processes..."
8184
8285NS=1000000000
86+ counter=0
8387
8488mkdir -p data/python3
8589for (( i= 0 ;i<= $DURATION ;i++ ))
8690do
8791 START_TIME=$( date +%s%N)
8892 PYTHON_PIDS=$( pgrep -f " python.* .*startup\.py" )
89- JVM_PID=$( pgrep -f NcsJVMLauncher)
93+ JVM_PID=$( pgrep -f com.tailf.ncs. NcsJVMLauncher)
9094 NCS_PID=$( pgrep -f " \.smp.*-ncs true" )
9195
9296 # Collect ncs.smp or beam.smp NSO process
9397 if [ ! -z " $NCS_PID " ]; then
94- # echo "Starting collection for ncs.smp PID $NCS_PID"
9598 COLLECT_PIDS=$( pgrep -f " .*collect.sh.* $NCS_PID " )
9699 if [ -z " $COLLECT_PIDS " ]; then
100+ echo " New ncs.smp process PID $NCS_PID : ncs.smp. Start Collection"
101+ counter=$(( counter+ 1 ))
97102 bash collect.sh $NCS_PID " data/ncs.smp/mem_ncs.smp.log" $DURATION $VERBOSE " $SIGNAL_FILE " &
98103 fi
99104 fi
100105
101106 # Collect NcsJVMLauncher process
102107 if [ ! -z " $JVM_PID " ]; then
103- # echo "Starting collection for NcsJVMLauncher PID $JVM_PID"
104108 COLLECT_PIDS=$( pgrep -f " .*collect.sh.* $JVM_PID " )
105109 if [ -z " $COLLECT_PIDS " ]; then
110+ echo " New JVM process PID $JVM_PID : NcsJVMLauncher. Start Collection"
111+ counter=$(( counter+ 1 ))
106112 bash collect.sh $JVM_PID " data/NcsJVMLauncher/mem_NcsJVMLauncher.log" $DURATION $VERBOSE " $SIGNAL_FILE " &
107113 fi
108114 fi
112118 for pid in $PYTHON_PIDS ; do
113119 COLLECT_PIDS=$( pgrep -f " .*collect.sh.* $pid " )
114120 if [ -z " $COLLECT_PIDS " ]; then
115- # echo "Not Found Collection Process for Python process PID $pid. Spwaning new Collection Process."
116121 PYTHON_SCRIPT=$( ps -p $pid -o command | tail -n 1 | awk -F' ' ' {print $9}' )
117122 SCRIPT_NAME=$( basename " $PYTHON_SCRIPT " .py 2> /dev/null || echo " python_$pid " )
118123 if [ ! -z " $PYTHON_SCRIPT " ]; then
119- # echo "Starting collection for Python process PID $pid: $SCRIPT_NAME"
124+ echo " New Python process PID $pid : $SCRIPT_NAME . Start Collection"
125+ counter=$(( counter+ 1 ))
120126 bash collect.sh $pid " data/python3/mem_$SCRIPT_NAME .log" $DURATION -$i $VERBOSE " $SIGNAL_FILE " &
121127 fi
122- # else
123- # echo "Collection Process already running for Python process PID $pid"
128+
124129 fi
125130 done
126- # else
127- # echo "No Python processes found to collect. for second $i"
128131 fi
129132
130133
139142 fi
140143
141144 # Signal all processes to start collecting
142- touch " $SIGNAL_FILE "
143- wait
144- echo -ne " Data Collection - $i second out of $DURATION second" \\ r
145+ echo " $i " > $SIGNAL_FILE
145146
147+ while [[ $( ps -aux | grep " collect.sh" | wc -l) -gt $(( $(ls "/ tmp/ signalback" | wc - l)+ 1 )) ]]; do
148+
149+ sleep 0.1
150+ done
146151 # Clean up signal file
147152 rm -f " $SIGNAL_FILE "
148- pkill -f collect.sh
149- # # Give a moment for all processes to register
150- # sleep 1
153+
154+ rm -rf " /tmp/signalback"
155+ mkdir " /tmp/signalback"
156+
157+ echo -ne " Data Collection - $i second out of $DURATION second" \\ r
158+
159+
151160done
152161
162+ wait
163+ pkill -f collect.sh
164+ rm -rf " /tmp/signalback"
153165echo " "
154166echo " Data Collection - OK!"
155167
0 commit comments