forked from kowalcj0/gee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzeZippedResults.sh
executable file
·206 lines (167 loc) · 8.61 KB
/
analyzeZippedResults.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env bash
#
# JMETER="apache-jmeter-2.9" DEBUG=true FILES="hibuVoiceLongRun/2013-03-31-13_01-*-jtls.zip" WIDTH=20000 HEIGHT=1080 ./analyzeZippedResults.sh
# Get the absolute path to the directory with this script
# Source: http://stackoverflow.com/a/630387
MY_PATH="`dirname \"$0\"`";
## =============================================================================
## import other scripts
## =============================================================================
. ${MY_PATH}/helpers.sh #load all the generic helpers
# Execute the jmeter-ec2.properties file, to get access to JMETER_VERSION variable
# if default config file is not present, then use default version of jmeter=2.9
if [ -f "${MY_PATH}/jmeter-ec2.properties" ] ; then
. ${MY_PATH}/jmeter-ec2.properties
else
JMETER_VERSION="apache-jmeter-2.10"
fi
################################################################################
# check if all required programs are installed
################################################################################
isProgramInstalled "unzip";
isProgramInstalled "grep";
isProgramInstalled "java";
################################################################################
# GLOBALS
################################################################################
DATETIME=$(date +"%Y-%m-%d_-_%H-%M") # more human readable date format, used to reporting
COUNT=
TMP=`mktemp -d` # create temp folder for processing
# declare all types of reports that you want to generate
GRAPHS=("ResponseTimesOverTime" "LatenciesOverTime" "ResponseTimesDistribution" "ResponseTimesPercentiles" "BytesThroughputOverTime" "HitsPerSecond" "ResponseCodesPerSecond" "TimesVsThreads" "TransactionsPerSecond" "ThroughputVsThreads");
################################################################################
# STEP 1 - check all provided parameters and set defaults were possible
################################################################################
# check for JMETER
if [ -z "$JMETER_VERSION" ]; then
cWarn "You forgot to provide path to the JMeter folder as a JMETER parameter. Please provide a valid path!!"
exit 1;
else
if [ -d $JMETER_VERSION ] && [[ -n $(ls $JMETER_VERSION/) ]] && [[ -e "${JMETER_VERSION}/bin/jmeter" ]] && [[ -e "${JMETER_VERSION}/lib/ext/CMDRunner.jar" ]]; then
cLog "Jmeter with CMDRunner.jar is installed properly" ${DEBUG}
else
cWarn "Couldn't find either Jmeter inslled in ${JEMTER_VERSION} folder or CMDRunner.jar in ${JMETER_VERSION}/lib/ext/CMDRunner.jar"
exit 2;
fi;
fi;
# assume that if no count was provided, then there's only 1 file to process
if [ -z "$FILES" ] ; then
cErr "
Please provide a path with the file name pattern to find all the result files, ie.:
if you have 3 zipped result files
2013-03-31-13_01-0-jtls.zip 2013-03-31-13_01-1-jtls.zip 2013-03-31-13_01-2-jtls.zip
then your command should look like:
FILES=\"hibuVoiceLongRun/2013-03-31-13_01-*-jtls.zip\" ./analyzeZippedResults.sh
NOTE:
If you have only one file to process, then then type the whole filepath
To run the script in a DEBUG mode add DEBUG=true to the command:
DEBUG=true FILES=\"hibuVoiceLongRun/2013-03-31-13_01-*-jtls.zip\" ./analyzeZippedResults.sh
"
exit 1;
else
lsCmd="ls --format single-column ${FILES}"
FILES_PATH=`basename "${FILES}"` # a copy of the original path, used to show in report
FILES=`${lsCmd} 2> /dev/null`
COUNT=`${lsCmd} 2> /dev/null | wc -l`
if [[ ${COUNT} -eq 1 ]]; then
cLog "Found only '${COUNT}' file using path provided!"
elif [[ ${COUNT} -gt 1 ]]; then
cLog "Found ${COUNT} files using path provided!"
else
cErr "Couldn't find any files using path provided! Please check it!"
exit 1;
fi;
fi;
# disable DEBUG mode as default
if [ -z "$DEBUG" ] ; then
DEBUG="false";
else
cWan "DEBUG mode is enabled" ${DEBUG}
fi;
# assume that if no width was provided, then use the default 1920px
if [ -z "$WIDTH" ] ; then
cWarn "Target graph WIDTH wasn't provided, I'm using default 1920px" ${DEBUG}
WIDTH="1920";
fi;
# assume that if no height was provided, then use the default 1200px
if [ -z "$HEIGHT" ] ; then
cWarn "Target graph HEIGHT wasn't provided, I'm using default 1200px" ${DEBUG}
HEIGHT="1200";
fi;
# assume that if no target folder was provided, then use the default result folder in the current directory
if [ -z "$TARGET" ] ; then
cLog "Target directory wasn't provided, I'm using default ./target" ${DEBUG}
TARGET="${MY_PATH}/target";
if [[ ! -d "${TARGET}" ]]; then
cLog "Creating target directory in the current directory" ${DEBUG}
mkdir ${TARGET}
fi;
if [[ ! -d "${TARGET}/${DATETIME}" ]]; then
mkdir ${TARGET}/${DATETIME} #create folder for images
fi;
else
if [[ ! -d "${TARGET}/${DATETIME}" ]]; then
mkdir ${TARGET}/${DATETIME} #create folder for images
fi;
fi;
# copy bootstrap folder to targer folder
if [[ ! -d "${TARGET}/bootstrap" ]] ; then
cp -R ${MY_PATH}/resources/bootstrap ${TARGET}/${DATETIME}
fi
################################################################################
# STEP 2 - extract all the zips
################################################################################
extractFiles "${FILES}";
################################################################################
# STEP 3 - merge selected files
################################################################################
mergeFilesUsingZipsNames "result.jtl" "${FILES}" "resultsMerged.jtl"
################################################################################
# STEP 3 - clean grouped file
################################################################################
refineGroupedFile "resultsMerged.jtl" "resultsMergedAndRefined.jtl"
#***************************************************************************
# add datatime to the report file that will point at the folder with graphs
# ps. that's why header filer is split in three parts
# I'm echo'eing with '-n' to remove new lines when appending to report file
#***************************************************************************
cat ${MY_PATH}/resources/zipHeader.txt \
| sed "s/*WIDTH\*/${WIDTH}/g" \
| sed "s/*HEIGHT\*/${HEIGHT}/g" \
| sed "s/*FOLDER\*/${DATETIME}/g" \
| sed "s/*TITLE\*/JMeter report generated on: ${DATETIME} from ${FILES_PATH} using analyzeZippedResults\.sh/g" \
> ${TARGET}/${DATETIME}-report.html
#echo -n `cat resources/zipHeader-part1.txt` > ${TARGET}/${DATETIME}-report.html
#echo -n ${DATETIME} >> ${TARGET}/${DATETIME}-report.html
#echo -n `cat resources/zipHeader-part2.txt` >> ${TARGET}/${DATETIME}-report.html
#echo -n ${DATETIME} >> ${TARGET}/${DATETIME}-report.html
#echo -n `cat resources/zipHeader-part3.txt` >> ${TARGET}/${DATETIME}-report.html
################################################################################
# STEP 4 - create graphs from the grouped file
################################################################################
# GRAPHS array is passed jsut as name, thus there is no $, it shall be
# expanded only in the called function
# http://stackoverflow.com/questions/1063347/passing-arrays-as-parameters-in-bash#comment12455821_4017175
generateGraphsFromFile GRAPHS[@] "resultsMergedAndRefined.jtl" "${WIDTH}" "${HEIGHT}"
################################################################################
# STEP 5 - run graph gen for perfMon
################################################################################
generatePerfMonGraphsFromFiles "${FILES}" "${WIDTH}" "${HEIGHT}"
################################################################################
# STEP 5 - create graphs from the individual result files
################################################################################
# GRAPHS array is passed jsut as name, thus there is no $, it shall be
# expanded only in the called function
# http://stackoverflow.com/questions/1063347/passing-arrays-as-parameters-in-bash#comment12455821_4017175
generateGraphsFromFiles GRAPHS[@] "${FILES}" "${WIDTH}" "${HEIGHT}"
#***************************************************************************
# add report header to a new report file
#***************************************************************************
cat resources/zipFooter.txt >> ${TARGET}/${DATETIME}-report.html
#tree $TMP
#tree ${TARGET}
################################################################################
# STEP 7 - tidy up
################################################################################
cLog "Deleting TMP folder!"
rm -fr ${TMP}