Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
UmakantKulkarni committed Sep 12, 2021
1 parent 4e8ad17 commit c3c7ccc
Showing 1 changed file with 63 additions and 56 deletions.
119 changes: 63 additions & 56 deletions getCpuVsQueue.sh
Original file line number Diff line number Diff line change
@@ -1,65 +1,72 @@
#!/usr/bin/env bash

for exp in Run4/* ;
do
echo $exp
f1=`basename $exp`
for subexp in `seq 100 100 1000`
do
for j in `seq 0 1 10`
do
if [[ $exp =~ "Blocking-Api-Disabled" || $exp =~ "Fully-Procedural-Stateless" ]]; then
echo "Working on $exp"
echo " "
f1=`basename $exp`
for subexp in `seq 100 100 1000`
do
amfTopFile=$exp/$f1-$j/$subexp/top_data_node1.txt
topCpuOpFile=$exp/$f1-$j/$subexp/topCpuOp.csv
queueLenFile=$exp/$f1-$j/$subexp/queueLen.csv
rm -f $topCpuOpFile
rm -f $queueLenFile
for j in `seq 0 1 10`
do
amfTopFile=$exp/$f1-$j/$subexp/top_data_node1.txt
topCpuOpFile=$exp/$f1-$j/$subexp/topCpuOp.csv
queueLenFile=$exp/$f1-$j/$subexp/queueLen.csv
rm -f $topCpuOpFile
rm -f $queueLenFile

echo "UTC-Time, Time-Diff, CPU-Usage" >> $topCpuOpFile
timestamps=( $(cat $amfTopFile | grep 2021- | grep -o '\-\-.*' | cut -c 3-) )
timestamps=("${timestamps[@]:1}")
cpusage=( $(cat $amfTopFile | grep open5gs-amfd | awk '{print $9}') )
basecpu="0.0"
k=0
for i in "${!cpusage[@]}";
do
if (( $(echo "${cpusage[$i]} > $basecpu" |bc -l) )); then
mdtTs=${timestamps[$i]}
if [[ $k == 0 ]]; then
firstTs=$(TZ=UTC date -d "$mdtTs MDT - 0.2 second" +'%T.%3N')
firstEpochTs=$(date -d "$firstTs" +"%s.%3N")
echo "$firstTs, 0, $basecpu" >> $topCpuOpFile
echo "Working on $topCpuOpFile"
echo "UTC-Time, Time-Diff, CPU-Usage" >> $topCpuOpFile
timestamps=( $(cat $amfTopFile | grep 2021- | grep -o '\-\-.*' | cut -c 3-) )
timestamps=("${timestamps[@]:1}")
cpusage=( $(cat $amfTopFile | grep open5gs-amfd | awk '{print $9}') )
basecpu="0.0"
k=0
for i in "${!cpusage[@]}";
do
if (( $(echo "${cpusage[$i]} > $basecpu" |bc -l) )); then
mdtTs=${timestamps[$i]}
if [[ $k == 0 ]]; then
firstTs=$(TZ=UTC date -d "$mdtTs MDT - 0.2 second" +'%T.%3N')
firstEpochTs=$(date -d "$firstTs" +"%s.%3N")
echo "$firstTs, 0, $basecpu" >> $topCpuOpFile
fi
utcTs=$(TZ=UTC date -d "$mdtTs MDT" +'%T.%3N')
epochTs=$(date -d "$utcTs" +"%s.%3N")
timediff=$(echo -e "$epochTs-$firstEpochTs" | bc)
timediff=$(echo -e "$timediff*1000" | bc | rev | cut -c 5- | rev)
echo "$utcTs, $timediff, ${cpusage[$i]}" >> $topCpuOpFile
k=$k+1
fi
utcTs=$(TZ=UTC date -d "$mdtTs MDT" +'%T.%3N')
epochTs=$(date -d "$utcTs" +"%s.%3N")
timediff=$(echo -e "$epochTs-$firstEpochTs" | bc)
timediff=$(echo -e "$timediff*1000" | bc | rev | cut -c 5- | rev)
echo "$utcTs, $timediff, ${cpusage[$i]}" >> $topCpuOpFile
k=$k+1
fi
done
utcTs=$(TZ=UTC date -d "$mdtTs MDT + 0.2 second" +'%T.%3N')
epochTs=$(date -d "$utcTs" +"%s.%3N")
timediff=$(echo -e "$epochTs-$firstEpochTs" | bc)
timediff=$(echo -e "$timediff*1000" | bc | rev | cut -c 5- | rev)
echo "$utcTs, $timediff, $basecpu" >> $topCpuOpFile
done
utcTs=$(TZ=UTC date -d "$mdtTs MDT + 0.2 second" +'%T.%3N')
epochTs=$(date -d "$utcTs" +"%s.%3N")
timediff=$(echo -e "$epochTs-$firstEpochTs" | bc)
timediff=$(echo -e "$timediff*1000" | bc | rev | cut -c 5- | rev)
echo "$utcTs, $timediff, $basecpu" >> $topCpuOpFile

echo "UTC-Time, Time-Diff, Queue-Length" >> $queueLenFile
mints=$(date -d "$(cat $topCpuOpFile | sed -n 2p | awk '{print $1}' | rev | cut -c 2- | rev)" +"%s.%3N")
maxts=$(date -d "$(cat $topCpuOpFile | tail -n1 | awk '{print $1}' | rev | cut -c 2- | rev)" +"%s.%3N")
utcTs=( $(cat $exp/$f1-$j/$subexp/open5gs-amf-deployment-*_logs.txt | grep " ogs_queue_size is" | grep "PCS " | awk '{print $2}' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | rev | cut -c 2- | rev) )
queuelens=( $(cat $exp/$f1-$j/$subexp/open5gs-amf-deployment-*_logs.txt | grep " ogs_queue_size is" | grep "PCS " | awk '{print $9}') )
for i in "${!utcTs[@]}";
do
epochTs=$(date -d "${utcTs[$i]}" +"%s.%3N")
if (( $(echo "$epochTs > $mints" |bc -l) )); then
if (( $(echo "$epochTs < $maxts" |bc -l) )); then
timediff=$(echo -e "$epochTs-$mints" | bc)
timediff=$(echo -e "$timediff*1000" | bc | rev | cut -c 5- | rev)
echo "${utcTs[$i]}, $timediff, ${queuelens[$i]}" >> $queueLenFile
k=$k+1
echo "Working on $queueLenFile"
echo "UTC-Time, Time-Diff, Queue-Length" >> $queueLenFile
mints=$(date -d "$(cat $topCpuOpFile | sed -n 2p | awk '{print $1}' | rev | cut -c 2- | rev)" +"%s.%3N")
maxts=$(date -d "$(cat $topCpuOpFile | tail -n1 | awk '{print $1}' | rev | cut -c 2- | rev)" +"%s.%3N")
utcTs=( $(cat $exp/$f1-$j/$subexp/open5gs-amf-deployment-*_logs.txt | grep " ogs_queue_size is" | grep "PCS " | awk '{print $2}' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | rev | cut -c 2- | rev) )
queuelens=( $(cat $exp/$f1-$j/$subexp/open5gs-amf-deployment-*_logs.txt | grep " ogs_queue_size is" | grep "PCS " | awk '{print $9}') )
for i in "${!utcTs[@]}";
do
epochTs=$(date -d "${utcTs[$i]}" +"%s.%3N")
if (( $(echo "$epochTs > $mints" |bc -l) )); then
if (( $(echo "$epochTs < $maxts" |bc -l) )); then
timediff=$(echo -e "$epochTs-$mints" | bc)
timediff=$(echo -e "$timediff*1000" | bc | rev | cut -c 5- | rev)
echo "${utcTs[$i]}, $timediff, ${queuelens[$i]}" >> $queueLenFile
k=$k+1
fi
fi
fi
done
done
done
done
echo "Completed processing files from $exp/$f1-$j/$subexp/"
echo " "
done
done
fi
done

0 comments on commit c3c7ccc

Please sign in to comment.