├── .DS_Store ├── LICENSE ├── README.md ├── mamian_yace.sh ├── yace.sh └── yace.txt /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sydowma/jmeterShell/de205a44ed23dcabb630d6c3db94cd00a0b3f2cf/.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## yace 2 | 3 | ### 功能介绍 4 | 5 | 通过修改配置文件,修改jmx文件信息,进而执行jmeter 6 | 7 | ```shell 8 | 9 | chmod 0600 yace.sh 10 | 11 | # run jmx with duration 60 seconds 12 | ./yace.sh example.jmx 60 13 | # 在JMeter/bin 目录下运行 14 | ``` 15 | 16 | 17 | 18 | ### 配置文件信息 19 | 20 | ```shell 21 | 100 22 | 50m 23 | 150 24 | ``` 25 | 26 | 执行完毕后 jtl文件 默认压缩到Apache JMeter/bin 文件夹下 27 | 28 | 29 | 30 | ## mamian_yace 31 | 32 | ### 功能介绍: 33 | 34 | 通过sed命令直接修改jmx文件 35 | 36 | - 支持设置JMeter线程组数量 37 | - 支持设置JMeter开启调度器设置循环时间 38 | - 支持设置报告压缩文件夹 39 | 40 | ### 运行方法 41 | 42 | ```shell 43 | ./mamian_yace.sh -j jmeterPath -m jmxPath 44 | # jmeterPath Apache JMeter 路径 必填 45 | # jmxPath JMX 文件 路径 必填 46 | 47 | ./mamian_yace.sh -j jmeterPath -m jmxPath -n 100 48 | # 设置线程组数量100 49 | 50 | ./mamian_yace.sh -j jmeterPath -m jmxPath -n 100 -d 120 51 | # 设置线程组数量100 循环120秒 52 | 53 | ./mamian_yace.sh -j jmeterPath -m jmxPath -n 100 -d 120 -z /home/work 54 | # 设置线程组数量100 循环120秒 zip解压缩在/home/work目录下 55 | 56 | 57 | ``` 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /mamian_yace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 命令执行参数 4 | # 5 | # sh jmeterShellPath -n -t score_select.jmx -l score_select.jtl 6 | # Author: MARK 7 | # Email: mamian521@gmail.com 8 | # LICENSE: Apache License 2.0 9 | 10 | # 使用 11 | # 通过sed命令直接修改jmx文件 12 | # 支持设置JMeter线程组数量 13 | # 支持设置JMeter开启调度器设置循环时间 14 | # 支持设置报告压缩文件夹 15 | 16 | # 运行方法 17 | # ./mamian_yace.sh -j jmeterPath -m jmxPath 18 | # jmeterPath Apache JMeter 路径 必填 19 | # jmxPath JMX 文件 路径 必填 20 | 21 | # ./mamian_yace.sh -j jmeterPath -m jmxPath -n 100 22 | # 设置线程组数量100 23 | 24 | # ./mamian_yace.sh -j jmeterPath -m jmxPath -n 100 -d 120 25 | # 设置线程组数量100 循环120秒 26 | 27 | # ./mamian_yace.sh -j jmeterPath -m jmxPath -n 100 -d 120 -z /home/work 28 | # 设置线程组数量100 循环120秒 zip解压缩在/home/work目录下 29 | 30 | 31 | # 功能需求 32 | # 1. 根据输入的命令来增加压测任务 完成 33 | # 2. 提前设置好线程数 读取执行 完成 34 | 35 | 36 | # 已知问题 37 | # 只支持单次 38 | 39 | 40 | 41 | # 接收选项式的参数输入 42 | while [[ $# -gt 1 ]] 43 | do 44 | key="$1" 45 | 46 | case $key in 47 | # jmeter 路径 48 | -j|--jmeter) 49 | jmeterShellPath="$2/bin/jmeter.sh" 50 | shift # past argument 51 | ;; 52 | # jmx 文件路径 53 | -m|--jmx) 54 | jmxFilePath="$2" 55 | shift # past argument 56 | ;; 57 | # zip文件保存路径 58 | -z|--zip) 59 | zipPath="$2" 60 | shift # past argument 61 | # 不用read 62 | ;; 63 | 64 | -n|--noread) 65 | # LEN="$#" 66 | n="$2" 67 | # 循环遍历保存每个线程组数字 68 | # echo "提前设置的好的线程组数量是 "$@" " 69 | # 已知问题 -nr 参数必须在最后面 70 | # NUM_THREADS=( "$@" ) 71 | # NUM_THREADS_LENGTH=$# 72 | NUM_THREADS[1]=$n 73 | 74 | 75 | # 过滤参数 76 | # for((i=1;i<$array_length;i++)) 77 | # do 78 | # # 如果不是数字 79 | # if [ "$i" -ne 1 ]; then 80 | # echo "非法数字" 81 | # break 82 | # fi 83 | # NUM_THREADS[$i]=${array[$i]} 84 | # done 85 | # continue 86 | 87 | # NUM_THREADS=( "$@" ) 88 | # LEN=$# 89 | # echo "$LEN" 90 | # for((i=1;i<$LEN;i++)) 91 | # do 92 | # echo "$NUM_THREADS[$i]" 93 | # done 94 | shift # past argument # resume (to find later ) 95 | ;; 96 | 97 | -d|-duration) 98 | duration=$2 99 | # 时间 100 | 101 | shift 102 | ;; 103 | --default) 104 | DEFAULT=YES 105 | ;; 106 | -h|--help) 107 | # unknown option 108 | printf "%s\n" "使用方法" 109 | printf "%s\n" "-j 指定 Apache JMeter 文件夹路径" 110 | printf "%s\n" "-m jmx文件路径" 111 | printf "%s\n" "-z zip文件保存路径" 112 | printf "%s\n" "-n 提前设置的好的线程组数量" 113 | printf "%s\n" "-d duration 调度器时间" 114 | shift 115 | ;; 116 | *) 117 | # unknown option 118 | # echo '使用方法, -j jmeter路径\n -m jmx文件路径\n -z zip文件保存路径' 119 | ;; 120 | 121 | esac 122 | shift # past argument or value 123 | done 124 | 125 | 126 | 127 | 128 | # jmeterShellPath=$1 129 | # jmxFilePath=$2 130 | # echo $no 131 | 132 | 133 | # 判断jmeter路径是否为空 134 | if [ ! ${jmeterShellPath} ] || [ ! ${jmxFilePath} ] 135 | then 136 | printf "%s\n" "缺少相关参数" 137 | printf "%s\n" "-j Apache JMeter 目录路径," 138 | printf "%s\n" "-m jmx文件路径" 139 | exit 140 | fi 141 | 142 | # 如果有zip保存的路径, 就删除 jtl zip文件斜杠前面的路径 143 | # if [ ${zipPath} ] 144 | # then 145 | 146 | # fi 147 | 148 | 149 | 150 | 151 | #echo $a 152 | 153 | # 文件名zlr 154 | jtlFile=${jmxFilePath%.*} 155 | 156 | # 线程组设置 157 | # 如果没有提前输入 -nr 线程数, 那么就提醒用户手动输入, 这个时候只支持单个 158 | if [ ! ${NUM_THREADS[1]} ] 159 | then 160 | while true 161 | do 162 | # 充次数, 无意义 163 | NUM_THREADS[0]="1" 164 | # 让使用者选择所需要登陆服务器的所属序号 165 | read -p '请输入要设置的线程组数量: ' NUM_THREADS[1] 166 | 167 | 168 | # 如果输入为空格或者回车,显示错误信息,后续代码不再执行,重新循环。 169 | if [ ! ${NUM_THREADS[1]} ] 170 | then 171 | echo '请输入线程组数量' 172 | continue 173 | fi 174 | 175 | # 如果输入的不是数字,显示错误信息,后续代码不再执行,重新循环。 176 | if [[ "${NUM_THREADS[1]}" =~ [^0-9]+ ]] 177 | then 178 | echo '线程组是数字' 179 | continue 180 | fi 181 | 182 | # 如果输入的以 0 开头的数字、大于等于服务器台数、小于 0,显示错误信息,后续代码不再执行,重新循环。 183 | # if [[ "${NUM_THREADS}" =~ ^0[0-9]+ ]] || [ ${NUM_THREADS} -ge ${LEN} ] || [ ${NUM_THREADS} -lt 0 ] 184 | if [ ${NUM_THREADS[1]} -lt 0 ] 185 | then 186 | echo '请输入线程组数量' 187 | continue 188 | fi 189 | 190 | # 跳出循环 191 | break 192 | 193 | done 194 | fi 195 | 196 | # 重置所有 线程组到1 197 | # sed -i "s/\"ThreadGroup.num_threads\">[0-9]*/\"ThreadGroup.num_threads\">1/g" $jmxFilePath 198 | 199 | # 开始运行 200 | # sed -i 's/"ThreadGroup.num_threads">1/"ThreadGroup.num_threads">100/g' $a 201 | # sh jmeterShellPath -n -t $a -l ${b}_100_1.jtl 202 | # sed -i 's/"ThreadGroup.num_threads">100/"ThreadGroup.num_threads">500/g' $a 203 | # sh jmeterShellPath -n -t $a -l ${b}_500_1.jtl 204 | 205 | 206 | 207 | # sed 找到目标位置修改 208 | # 为了正常找到"", 需要对其进行转义 209 | # LEN=${#NUM_THREADS[@]} 210 | 211 | 212 | 213 | # 取线程组数量 214 | NUM_THREADS_LENGTH=${#NUM_THREADS[@]}+1 215 | 216 | # screen_echo() { 217 | 218 | # for((i=1;i<$NUM_THREADS_LENGTH;i++)) 219 | # do 220 | # printf "%-7s" '线程组数量为'  221 | # printf "\e[31m %-5s\e[0m\n" "${NUM_THREADS[$i]}" # 颜色为红色 222 | # done 223 | 224 | 225 | # # for((i=0; i <$LEN; i++)) 226 | # # do 227 | # # printf "\e[31m %-5s\e[0m|" "$i" # 颜色为红色 228 | # # printf "%-15s\n |" "${NUM_THREADS[$i]}" # 显示线程组数量 229 | # # done 230 | 231 | # } 232 | 233 | 234 | # # 调用函数,让信息显示出来 235 | # screen_echo 236 | 237 | # 如果开启调度器 说明是按时间 238 | echo "duration%s\n" "$duration" 239 | if [ ${duration} ] 240 | then 241 | # 开启或关闭调度器 242 | sed -i "s/\"ThreadGroup.scheduler\">.*true.*-1.*${duration}.*false.*1.*-1/"LoopController.loops">1/g' $jmxFilePath 268 | # sed -i 's/"ThreadGroup.scheduler">true/"ThreadGroup.scheduler">false/g' $jmxFilePath 269 | # sed -i 's/"ThreadGroup.duration">180/"ThreadGroup.duration">/g' $jmxFilePath 270 | 271 | 272 | 273 | auto_stress_test() { 274 | 275 | for (( i=1; i<${NUM_THREADS_LENGTH}; i++ )); 276 | do 277 | # 提示开始测试 278 | printf "%-7s" '线程组数量为'  279 | printf "\e[31m %-5s\e[0m\n" "${NUM_THREADS[$i]}" # 颜色为红色 280 | 281 | # 开始循环 282 | # 1. 保存的jtl文件名称 283 | jtlFileName=${jtlFile}_${NUM_THREADS[i]}_${duration}sec.jtl 284 | # 暂时先放在这里 , 后续要指定目录 ${jtlFileName##*/} 去掉 / 之前的路径 285 | # 2. 保存的jtl文件路径 现在会保存在 jmx 同一目录下 286 | 287 | 288 | 289 | 290 | # echo $jtlFilePath 291 | # 3. 修改jmx文件线程数 292 | sed -i "s/\"ThreadGroup.num_threads\">.*${NUM_THREADS[$i]}[0-9]*/\"ThreadGroup.num_threads\">$NUM_THREADS/g" $jmxFilePath 320 | # sh $jmeterShellPath -n -t $jmxFilePath -l $jtlFileName 321 | # zip ${jtlFilePath} ${jtlFileName} 322 | # tar -zcvf /home/xahot.tar.gz /xahot 323 | } 324 | 325 | 326 | auto_stress_test 327 | 328 | 329 | # sed -i "s/\"ThreadGroup.num_threads\">[0-9]*/\"ThreadGroup.num_threads\">${num_threads[1]}/g" $jmxFilePath 330 | # sh jmeterShellPath -n -t $jmxFilePath -l ${jtlFile}_${num_threads[1]}_1.jtl 331 | # sed -i "s/\"ThreadGroup.num_threads\">[0-9]*/\"ThreadGroup.num_threads\">${num_threads[2]}/g" $jmxFilePath 332 | # sh jmeterShellPath -n -t $jmxFilePath -l ${jtlFile}_${num_threads[2]}_1.jtl 333 | # sed -i "s/\"ThreadGroup.num_threads\">[0-9]*/\"ThreadGroup.num_threads\">${num_threads[3]}/g" $jmxFilePath 334 | # sh jmeterShellPath -n -t $jmxFilePath -l ${jtlFile}_${num_threads[3]}_1.jtl 335 | 336 | # # 设置循环次数 337 | 338 | # # 控制器 不需要改 339 | # sed -i 's/"LoopController.loops">1/"LoopController.loops">-1/g' $jmxFilePath 340 | 341 | # # 控制器 不需要改 342 | # sed -i 's/"ThreadGroup.scheduler">false/"ThreadGroup.scheduler">true/g' $jmxFilePath 343 | 344 | # # 时间: 3分钟 345 | # sed -i 's/"ThreadGroup.duration">/"ThreadGroup.duration">180/g' $jmxFilePath 346 | 347 | # # 并发数 修改回1000 348 | # sed -i 's/"ThreadGroup.num_threads">5000/"ThreadGroup.num_threads">1000/g' $jmxFilePath 349 | 350 | # # sh jmeterShellPath -n -t $a -l ${b}_100_3min.jtl 351 | # # sed -i 's/"ThreadGroup.num_threads">100/"ThreadGroup.num_threads">500/g' $a 352 | # # sh jmeterShellPath -n -t $a -l ${b}_500_3min.jtl 353 | # sed -i 's/"ThreadGroup.num_threads">1000/"ThreadGroup.num_threads">1000/g' $jmxFilePath 354 | # sh jmeterShellPath -n -t $jmxFilePath -l ${jtlFile}_${num_threads[1]}_3min.jtl 355 | # sed -i 's/"ThreadGroup.num_threads">1000/"ThreadGroup.num_threads">3000/g' $jmxFilePath 356 | # sh jmeterShellPath -n -t $jmxFilePath -l ${jtlFile}_${num_threads[2]}_3min.jtl 357 | # sed -i 's/"ThreadGroup.num_threads">3000/"ThreadGroup.num_threads">5000/g' $jmxFilePath 358 | # sh jmeterShellPath -n -t $jmxFilePath -l ${jtlFile}_${num_threads[3]}_3min.jtl 359 | 360 | # # 还原到原先状态 361 | # sed -i 's/"LoopController.loops">-1/"LoopController.loops">1/g' $jmxFilePath 362 | # sed -i 's/"ThreadGroup.scheduler">true/"ThreadGroup.scheduler">false/g' $jmxFilePath 363 | # sed -i 's/"ThreadGroup.duration">180/"ThreadGroup.duration">/g' $jmxFilePath 364 | # sed -i 's/"ThreadGroup.num_threads">5000/"ThreadGroup.num_threads">1/g' $jmxFilePath 365 | 366 | 367 | -------------------------------------------------------------------------------- /yace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: mark 4 | # LICENSE: Apache License 2.0 5 | 6 | # 7 | # 通过修改配置文件,修改jmx文件信息,进而执行jmeter 8 | # 使用前需要把shell文件放置到 Apache JMeter/bin 目录下 9 | # ./yace.sh example.jmx 10 | # ./yace.sh example.jmx 60 11 | # 在JMeter/bin 目录下运行 12 | 13 | # yace.txt 文件信息 14 | # 100 15 | # 50m 16 | # 150 17 | # 100并发*1次+50并发*3分钟+150并发*1次 18 | 19 | 20 | # $1 第一个参数 21 | # $2 持续时间 需要持续时间参数 22 | # jmxFileName 不带后缀 23 | 24 | 25 | jmxFile=$1 26 | 27 | jmxFileName=${jmxFile%.*} 28 | 29 | 30 | file="yacezlr.txt" 31 | for d in `cat $file` 32 | do 33 | #echo ${d:0-1} 34 | if [ ${d:0-1} != m ] ; then 35 | sed -i 's/"LoopController.loops">.*1.*false.*.*'${d}'.*-1.*true.*${duration}.*${duration}.*'${numberD}'