Last active
August 29, 2015 14:04
-
-
Save baskaran-md/7d77fa6bdc016bd22d8e to your computer and use it in GitHub Desktop.
Jenkins Console Log File Parser - To find the time taken by each test module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ts_get_sec() | |
{ | |
read -r h m s <<< $(echo $1 | tr ':' ' ' ) | |
echo $(((h*60*60)+(m*60)+s)) | |
} | |
## MAIN GOES HERE ## | |
LOG_FILE=$1 | |
grep -i "including the module" $LOG_FILE | awk '{print $1,$6}' | cut -d '/' -f1 | sort | uniq -f1 | sed 's/ /#/g' | sed 's/:0/:/g' > cText.log | |
grep -i "apigee-jmeter-report:" $LOG_FILE | sed 's/ /#/g' | sed 's/apigee-jmeter-report:/END/g' >> cText.log | |
i=1 | |
for line in `cat cText.log` | |
do | |
TC=`echo $line | cut -d '#' -f2`; | |
l1=`sed -n "${i}p" cText.log | cut -d '#' -f1 | cut -d '.' -f1`; | |
i=`expr $i + 1`; | |
l2=`sed -n "${i}p" cText.log | cut -d "#" -f1 | cut -d '.' -f1`; | |
start_ts=$l1 | |
stop_ts=$l2 | |
START=$(ts_get_sec $start_ts) | |
STOP=$(ts_get_sec $stop_ts) | |
DIFF=$((STOP-START)) | |
tdiff="$((DIFF/60)).$((DIFF%60))" | |
echo "$tdiff" | awk '{print int( ($1) + 1 )}' | tr '\n' '\t\t' >> tcTime.log | |
echo "::: $TC" >> tcTime.log | |
done | |
cat tcTime.log | grep -v "TOTAL TIME" | grep -v "#####" > tmp_tcTime.log | |
cat tmp_tcTime.log | sort -g | uniq > tcTime.log | |
totalTime=0 | |
for i in `cat tcTime.log | grep -v "END" | awk '{print $1}'` | |
do | |
totalTime=`expr $totalTime + $i` | |
done | |
cp tcTime.log tmp_tcTime.log | |
echo "$totalTime#::: TOTAL TIME" | tr '#' '\t\t' > tcTime.log | |
echo "#########################" >> tcTime.log | |
cat tmp_tcTime.log | grep -v "::: END" >> tcTime.log | |
cat tcTime.log | |
rm tmp_tcTime.log | |
rm cText.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment