基于jmeter+sysstat+influxdb+grafana+flume的性能测试平台

大概分为两部分:发起请求、统计数据

发起请求:jmeter

统计数据:sysstat :硬件设备统计、请求并发、系统吞吐量、响应时间统计 

jmeter: qps responseTime currentThreadsNum 

收集数据:flume (分布式、稳定、安全)

数据存储:influxdb (分布式、时序、结构简单、轻便)

数据展示:grafana(与influxdb结合比较完备,可配置化、动态展示数据)



jmeter :

jmeter试压-》

增加AbstractBackendListenerClient抽象类的实现类,FileBackendListenerClient将监听器数据log4j2输出到日志文件-》

   ant-install构建打包

jmeter源码中添加包需要再lib/opt下编译才生效

运行时是读取lib包下,需要添加到lib下即可

添加后台进程,不断增量读取log日志,批量写入influxdb中

(提高性能使用线程安全的 ConcurrentLinkedDeque)

curl -i -XPOST 'http://localhost:8086/write?db=jmeter' --data-binary @jmeter_data.txt

jmeter执行流程:

jmeter在core包中org.apache.jmeter.threads.ThreadGroup.start类中开始并发线程,每个线程根据线程组生成线程树,

org.apache.jmeter.threads.JmeterThread.process_sampler递归执行每个sampler

实际执行的接口AbstractJavaSamplerClient.runTest方法,所以需要手动实现这个接口的runtest方法,返回samplerResult

分布式:jmeter master+slavers 通过RMI协议通信(默认端口1099),master把测试计划发送给每个slavers,slavers传递samplerResult给master

(所以测试计划只需要在master,但是测试数据和配置文件需要添加给每个slavers)

influxdb grafana配置:

influxdb:https://docs.influxdata.com/influxdb/v0.13/

安装:

/etc/yum.repos.d/ 下添加influxdb的安装文件 influxdb.repo

[influxdb]

name = InfluxDB Repository - RHEL \$releasever

baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable

enabled = 1

gpgcheck = 1

gpgkey = https://repos.influxdata.com/influxdb.key

启动:service influxdb start/status/restart
启动脚本目录:/etc/init.d/influxdb //启动脚本中user=influxdb 可以进行修改
config文件:/etc/influxdb/influxdb.conf //服务端口
日志:/var/log/influxdb/influxdb.log

web访问:http://ip:8083 

默认用户:root/root

connect 默认端口 8086

influxdb command line:

influx->

create/show databases

use mydb

show measurements

exit

history

drop measurement "measurementsname"

delete from measurementsname ->不支持where参数


http方式查询数据:curl -G 'http://ip:8086/query?pretty=true' --data-urlencode "db=jmeter" --data-urlencode "q=SELECT min(costtime) FROM \"jmeter.single.time\" where costtime > 0 and mark = 123" 

influxdb是以json方式返回的数据

取出值:liunx的json处理包 jq: jq '.results[0].series[0].values[0][1]'

influxdb的规则:

database-》measuremets -》

<measurement>[,<tag-key>=<tag-value>...] <field-key>=<field-value>[,<field2-key>=<field2-value>...] [unix-nano-timestamp]

timestamp 唯一索引

tag 索引

field 普通列 ,至少有一对

grafana:http://docs.grafana.org/installation/

安装:

/etc/yum.repos.d/ 下添加influxdb的安装文件 influxdb.repo

[grafana]

name=grafana

baseurl=https://packagecloud.io/grafana/stable/el/6/$basearch

repo_gpgcheck=1

enabled=1

gpgcheck=1

gpgkey=https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana

sslverify=1

sslcacert=/etc/pki/tls/certs/ca-bundle.crt

service grafana-server status/start
Installs binary to /usr/sbin/grafana-server   // 二进制文件无法查看安装文件
Copies init.d script to  /etc/init.d/grafana-server   // 启动脚本 配置文件 目录等信息
Installs default file (environment vars) to  /etc/sysconfig/grafana-server // 配置信息副本 启动用户修改
Copies configuration file to  /etc/grafana/grafana.ini
Installs systemd service (if systemd is available) name  grafana-server.service
The default configuration uses a log file at  /var/log/grafana/grafana.log
The default configuration specifies an sqlite3 database at  /var/lib/grafana/grafana.db   // 数据展示配置信息
/var/lib/grafana/sessions   用户登录session信息

web访问:http://IP:3000/login

默认用户:admin/admin

flume:数据收集

flume 的source 采用TAILDIR方式,增量读取jmeter写入的响应数据文件(缺点:执行过程中tail进程断掉,不能断点续传)

flume 的sink采用自定义sink,发http请求到influxdb,写入数据

(https://docs.influxdata.com/influxdb/v0.13/guides/writing_data/)


猜你喜欢

转载自blog.csdn.net/weilan100/article/details/51953572