Locust 啓動命令的可選參數
如果參數是以“--”開頭,則以 = 連接實參。例如“--host=http://sample”。如果不是,則以空格連接實參。例如“-H http://sample”
-h, --help
查看幫助
-H HOST, --host=HOST
被測服務器的域名
--web-host=WEB_HOST
locust服務的web界面
-P PORT, --port=PORT, --web-port=PORT
指定 –web-host 的端口,默認是8089
-f
腳本路徑。可以寫相對路徑或是絕對路徑。如果是腳本當前目錄下,就寫相對路徑。如果不是,就寫絕地路徑。
--csv=CSVFILEBASE, --csv-base-name=CSVFILEBASE
以CSV格式存儲當前請求測試數據,csv文件存放當前目錄
--master
做分佈式壓測時,標記哪臺用做主機。主機只用來做統計,並不用來施壓。施壓的任務留給slave分機做。如果想主機也做來施壓,就要在主機上也啓動一個slave。
--slave
做分佈式壓測時,標記哪些用做分機。分機的主要任務是進行施壓。
--master-host
做分佈式壓測時,指定主機的IP。只用於slave。如果沒有指定,默認是本機“127.0.0.1”。
--master-port
做分佈式壓測時,指定主機的port。只用於slave。如果沒有指定且主機沒有修改的話,默認是5557。
--master-bind-host
做分佈式壓測時,指定分機IP。只用於master。如果沒有指定,默認是所有可用的IP(即所有標記主機IP的slave)
--master-bind-port
做分佈式壓測時,指定分機port。默認是5557與5558。
--heartbeat-liveness=HEARTBEAT_LIVENESS
set number of seconds before failed heartbeat from slave
--heartbeat-interval=HEARTBEAT_INTERVAL
set number of seconds delay between slave heartbeats to master
--expect-slaves=EXPECT_SLAVES
在開始測試之前,需要連接多少個從屬主機(僅 --no-web 使用).
--no-web
no-web模式,要求指定-c和-r.
-c NUM_CLIENTS, --clients=NUM_CLIENTS
併發用戶數. Only used togetherwith --no-web
-r HATCH_RATE, --hatch-rate=HATCH_RATE
每秒生成用戶的速率. 和--no-web一起使用
-t RUN_TIME, --run-time=RUN_TIME
在指定時間後停止, 如 (300s,20m, 3h, 1h30m, etc.). 和--no-web一起使用
-L LOGLEVEL, --loglevel=LOGLEVEL
日誌等級(DEBUG/INFO/WARNING/ERROR/CRITICAL.默認INFO.)
--logfile=LOGFILE
日誌文件的路徑。如果未設置,日誌將轉到stdout/stderr
--print-stats
在控制檯中打印統計信息
--only-summary
只打印摘要統計信息
--no-reset-stats
[DEPRECATED] Do not reset statistics once hatching has been completed. This is now the default behavior. See --reset-stats to disable
--reset-stats
Reset statistics once hatching has been completed. Should be set on both master and slaves when running in distributed mode
-l, --list
顯示可能的locust類列表並退出
--show-task-ratio
打印locust類任務執行率表
--show-task-ratio-json
打印locust類任務執行率的JSON數據
-V, --version
locust版本
usage: locust [-h] [-H HOST] [--web-host WEB_HOST] [-P PORT] [-f LOCUSTFILE]
[--csv CSVFILEBASE] [--csv-full-history] [--master] [--slave]
[--master-host MASTER_HOST] [--master-port MASTER_PORT]
[--master-bind-host MASTER_BIND_HOST]
[--master-bind-port MASTER_BIND_PORT]
[--heartbeat-liveness HEARTBEAT_LIVENESS]
[--heartbeat-interval HEARTBEAT_INTERVAL]
[--expect-slaves EXPECT_SLAVES] [--no-web] [-c NUM_CLIENTS]
[-r HATCH_RATE] [-t RUN_TIME] [--skip-log-setup] [--step-load]
[--step-clients STEP_CLIENTS] [--step-time STEP_TIME]
[--loglevel LOGLEVEL] [--logfile LOGFILE] [--print-stats]
[--only-summary] [--no-reset-stats] [--reset-stats] [-l]
[--show-task-ratio] [--show-task-ratio-json] [-V]
[--exit-code-on-error EXIT_CODE_ON_ERROR] [-s STOP_TIMEOUT]
[LocustClass [LocustClass ...]]
Args that start with '--' (eg. -H) can also be set in a config file
(~/.locust.conf or locust.conf). Config file syntax allows: key=value,
flag=true, stuff=[a,b,c] (for details, see syntax at https://goo.gl/R74nmi).
If an arg is specified in more than one place, then commandline values
override config file values which override defaults.
1.也可以在配置文件中設置以“---”開頭的參數
2.配置文件語法允許:key=value,flag=true,stuff=[a,b,c]
3.如果在多個位置指定了參數,則命令行值覆蓋覆蓋默認值的配置文件值。
positional arguments:
LocustClass
optional arguments:
-h, --help show this help message and exit
-H HOST, --host HOST Host to load test in the following format:
http://10.21.32.33
--web-host WEB_HOST Host to bind the web interface to. Defaults to '' (all
interfaces)
-P PORT, --port PORT, --web-port PORT
Port on which to run web host
-f LOCUSTFILE, --locustfile LOCUSTFILE
Python module file to import, e.g. '../other.py'.
Default: locustfile
--csv CSVFILEBASE, --csv-base-name CSVFILEBASE
Store current request stats to files in CSV format.
--csv-full-history Store each stats entry in CSV format to
_stats_history.csv file
--master Set locust to run in distributed mode with this
process as master
--slave Set locust to run in distributed mode with this
process as slave
--master-host MASTER_HOST
Host or IP address of locust master for distributed
load testing. Only used when running with --slave.
Defaults to 127.0.0.1.
--master-port MASTER_PORT
The port to connect to that is used by the locust
master for distributed load testing. Only used when
running with --slave. Defaults to 5557.
--master-bind-host MASTER_BIND_HOST
Interfaces (hostname, ip) that locust master should
bind to. Only used when running with --master.
Defaults to * (all available interfaces).
--master-bind-port MASTER_BIND_PORT
Port that locust master should bind to. Only used when
running with --master. Defaults to 5557.
--heartbeat-liveness HEARTBEAT_LIVENESS
set number of seconds before failed heartbeat from
slave
--heartbeat-interval HEARTBEAT_INTERVAL
set number of seconds delay between slave heartbeats
to master
--expect-slaves EXPECT_SLAVES
How many slaves master should expect to connect before
starting the test (only when --no-web used).
--no-web Disable the web interface, and instead start running
the test immediately. Requires -c and -t to be
specified.
-c NUM_CLIENTS, --clients NUM_CLIENTS
Number of concurrent Locust users. Only used together
with --no-web
-r HATCH_RATE, --hatch-rate HATCH_RATE
The rate per second in which clients are spawned. Only
used together with --no-web
-t RUN_TIME, --run-time RUN_TIME
Stop after the specified amount of time, e.g. (300s,
20m, 3h, 1h30m, etc.). Only used together with --no-
web
--skip-log-setup Disable Locust's logging setup. Instead, the
configuration is provided by the Locust test or Python
defaults.
--step-load Enable Step Load mode to monitor how performance
metrics varies when user load increases. Requires
--step-clients and --step-time to be specified.
--step-clients STEP_CLIENTS
Client count to increase by step in Step Load mode.
Only used together with --step-load
--step-time STEP_TIME
Step duration in Step Load mode, e.g. (300s, 20m, 3h,
1h30m, etc.). Only used together with --step-load
--loglevel LOGLEVEL, -L LOGLEVEL
Choose between DEBUG/INFO/WARNING/ERROR/CRITICAL.
Default is INFO.
--logfile LOGFILE Path to log file. If not set, log will go to
stdout/stderr
--print-stats Print stats in the console
--only-summary Only print the summary stats
--no-reset-stats [DEPRECATED] Do not reset statistics once hatching has
been completed. This is now the default behavior. See
--reset-stats to disable
--reset-stats Reset statistics once hatching has been completed.
Should be set on both master and slaves when running
in distributed mode
-l, --list Show list of possible locust classes and exit
--show-task-ratio print table of the locust classes' task execution
ratio
--show-task-ratio-json
print json data of the locust classes' task execution
ratio
-V, --version show program's version number and exit
--exit-code-on-error EXIT_CODE_ON_ERROR
sets the exit code to post on error
-s STOP_TIMEOUT, --stop-timeout STOP_TIMEOUT
Number of seconds to wait for a simulated user to
complete any executing task before exiting. Default is
to terminate immediately. This parameter only needs to
be specified for the master process when running
Locust distributed.