引言
JMeter的 PerfMonMetricsCollector
插件支持收集服务器的性能指标,但是我们很少使用它,因为它收集起来的性能损耗太大了,另外,我们也需要收集JMeter的测试结果数据,在上文中,我们已经可以使用inflluxDB来存储性能测试结果,因此,我们也可以将服务器的性能数据存储到influxDB,那么通过Grafana我们可以实时得到一个炫酷的可视化看板。
目标
收集Linux APP服务器的性能指标:
- cpu
- disk
- disk.io
- processes
- swap memory usage
- memory usage
- system load and uptime
- network interface usage
- inodes usage
解决方案
Telegraf
除非我自己修改JMeter源码,否则JMeter不会把收集的性能数据持久化到数据库的,但这样的成本太高,因此,我们选择更简单成本低的Telegraf作为采集服务。
Telegraf 是一个用 Go 编写的代理程序,可收集系统和服务的统计数据,并写入到InfluxDB 数据库。Telegraf 具有内存占用小的特点,通过插件系统可轻松添加支持其他服务的扩展。
TICK家族
官网地址:https://www.influxdata.com/time-series-platform/telegraf/
整体设计
Telegraf&InfluxDB集成
下载安装
1. [root@zuozewei ~]# wget https://dl.influxdata.com/telegraf/releases/telegraf-1.7.4-1.x86_64.rpm
2. [root@zuozewei ~]# yum localinstall telegraf-1.7.4-1.x86_64.rpm
创建influxDB用户和数据库
1. [root@zuozewei ~]# influx
2. Connected to http://localhost:8086 version 1.6.2
3. InfluxDB shell version: 1.6.2
4. > create user "telegraf" with password 'telegraf'
5. > create database telegraf
6. > show databases
7. name: databases
8. name
9. ----
10. _internal
11. jmeter
12. demo
13. test
14. 7dgroup
15. telegraf
16. > exit
配置Telegraf
1. [root@zuozewei ~]# vim /etc/telegraf/telegraf.conf
2. # Configuration for sending metrics to InfluxDB
3. [[outputs.influxdb]]
4. ## The full HTTP or UDP URL for your InfluxDB instance.
5. urls = ["http://127.0.0.1:8086"]
6.
7. ## The target database for metrics; will be created as needed.
8. database = "telegraf"
9.
10. ## Name of existing retention policy to write to. Empty string writes to
11. ## the default retention policy. Only takes effect when using HTTP.
12. retention_policy = ""
13.
14. ## Timeout for HTTP messages.
15. timeout = "5s"
16.
17. ## HTTP Basic Auth
18. username = "telegraf"
19. password = "telegraf"
启动Telegraf
1. [root@zuozewei ~]# systemctl start telegraf
查看数据
1. [root@zuozewei ~]# influx
2. Connected to http://localhost:8086 version 1.6.2
3. InfluxDB shell version: 1.6.2
4. > use telegraf
5. Using database telegraf
>
1. > show measurements
2. name: measurements
3. name
4. ----
5. cpu
6. disk
7. diskio
8. kernel
9. mem
10. processes
11. swap
12. system
性能数据已经成功保存~
InfluxDB&Grafana集成
Grafana新建数据源
下载看板模板
搜索看板模板
官方看板模板库:https://grafana.com/dashboards
选择需要下载的看板模板
下载看板模板
此看板地址:https://grafana.com/dashboards/79
Grafana导入模板
选择Telegraf数据源
最后来张监控效果高清大图
其他看板模板效果图
模板地址:https://grafana.com/dashboards/1443
相关系列: