由网络副手--寻路人于2018.10.31 14:12:00发布在Linux Shell siege 安装+压测工具使用说明 阅读3845 评论0 喜欢0 一、安装: wget http://download.joedog.org/siege/siege-4.0.4.tar.gz tar -xzvf siege-4.0.4.tar.gz cd siege-4.0.4/ ./configure --prefix="/usr/local/siege-404" make && make install ln -s /usr/local/siege-404/bin/siege.config /usr/local/bin/siege.config ln -s /usr/local/siege-404/bin/siege.config /usr/bin/siege.config ln -s /usr/local/siege-404/bin/siege /usr/local/bin/siege ln -s /usr/local/siege-404/bin/siege /usr/bin/siege 二、常用命令介绍 2.1 Siege命令常用参数 -c 200 指定并发数200 -r 5 指定测试的次数5 -f urls.txt 制定url的文件 -i internet系统,随机发送url -b 请求无需等待 delay=0 -t 5 持续测试5分钟, 如果需要精确掉秒 -t 5S # -r和-t一般不同时使用 例子: # 200个并发对http://www.baidu.com发送请求100次 siege -c 200 -r 100 http://www.baidu.com # 随机选取urls.txt中列出所有的网址,200迸发 执行100次 siege -c 200 -r 100 -f urls.txt # 随机选取urls.txt中列出所有的网址 siege -c 200 -r 100 -f urls.txt -i #delay=0,更准确的压力测试,而不是功能测试 siege -c 200 -r 100 -f urls.txt -i -b # 指定http请求头 文档类型 siege -H "Content-Type:application/json" -c 200 -r 100 -f urls.txt -i -b # 在urls.txt 中PSOT类型的请求 http://www.baidu.com/index POST p1=v1&p2=v2 注释: POST参数之间用&符连接,K=V形式 如果url中含有空格和中文,要先进行url编码,否则siege发送的请求url不准确 输出结果介绍: HTTP/1.1 200 0.01 secs: 69 bytes ==> POST http://www.baidu.com/index HTTP/1.1 200 0.01 secs: 69 bytes ==> POST http://www.baidu.com/index HTTP/1.1 200 0.00 secs: 69 bytes ==> POST http://www.baidu.com/index HTTP/1.1 200 0.00 secs: 69 bytes ==> POST http://www.baidu.com/index HTTP/1.1 200 0.00 secs: 69 bytes ==> POST http://www.baidu.com/index HTTP/1.1 200 0.00 secs: 69 bytes ==> POST http://www.baidu.com/index HTTP/1.1 200 0.00 secs: 69 bytes ==> POST http://www.baidu.com/index Transactions: 25500 hits (请求数) Availability: 100.00 % (成功次数百分比) Elapsed time: 68.42 secs (总共耗时多少秒) Data transferred: 1.68 MB (总共数据传输) Response time: 0.48 secs (响应耗时) Transaction rate: 372.70 trans/sec (平均每秒处理请求数) Throughput: 0.02 MB/sec (吞吐率) Concurrency: 179.11 (最高并发) Successful transactions: 25500 (成功的请求数) Failed transactions: 0 (失败的请求数) Longest transaction: 15.12 Shortest transaction: 0.00 三、使用参数介绍 $ siege --help SIEGE 4.0.4 Usage: siege [options] siege [options] URL siege -g URL Options: -V, --version VERSION, prints the version number. -h, --help HELP, prints this section. -C, --config CONFIGURATION, show the current config. -v, --verbose VERBOSE, prints notification to screen. -q, --quiet QUIET turns verbose off and suppresses output. -g, --get GET, pull down HTTP headers and display the transaction. Great for application debugging. -p, --print PRINT, like GET only it prints the entire page. -c, --concurrent=NUM CONCURRENT users, default is 10 -r, --reps=NUM REPS, number of times to run the test. -t, --time=NUMm TIMED testing where "m" is modifier S, M, or H ex: --time=1H, one hour test. -d, --delay=NUM Time DELAY, random delay before each requst -b, --benchmark BENCHMARK: no delays between requests. -i, --internet INTERNET user simulation, hits URLs randomly. -f, --file=FILE FILE, select a specific URLS FILE. -R, --rc=FILE RC, specify an siegerc file -l, --log[=FILE] LOG to FILE. If FILE is not specified, the default is used: PREFIX/var/siege.log -m, --mark="text" MARK, mark the log file with a string. between .001 and NUM. (NOT COUNTED IN STATS) -H, --header="text" Add a header to request (can be many) -A, --user-agent="text" Sets User-Agent in request -T, --content-type="text" Sets Content-Type in request --no-parser NO PARSER, turn off the HTML page parser --no-follow NO FOLLOW, do not follow HTTP redirects 赞 0 分享 赏 您可以选择一种方式赞助本站 支付宝扫码赞助 BraveDu 署名: 网络副手~寻路人