美文网首页
How to run JMeter and monitor se

How to run JMeter and monitor se

作者: 爱吃葡萄冰的鲸 | 来源:发表于2017-04-21 10:41 被阅读54次

    Pre-configuration

    JMeter

    1. Download JDK and configure Java Environment Variables
    2. Download JMeter zip file for windows.
    3. Unzip JMeter in certain dir, for example, D:\apache-jmeter-3.1
    4. Run JMeter
    • Open cmd.exe > change direction to D:\apache-jmeter-3.1\bin > jmeter > Enter.
    • Or open folder by GUI > D:\apache-jmeter-3.1\bin > Double click jmeter.bat.

    JMeter Plug-ins

    1. Download JMeter Plugins Manager.
    2. Copy and paste it into D:\apache-jmeter-3.1\lib\ext.
    3. Run Jmeter > Options > you will see Plugins Manager.
    4. Install Throughput Sharing Timer
    • Plugin Manager > Throughput Sharing Timer, PerfMon, jpgc-Standard Set > Apply changes and Restart JMeter.
    1. Test Plan > Add > Threads(Users) > Ultimate Thread Group.
    2. Right click Ultimate Thread Group > Add > Listener > PerfMon.
    3. Click jp@gc - PerfMon Metrics Controller > Add Row
      | Host/IP | Port | Metrics to collect | Metrics parameter |
      | ---------- | ----- | ----------------------- | ------------------------ |
      | wechat-dev2.vod309.com | 39800(you defined in serverAgent) | CPU | combined |
      | wechat-dev2.vod309.com | 39800(you defined in serverAgent) | Memory | usedperc |
      | wechat-dev2.vod309.com | 39800(you defined in serverAgent) | Network/IO | iface=eth0:unit=mb:bytessent |
      | wechat-dev2.vod309.com | 39800(you defined in serverAgent) | Disks/IO | queue |

    PerfMonServerAgent

    1. Download PerfMonServerAgent, unzip and copy the folder to certain directory in your server.
    2. Start agent: sudo sh ./startAgent.sh --udp-port 0 --tcp-port 39800

    JMeter scripts

    1. Right click "Test Plan" > Add > Threads(Users) > jp@gc - Ultimate Thread Group.
    2. Right click "jp@gc - Ultimate Thread Group" > Add > Config Element > HTTP Header Manager.
    • Name: Content-Type
    • Value: application/json;charset=utf-8
    1. If requests has the same request parameter, right click "jp@gc - Ultimate Thread Group" > Add > Config Element > HTTP Request Defaults.
    1. Right click "jp@gc - Ultimate Thread Group" > Add > Listener > View Result Tree.
    2. Right click "jp@gc - Ultimate Thread Group" > Add > Listener > Aggregate Report.
    3. Right click "jp@gc - Ultimate Thread Group" > Add > Listener > jp@gc - PerfMon Metrics Collector.
    4. Right click "jp@gc - Ultimate Thread Group" > Add > Sampler > HTTP request. Make sure requests is after the HTTP Header Manager,HTTP Request Defaults.
    5. Input full URL in browser and load the page, right click blank area to select "Inspect > NetWork > check Preserve log > XHR > select the request > Headers", collect information from the inspector.
    • GET

      • Method: GET
      • Path: (your path such as '/wechat-crmapp-perf/api/account/professional/list')
      • Parameters: (Headers > General > Request URL), check "Encode?"
    • POSTMethod: POST

      • Path: (your path such as '/wechat-crmapp-perf/api/account/professional/list')
      • Body Data: (Headers > General > Form Data > view source), copy and paste.
      • (Optional, this is for form post)New a HTTP Header Manager under post request, set Name:Content-Type and Value:application/x-www-form-urlencoded; charset=UTF-8.
    1. Click jp@gc - Ultimate Thread Group to set group parameters
    • Start Threads Count : total number of threads you want to run
    • Initial Dely,sec :
    • Startup time : time to start a thread
    • Hold Load For,sec : total run time of script
    • Shutdown Time : time to shutdown a thread
    1. Login server, change directory to PerfMonServerAgent, execute sudo sh ./startAgent.sh --udp-port 0 --tcp-port 39800 to start serverAgent.
    2. Click Run on the top menu or green play button to run your test plan.
    3. Click View Result Tree > select a request > Response data, compare it with NetWork > XHR > Response to check if request is really responsed successfully.
    4. Click Aggregate Report to monitor average, min, max and other statistics of thread group.
    5. Click jp@gc - PerfMon Metrics Collector to monitor your server behaviour.

    相关文章

      网友评论

          本文标题:How to run JMeter and monitor se

          本文链接:https://www.haomeiwen.com/subject/ccyhbttx.html