Jmeter Perfmon metrics collector graph - Jenkins

823 views
Skip to first unread message

reut....@gmail.com

unread,
Jul 6, 2016, 4:45:53 AM7/6/16
to jmeter-plugins
Hi ,

I need your help with addig more graph to jenkins dashboard:

How to view Jmeter Perfmon metrics collector graph via Jenkins dashboard ?

Thanks,
Reut.

Auro

unread,
Jul 6, 2016, 7:22:21 AM7/6/16
to jmeter-plugins, reut....@gmail.com
In jenkins use HTML publisher plugin and create an html page to load png charts generated via shell:


E.G.
java -Djava.awt.headless=true -jar CMDRunner.jar --tool Reporter --generate-png $CHARTSDIR/RESPONSE_TIME$ID.png --input-jtl $JTLFILE --plugin-type ResponseTimesOverTime --exclude-labels 'JDBC Request','UID Generator' --include-labels "T.*" --include-label-regex true --width 1600 --height 1200 --granulation 30000 --relative-times no

Vincent Daburon

unread,
Jul 6, 2016, 9:29:47 AM7/6/16
to jmeter-plugins, reut....@gmail.com
Hi,

I use a free jenkins job to create more graphs, perfmon graphs for this example :
some parameters are declare for this job like :
JM_DIR_RES=result
JMETER_HOME=/products/jmeter2.13-jp1.31
IMAGE_WIDTH=800
IMAGE_HEIGHT=600

# Generate Perfmon's graphs

export JAVA_HOME=/products/jdk1.7.0_51

export REP_RES=$WORKSPACE/$JM_DIR_RES/image

cd $JMETER_HOME

# fichier des logs de monitoring Perfmon
FILE_JTL=$WORKSPACE/$JM_DIR_RES/perfmon.jtl

$JAVA_HOME/bin/java -jar lib/ext/CMDRunner.jar --tool Reporter --generate-png $REP_RES/Perfmon_CPU.png --input-jtl $FILE_JTL  --plugin-type PerfMon  --width $IMAGE_WIDTH --height $IMAGE_HEIGHT --limit-rows 100 --force-y 100 --auto-scale no --relative-times no --include-labels ".*CPU.*" --include-label-regex true

$JAVA_HOME/bin/java -jar lib/ext/CMDRunner.jar --tool Reporter --generate-png $REP_RES/Perfmon_Disk.png --input-jtl $FILE_JTL  --plugin-type PerfMon  --width $IMAGE_WIDTH --height $IMAGE_HEIGHT --limit-rows 100 --auto-scale no --relative-times no --include-labels ".*Disk.*" --include-label-regex true

Regards
Vincent D.

Auro

unread,
Jul 6, 2016, 9:49:32 AM7/6/16
to jmeter-plugins, reut....@gmail.com
Ok, now add a build step "execute shell" to create an html page table with your images inside:

something like

###### HTML CHARTS REPORT ######
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
 \"http://www.w3.org/TR/html4/loose.dtd\">
<html>

  <body>
    <table align=\"center\" border=\"1\">
      <tbody>" > $OUTPUTDIR/$HTML_FILE
     

for i in $IMAGE_SET
do
   echo "<tr><td>$i                             </td> <td><img src=\"$i.png\" height=\"600\" width=\"600\" /></td></tr>" >> $OUTPUTDIR/$HTML_FILE
done

echo "</table>
    &nbsp;
  </body>
</html>" >> $OUTPUTDIR/$HTML_FILE


after that you can load the html page using the html publisher plugin

Vincent Daburon

unread,
Jul 7, 2016, 5:12:30 AM7/7/16
to jmeter-plugins, reut....@gmail.com
Hi,

I use a simple java class to generate a html page with links to images and csv files
script shell to call the generator
==============================================================
rem launch generate html
set JAVA_HOME=D:\jdk1.7.0_75

rem %1 = dirRead contains image or csv files
rem %2 = dirOut where create the %3 file
rem %3 = fileOut for example index.html

cd /D %~dp0

%JAVA_HOME%\bin\java -jar htmlgraph.jar %1 %2 %3
=============================================================
In jenkins windows script shell
%WORKSPACE%\utils\launch_generate_html.bat %WORKSPACE%/image %WORKSPACE%/image index.html
==============================================================
package org.mypackage.tools;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

/**
 *
 * @author Vincent Daburon
 */
public class HtmlGraphVisualizationGenerator {

    // CRLF or LF or CR
    public static final String LINE_SEP = System.getProperty("line.separator");
   
    // array of supported extensions
    static final String[] EXTENSIONS = new String[] { "gif", "png", "bmp", "jpg", "csv" };
    // filter to identify images based on their extensions
    static final FilenameFilter EXTENSION_FILTER = new FilenameFilter() {

        @Override
        public boolean accept(final File dir, final String name) {
            for (final String ext : EXTENSIONS) {
                if (name.endsWith("." + ext)) {
                    return (true);
                }
            }
            return (false);
        }
    };


