jmeter一键启停agent shell脚本
2019-06-10 16:25
2521 查看
Jmeter分布式压测过程中经常需要到节点上启停jmeter agent,因此编写一键启停jmeter脚本可以帮助减轻不少工作量,只需要输入节点密码即可,安全有可靠。如果密码也不想输入,可参考本人另一篇文章https://blog.csdn.net/a200822146085/article/details/91363280,使用expect达到免密输入。
Agent端脚本,放到agent端测试脚本目录
#! /bin/bash #获取主机ip HOST_IP=`ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " " ` function start(){ cd /usr/local/tomcat/wanwei/tensorflow nohup jmeter-server -Djava.rmi.server.hostname=$HOST_IP & if [[ $? -eq 0 ]] then echo "start agent success.........." else echo "start agent failed..........." fi exit 0 } function stop(){ pids=$(ps -ef | grep jmeter-server | grep -v grep | awk '{print $2}') for pid in ${pids[*]} do kill -9 ${pid} echo ${pid} done if [[ $? -eq 0 ]] then echo "stop agent success.........." else echo "stop agent failed..........." fi } case $1 in start) start ;; stop) stop ;; restart) stop sleep 2 start ;; *) echo "Usage sh agent_process {start|stop|restart}" ;; esac
Server端控制脚本,放到server端任何目录即可
#! /bin/bash ip_arr=("10.201.3.250" "10.201.3.249") for ip in ${ip_arr[*]} do ssh testmsgpub@$ip << eeooff cd /usr/local/tomcat/wanwei/tensorflow sh agent_process.sh $1 eeooff done
用法
- 启动:sh agent_start_stop.sh start
- 停止:sh agent_start_stop.sh stop
- 重启:sh agent_start_stop.sh restart
相关文章推荐
- shell脚本一键安装nginx
- Linux环境下通过shell脚本一键安装redis
- Centos5.8上面用Shell脚本一键安装mysql5.5.25源码包
- shell脚本实现ipa一键安装(itms-services协议)
- Centos上面用Shell脚本一键安装LNMP环境
- shell脚本一键安装ftp及配置
- 基于Shell脚本的Linux下Javaweb项目一键部署
- Linux环境一键自动化安装oracle软件的构想(附shell脚本)
- shell脚本:一键优化centos系统
- Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
- shell脚本:LAMP一键自动安装 (linux,apache,mysql,php)
- zabbix-agent一键部署脚本
- shell脚本一键安装LNMP环境
- Centos 上面用Shell脚本一键安装LAMP环境
- 一键备份gitolite服务器的Shell脚本
- Shell脚本一键安装LNMP环境
- shell脚本一键安装solr4.10.0
- 使用 shell 脚本实现 LANMP 一键安装
- 昊鼎王五:如何2分钟内shell脚本实现编译安装zabbix_agent客户端?