How to incorporate perfmon (plugin) stats into the standard JMeter report

51 Views Asked by At

I'm using the perfmon plugin within JMeter to collect stats like CPU usage and would like to display this in a custom (over time) graph in the standard JMeter HTML report.

So far I have a custom graph which allows me to display any variable I like from the test script. However the problem seems to be that I can't pass samples from the perfmon collector to a variable in order to get them on the graph.

I suspect the problem may be that the custom graphs are geared around using a SAMPLER, whereas the perfmon plugin is a LISTENER.

I realise the perfmon listener can also output to a CSV file but isn't there a way to extract values from the perfmon listener which would facilitate usage on a custom graph?

Is there another way to sample the CPU usage which makes the information available to custom graphs in the HTML report?

1

There are 1 best solutions below

0
Dmitri T On

It looks like your colleague has asked the identical question yesterday

  1. Add the next lines to user.properties file:

    sample_variables=cpu
    jmeter.reportgenerator.graph.custom_testGraph.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
    jmeter.reportgenerator.graph.custom_testGraph.title=CPU Usage
    jmeter.reportgenerator.graph.custom_testGraph.property.set_Y_Axis=CPU Usage %
    jmeter.reportgenerator.graph.custom_testGraph.set_X_Axis=Over Time
    jmeter.reportgenerator.graph.custom_testGraph.property.set_granularity=60000
    jmeter.reportgenerator.graph.custom_testGraph.property.set_Sample_Variable_Name=cpu
    jmeter.reportgenerator.graph.custom_testGraph.property.set_Content_Message=CPU Usage :
    
  2. Add JSR223 Listener to your Test Plan and put the following code there:

    def s = new Socket("your-system-under-test-ip-or-hostname", 4444);
    s.setSoTimeout(3000);
    s << "metrics-single:cpu\n";
    s.withStreams { inStream, outStream ->
      def reader = inStream.newReader()
      def response = reader.readLine()
      vars.put('cpu', response)
    }
    s.close()
    

This way when a Sample occurs the JSR223 Listener will query the Server Agent for CPU usage and store the value into cpu variable. The variable values for each Sampler will be added to the .jtl results file and you will be able to plot them over your test execution time span.

More information: