前言
我们做性能测试的时候,不仅要关注jmter上的测出来的TPS值和响应时间等指标,还得关注服务器的性能指标。
服务器上性能指标如何监控呢,可以安装PerfMon服务器代理来监控
PerfMon服务器代理
PerfMon服务器代理的github地址https://github.com/undera/perfmon-agent,可以下载到安装包
ServerAgent-2.2.3.zip下载地址 https://github.com/undera/perfmon-agent/releases/download/2.2.3/ServerAgent-2.2.3.zip
下载完成后,上传到我们压测环境的服务器上,新建一个PerfMon文件夹,把安装包放到PerfMon目录
可以在windows上下载了上传到服务器上,也可以直接在服务器上wget下载
wget https://github.com/undera/perfmon-agent/releases/download/2.2.3/ServerAgent-2.2.3.zip
下载后解压文件
[root@VM_0_2_centos ~]# mkdir Perfmon
[root@VM_0_2_centos ~]# cd Perfmon/
[root@VM_0_2_centos Perfmon]# wget https://github.com/undera/perfmon-agent/releases/download/2.2.3/ServerAgent-2.2.3.zip
[root@VM_0_2_centos Perfmon]# unzip ServerAgent-2.2.3.zip
[root@VM_0_2_centos Perfmon]# cd ServerAgent-2.2.3/
[root@VM_0_2_centos ServerAgent-2.2.3]# ll
total 176
-rw-rw-r-- 1 root root 10782 Aug 8 2017 CMDRunner.jar
drwxr-xr-x 2 root root 4096 Aug 8 2017 lib
-rw-rw-r-- 1 root root 85433 Aug 8 2017 LICENSE
-rw-rw-r-- 1 root root 67195 Aug 8 2017 ServerAgent.jar
-rwxr-xr-x 1 root root 63 Aug 8 2017 startAgent.bat
-rwxr-xr-x 1 root root 74 Aug 8 2017 startAgent.sh
[root@VM_0_2_centos ServerAgent-2.2.3]# ./startAgent.sh
INFO 2020-12-24 23:03:42.523 [kg.apc.p] (): Binding UDP to 4444
INFO 2020-12-24 23:03:43.602 [kg.apc.p] (): Binding TCP to 4444
INFO 2020-12-24 23:03:43.624 [kg.apc.p] (): JP@GC Agent v2.2.3 started
执行./startAgent.sh 启动服务,当看到如下提示,说明启动成功
[root@VM_0_2_centos ServerAgent-2.2.3]# ./startAgent.sh
INFO 2020-12-24 23:03:42.523 [kg.apc.p] (): Binding UDP to 4444
INFO 2020-12-24 23:03:43.602 [kg.apc.p] (): Binding TCP to 4444
INFO 2020-12-24 23:03:43.624 [kg.apc.p] (): JP@GC Agent v2.2.3 started
默认监听的UDP和TCP端口是4444, 服务正常启动后,在自己windows本地用telnet端口能不能连得通
telnet ip 4444
我自己本地的windows电脑一直连不上这个4444端口,不知道为啥
如果4444端口连不上,可以换个端口重新启动,带上-udp-port 和 --tcp-port两个参数
[root@VM_0_2_centos ServerAgent-2.2.3]# ./startAgent.sh --udp-port 3456 --tcp-port 3456
INFO 2020-12-24 23:32:11.661 [kg.apc.p] (): Binding UDP to 3456
INFO 2020-12-24 23:32:12.696 [kg.apc.p] (): Binding TCP to 3456
INFO 2020-12-24 23:32:12.709 [kg.apc.p] (): JP@GC Agent v2.2.3 started
再重新telnet ip 3456
端口就能连上了
jmeter监听器jp@gc - PerfMon Metrics Collector
首先在插件管理Available Plugins里面搜索:PerfMon,看有没有安装,已经安装过的话,在Installed Plugins搜得到
关于插件管理,可以参考前面的文章https://www.cnblogs.com/yoyoketang/p/14180667.html
添加-监听器-jp@gc - PerfMon Metrics Collector
配置需要监控的性能指标,我这里配置了CPU和Memory
运行压测脚本就能看到服务器的性能指标了
原文地址https://www.cnblogs.com/yoyoketang/tag/jmeter/,转载请注明出处!