另一篇
https://blog.csdn.net/dataiyangu/article/details/88851898
部署demo
在机器上部署自己的用于测试的demo,我就是直接在tomcat下安装的
写脚本
通过书写grovy脚本访问自己的demo。
将写好的grovy脚本上传拿到ngrinder
压力测试
脚本:指向刚才的脚本,通过这个脚本不断的去访问自己的demo
目标主机:即自己刚才部署的demo的机器ip
如此便关联起来了
目标主机监控
在目标主机上同样需要一个监控的脚本
最后生成监控的日志
具体脚本是机密。
可能报错
java.net.ConnectException: Connection refused (Connection refused)
at HTTPClient.HTTPConnection$EstablishConnection.run(HTTPConnection.java:4082) ~[grinder-httpclient-3.9.1.jar:na]
2019-05-06 18:25:32,124 INFO shut down
2019-05-06 18:25:32,124 INFO finished 1011 runs
2019-05-06 18:25:32,124 INFO shut down
2019-05-06 18:25:32,124 INFO finished 1015 runs
2019-05-06 18:25:32,124 ERROR Connection refused (Connection refused)
java.net.ConnectException: Connection refused (Connection refused)
at HTTPClient.HTTPConnection$EstablishConnection.run(HTTPConnection.java:4082) ~[grinder-httpclient-3.9.1.jar:na]
2019-05-06 18:25:32,124 ERROR Connection refused (Connection refused)
java.net.ConnectException: Connection refused (Connection refused)
at HTTPClient.HTTPConnection$EstablishConnection.run(HTTPConnection.java:4082) ~[grinder-httpclient-3.9.1.jar:na]
2019-05-06 18:25:32,124 INFO shut down
2019-05-06 18:25:32,124 INFO finished 1030 runs
2019-05-06 18:25:32,124 INFO shut down
2019-05-06 18:25:32,124 INFO finished 1020 runs
2019-05-06 18:25:32,125 ERROR Connection refused (Connection refused)
java.net.ConnectException: Connection refused (Connection refused)
at HTTPClient.HTTPConnection$EstablishConnection.run(HTTPConnection.java:4082) ~[grinder-httpclient-3.9.1.jar:na]
2019-05-06 18:25:32,125 INFO shut down
2019-05-06 18:25:32,125 INFO finished 1035 runs
2019-05-06 18:25:32,130 ERROR Connection refused (Connection refused)
java.net.ConnectException: Connection refused (Connection refused)
at HTTPClient.HTTPConnection$EstablishConnection.run(HTTPConnection.java:4082) ~[grinder-httpclient-3.9.1.jar:na]
2019-05-06 18:25:32,130 INFO shut down
2019-05-06 18:25:32,130 INFO finished 1014 runs
2019-05-06 18:25:32,136 INFO elapsed time is 13916 ms
2019-05-06 18:25:32,136 INFO Final statistics for this process:
2019-05-06 18:25:32,145 INFO
Tests Errors Mean Test Test Time TPS Mean Response Response Mean time to Mean time to Mean time to
Time (ms) Standard response bytes per errors resolve host establish first byte
Deviation length second connection
(ms)
Test 1 0 25622 � 0.00 0.00 � 0.00 0 � � � "Test_SelfDemo"
Totals 0 25622 � 0.00 0.00 � 0.00 0 � � �
运行压力测试的时候报错如上,Connection refused,就是我的tomcat长时间没有动它,自己挂掉了,所以Connection refused,郁闷。
总结:
ngrinder的作用就是主要用来不断的发送请求的(搭配上脚本效果更好),当然在最后测试完成的时候也会有监控的信息,但是粒度比较粗,也能满足需求,而我们目标主机上的脚本就是专门用来监控请求时候的主机cpu 等信息的,当然数据库的主机也可以来一份监控脚本,做一个辅助的判断功能。