    public static void main(String[] args) {
       
        if (args.length != 3) {
            System.err.println("Usage HtmlGraphVisualizationGenerator dirRead dirOut fileOutHtml");
            System.exit(1);
        }
        String dirRead = args[0];
        String dirOut =args[1];
        String fileOutHtml =args[2];
       
       
        File folderRead = new File(dirRead);
        File folderOut = new File(dirOut);
       
        if (!folderOut.isDirectory()) {
            if (folderOut.exists()) {
                System.err.println(dirOut + "  is not a directory");
            }
            else {
                folderOut.mkdirs();
            }
        }
       
        Object tabFiles[] = listFileOrderByName(folderRead);
       
        BufferedWriter out = null;
        try {
            out = new BufferedWriter(new FileWriter(new File(dirOut + "/" + fileOutHtml)));

            System.out.println("Generating " + fileOutHtml + " ...");

            out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
            out.write(LINE_SEP);
            out.write("<html>");
            out.write(LINE_SEP);
            out.write("<head>");
            out.write(LINE_SEP);
            out.write("<title>Graphs generated with JMeter Plugins</title>");
            out.write(LINE_SEP);
            out.write("</head>");
            out.write(LINE_SEP);
            out.write("<body><br/><br/>");
            out.write(LINE_SEP);

            out.write("<h1> Generated date " + new java.util.Date().toString() + "</h1><br/>");
            out.write(LINE_SEP);
           
            for (int i = 0; i < tabFiles.length; i++) {
                File f = (File) tabFiles[i];
                out.write("<h2>" + f.getName() + "</h2><br/>");
                out.write(LINE_SEP);
                String name = f.getName();
                if (name.endsWith("csv")) {
                    out.write("<a href='" + f.getName() + "'>" + f.getName() + "</a><br/><br/>");
                }
                else {
                    // image
                    out.write("<img src='" + f.getName() + "'><br/><br/>");
                    out.write(LINE_SEP);
                }
            }
           
            out.write(LINE_SEP);
            out.write("</body>");
            out.write(LINE_SEP);
            out.write("</html>");

            System.out.println("Done!");

        } catch (final Exception e1) {
            System.out.println(e1.getMessage());

        } finally {
            if (null != out) {
                try {
                    out.close();
                } catch (IOException e2) {
                    System.out.println(e2.getMessage());
                }
            }
        }
    }
   
    public static Object[] listFileOrderByName(File folderRead) {
        ArrayList<File> aList = new ArrayList<File>();
       
        if (folderRead.isDirectory()) { // make sure it's a directory
            for (final File f : folderRead.listFiles(EXTENSION_FILTER)) {
                aList.add(f);
            }
        }
       
        Object tabFiles[] = aList.toArray();
       
        Arrays.sort(tabFiles , new FileNameComparator());
        return tabFiles;
    }
   

}

=======================================================================
package org.mypackage.tools;

import java.io.File;
import java.util.Comparator;

public class FileNameComparator implements Comparator {
    public int compare(Object obj1, Object obj2) {

        if (obj1 instanceof File) {
            String name1 = ((File) obj1).getName();
            String name2 = ((File) obj2).getName();
            return name1.compareTo(name2);
        }
        return 0;
    }

}
======================================================
Regards.
Vincent D.

reut....@gmail.com

unread,
Jul 7, 2016, 10:32:13 AM7/7/16
to jmeter-plugins, reut....@gmail.com
Thank you all!!!
it works :)

arvi...@gmail.com

unread,
Mar 18, 2019, 10:13:20 AM3/18/19
to jmeter-plugins
Hello,
Could you please share the solution that worked for you!!
I mean whats the code you used to display the Perfmon metrics on Jenkins?

shreeji...@gmail.com

unread,
Jun 24, 2019, 3:31:43 PM6/24/19
to jmeter-plugins
I am also looking for a solution to retrieve the charts in Jenkins directly from the perf mon output.csv
The only option I see is to load the csv back into Jmeter GUI and view the charts.
How do we get the csv converted to a graph (showing CPU / Memory / Disk stats) without manually importing the file back into Jmeter.

Vincent Daburon

unread,
Jun 25, 2019, 7:58:30 AM6/25/19
to jmeter-plugins
Hi,
All informations are in previously reponses.
Read all responses of this current topic

Regards
Vincent DAB.

ruth...@gmail.com

unread,
Aug 13, 2019, 6:06:07 PM8/13/19
to jmeter-plugins
When you click on Perfmon - Configure button, for those for whose it working.. What is setup?

And when you try to read log through Perfmon  Browse dialog, can be graph visualized after test? I had everytime problem with it.
Reply all
Reply to author
Forward
0 new messages