分布式场景,启动多个Jmeter-Server服务,特殊情况需要重启Jmeter-server服务,机器过多时借助脚本实现重启,也可单独使用,多台机器启动jmeter-server。
1.控制脚本
Jmeter_restart.sh
#!/bin/sh
BUILD_ID=DONTKILLME
#此处可添加压力机ip地址,以“ 空格”分隔
Jmeter=(192.168.0.1 192.168.0.2)
for ip in ${Jmeter[*]}
do
echo "====================================================="
echo "$ip "
#注意修改脚本路径
ssh -t -p 22 root@$ip "/opt/Jmeter/bin/stop.sh"
ssh -t -p 22 root@$ip "/opt/Jmeter/bin/start.sh"
echo "================================================================="
done
2.启动脚本
start.sh
#! /bin/sh
source /etc/profile
source ~/.bash_profile
nohup jmeter-server >/dev/null 2>&1 &
sleep 2
processids=`ps -ef | grep java | awk '{print $2}'`
echo jmeter-server process $processids has started ....
exit 0
3.停止脚本
stop.sh
#! /bin/sh
psid = `ps -ef | grep ApacheJMeter | awk '{ print $2 }'`
echo "$pid"
for pid in $psid;do
if [ -n "Spid" ]; then
kill -9 "$pid"
fi
done
exit 0
网友评论