压侧工具 ngrinder 学习(发送POST JSON请求)

[python] # -*- coding:utf-8 -*- # A simple example using the HTTP plugin that shows the retrieval of a # single page via HTTP. # # This script is automatically generated by ngrinder. # # @author admin from net.grinder.script.Grinder import grinder from net.grinder.script import Test from net.grinder.plugin.http import HTTPRequest from net.grinder.plugin.http import HTTPPluginControl from HTTPClient import NVPair #导入对JSON格式返回值的处理函数 from org.json import JSONObject import sys reload(sys) sys.setdefaultencoding('utf-8') control = HTTPPluginControl.getConnectionDefaults() # if you don't want that HTTPRequest follows the redirection, please modify the following option 0. # control.followRedirects = 1 # if you want to increase the timeout, please modify the following option. control.timeout = 6000 test1 = Test(1, "api.vd.cn") request1 = HTTPRequest() # Make any method call on request1 increase TPS test1.record(request1) class TestRunner: # initlialize a thread def __init__(self): grinder.statistics.delayReports=True pass # test method def __call__(self): headers = [ NVPair("Content-Type","application/json") ] json_data='{"is_card_photo":"1","wid":"200168668","BaseAppType":"android","BaseAppVersion":"4.4.0","SystemVersion":"4.4.2","shop_id":"11433415","_sign_":"DDFDDA37A35F2CF28591FC6D18245779","_token_":"53c571f37a7e2fe64cc4d24200fdd8ca","_wid_":"200168668","appIdentifier":"com.hs.yjseller"}' #submitdata = [NVPair("a","1"),NVPair("b","2"),NVPair("c","3")] result = request1.POST("http://your ip/user/getuseraddressall", json_data, headers) # You get the message body using the getText() method. # if result.getText().find("HELLO WORLD") != -1 : # grinder.statistics.forLastTest.success = 1 # else : # grinder.statistics.forLastTest.success = 0 # if you want to print out log.. Don't use print keyword. Instead, use following. #grinder.logger.info(result.getText()) if result.getStatusCode() == 200 : grinder.statistics.forLastTest.success = 1 elif result.getStatusCode() in (301, 302) : grinder.logger.warn("Warning. The response may not be correct. The response code was %d." % result.getStatusCode()) grinder.statistics.forLastTest.success = 1 else : grinder.statistics.forLastTest.success = 1 [/python]

压侧工具 ngrinder 学习(安装)

系统环境mac 自带的java版本1.8 对java tomcat 不是很熟悉 所以直接下载 ngrinder-controller-3.2.3-with-tomcat.tar.gz ngrinder-core-3.2.3-agent-package.tar.gz 2个压缩包 直接解压 并将bin目录添加到系统环境变量 启动 startup.sh 启动代理 run_agent.sh 编辑 ~/.ngrinder_agent/agent.conf start.mode=agent agent.console.ip=please specify your controller IP #monitor.listen.port=3243 #monitor.collector.interval=1 #monitor.controller.cache.size=128 #monitor.collector.interval=1 #start.mode=agent #agent.console.port=7001 #agent.region= 重新启动代理服务 这里发现个问题 测试时无法发现代理机 导致代理为0 解决方法 在代理管理中 把代理设置为启动即可

ss服务搭建 翻墙

ss服务 代理  翻墙 服务器ubuntu14.04 lts apt-get install python-pip apt-get install python-m2crypto pip install shadowsocks mkdir /etc/shadowsocks vim /etc/shadowsocks/config.json apt-get install vim vim /etc/shadowsocks/config.json { "server":"服务器ip", "server_port":服务器端口, "local_port":本地端口, "password":"密码", "timeout":600, "method":"aes-256-cfb" } 启动 ssserver -c /etc/shadowsocks/config.json start 下载客户端 https://github.com/shadowsocks/shadowsocks/wiki/Ports-and-Clients#os-x 开启 qweqczcz C9GMKE[O$]@~QG8MCXR]651 MEZLP~QL$K`G~RC}B}EJ34B

linux下压力测试软件siege的安装与使用详解

假定: 1 centos 系统 root登录 2 siege-2.72版本 下载自:http://www.joedog.org 3 openssl 安装路径 /usr/local/ssl 4 使用人员:php开发人员 关于siege的说明请先参考http://www.joedog.org 选择siege的理由: 1 稳定 2 除了对http支持外,还支持https,并且支持的很好,apachebanch 对https支持的不够好。 3 安装简单,功能够开发测试用 一、siege的安装 cd /root/ rz tar -zxvf siege-2.72.tar.gz cd siege-2.72 ./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/ssl mkdir -p /usr/local/siege/etc/ mkdir -p /usr/local/siege/var/ make make install 创建.siegec.config配置文件到当前用户的家目录下 /usr/local/siege/bin/siege.config 安装完成 查看配置文件 /usr/local/siege/bin/siege -C CURRENT SIEGE CONFIGURATION JoeDog/1.00 [en] (X11; I; Siege 2.72) Edit the resource file to change the settings. ---------------------------------------------- version: 2.72 verbose: false debug: false protocol: HTTP/1.1 connection: close concurrent users: 15 time to run: n/a repetitions: n/a socket timeout: 30 delay: 1 sec internet simulation: false benchmark mode: false failures until abort: 1024 named URL: none URLs file: /usr/local/siege/etc/urls.txt logging: true log file: /usr/local/siege/var/siege.log resource file: /root/.siegerc timestamped output: false comma separated output: false allow redirects: true allow zero byte data: true allow chunked encoding: true proxy auth: www auth: 二、siege的使用 举例说明: 50个用户(每次并发量,注意不是每秒并发量) 重复100次 共产生 50 * 100 = 5000个请求 /usr/local/siege/bin/siege -c 50 -r 100 https://www.abc.com/a.php 50个用户 重复100次 发送GET参数 /usr/local/siege/bin/siege -c 50 -r 100 https://www.abc.com/a.php?name=zhangsan 50个用户 重复100次 发送POST参数 (注意引号) /usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST name=zhangsan" 50个用户 重复100次 发送POST参数(从文件中读取) /usr/local/siege/bin/siege -c 50 -r 100 "https://www.abc.com/a.php POST < /root/ab_test/post.xml" 另外还有发送时间参数等 详情请man 或 siege -h siege报表解析,请man查看,暂略(有点累了,不想写了。。。。。)。 常见问题见:http://www.joedog.org/siege-faq/ 原文地址 http://blog.csdn.net/yangzhenzhen/article/details/8904746