1.创建虚拟环境
2.进入到bin目录执行source activate打开虚拟环境
第一种直接运行:locust -f ***.py(文件名称)--host=***
第二种同一台机器上有多核先启动master,再一个个启动worker(worker的数量不能超过本机核数)
第三种多个机器上,虚拟环境保持一致,主机上运行 locust -f ***.py --master,在其他机器上运行命令:locust -f ***.py --worker --master-host=xxx.xxx.xxx.xxx
备注后台执行:nohup xxx &~
windows上小脚本直接控制执行,双击即可:
1.安装putty.
2.
set ws=createobject("wscript.shell")
ws.run "putty.exe -ssh -pw 密码 root@10.128.33.82"
wscript.Sleep 2000
ws.AppActivate "10.128.33.82"
wscript.Sleep 1000
ws.SendKeys "kill -9 $(ps -ef|grep locust|grep -v grep|awk '{print $2}')~"
wscript.Sleep 1000
ws.SendKeys "cd /opt/python38/bin/locusttest/bin~"
wscript.Sleep 1000
ws.SendKeys "source activate~"
wscript.Sleep 1000
ws.SendKeys "cd /opt/python38/bin/locusttest/test_cases/~"
wscript.Sleep 1000
ws.SendKeys "nohup locust -f locust_label.py --host=http://10.128.166.181:32856 --master &~"
wscript.Sleep 1000
set ws=createobject("wscript.shell")
ws.run "putty.exe -ssh -pw 密码 root@10.128.33.82"
wscript.Sleep 2000
ws.AppActivate "10.128.33.82"
wscript.Sleep 1000
ws.SendKeys "cd /opt/python38/bin/locusttest/bin~"
wscript.Sleep 1000
ws.SendKeys "source activate~"
wscript.Sleep 1000
ws.SendKeys "cd /opt/python38/bin/locusttest/test_cases/~"
wscript.Sleep 1000
ws.SendKeys "nohup locust -f locust_label.py --worker &~"
wscript.Sleep 1000