jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thibaut Raballand <thibaut.raball...@gmail.com>
Subject Re: Effectively monitoring target resources with jmeter?
Date Wed, 24 Feb 2010 09:45:57 GMT
Hi,

Yeh, well, I could sell you this stuff ;) Some little piece of code are
quite big value added sometimes!
Just joking, I guess my company won't reclaim the ownership if 20 lines of
Java code.

Creating a listener allows to get the result in the DB during the tests.
That way, you're able to watch the good running of your tests, the graphs in
real time etc.
Way better than having a CSV to parse afterwards I believe !

Here it is :
1 - Put a Beanshell sample in a run-once controller at the beginning of your
test to create the MySQL / Oracle / Whatever configuration.
    ----- You could maybe use the JDBC configuration sample if there is a
way to gain access to the pool in Beanshell

import java.sql.DriverManager;
> import java.sql.Connection;
> import java.sql.SQLException;
> import java.sql.Statement;
>
> Class.forName("com.mysql.jdbc.Driver");
> c = DriverManager.getConnection("jdbc:mysql://10.68.138.205/BenchV6-V7","root",
> "root");
>
> if(c!=null){
>     IsSuccess=true;
>     SampleResult.setResponseData("Connexion à MySQL réussie");
>
> Statement ps = c.prepareStatement("INSERT INTO SP_Result
> (Tir,Scenario,Username,Version,Injecteur,Thread,
> StartTime,Sample,ElapsedTime,Size,Success,RequestData,ResponseData) VALUES
> ('"+vars.get("key")+"','"+vars.get("Scenario")+"',?,'"+vars.get("Version")+"','${__machineName()}',${__threadNum()},?,?,?,?,?,?,?)");
>
> vars.putObject("SaveDBStatement",ps);
>
> }
> else{
>     IsSuccess=false;
>     SampleResult.setResponseData("Erreur dans la connexion à MySQL");
> }
>

As you can see, i create inside the PreparedStatement that I'll use to save
to DB in the listener.

2 - Create a Beanshell Listener that get the result of each sample and save
that to DB.
----- In my tests, I do save anymore in CSV or XML
----- Beware of the number of concurrent users your DB accepts => must be >
to the number of JMeter threads you're running

import java.sql.Connection;
> import java.sql.Statement;
> import java.text.SimpleDateFormat;
> import java.util.Date;
>
> dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
>
> Statement ps=(Statement) vars.getObject("SaveDBStatement");
>
> //StartTime,Sample,ElapsedTime,Size,Success
>
> ps.setString(1, "Demon");
> ps.setString(2, dateFormat.format(new Date(sampleResult.getStartTime())));
> ps.setString(3, sampleResult.getSampleLabel());
> ps.setLong(4, sampleResult.getTime());
> ps.setInt(5, sampleResult.getBytes());
>
> if(sampleResult.isSuccessful()){
>     ps.setInt(6, 1);
> }
> else{
>     ps.setInt(6, 0);
> }
>
> if(vars.get("Debug").equals("1")){
>     ps.setString(7, sampleResult.getSamplerData());
>     ps.setString(8, sampleResult.getResponseDataAsString());
> }
> else{
>     ps.setString(7,"");
>     ps.setString(8,"");
> }
>
> ps.executeUpdate();
>

Here it is, hope I'll get it working on your side.
As you see, I got a 'global' variable "Debug" that let me save/or not save
the contents of the request and response in the DB.


As for the CPU/stuff collection, I use a script implementing the Perl
library Sys.Internals.Linux, and sending it to my DB.
Homemade again.


Regards,
Tibo

On Wed, Feb 24, 2010 at 03:12, James Hill <everywherenet@gmail.com> wrote:

> Yeah I know. My tests save in CSV format. I then use SQL to load the data
> into a DB and analyse results from there with some basic queries. I'm
> interested in finding out how others are doing it, particularly if they're
> automating the task via JMeter.
>
> On Wed, Feb 24, 2010 at 10:40 AM, Deepak Shetty <shettyd@gmail.com> wrote:
>
> > >Could you go into a little more detail about how you use a listener to
> > write
> > >data to the DB
> > you dont need a listener, you can do it after the test has run.
> > If your result file is CSV this is trivial. If XML then its fairly easy
> to
> > parse and insert.
> >
> > On Tue, Feb 23, 2010 at 2:55 PM, James Hill <everywherenet@gmail.com>
> > wrote:
> >
> > > Could you go into a little more detail about how you use a listener to
> > > write
> > > data to the DB? I've been looking at doing it as part of the Ant task
> > that
> > > calls JMeter but if there's an easier way I'd love to find it :)
> > >
> > > Also, what do you use to collect load/mem/cpu usage from the servers?
> I'm
> > > considering sar to do this, but seeing as there's an existing license
> for
> > > Spotlight on Unix I'm not sure I need to (seeing as it collects that
> info
> > > anyway). However, it could be handy for another project where SoU isn't
> > in
> > > use.
> > >
> > > I like the idea of the php website to collate and display the results.
> > When
> > > I have some spare time I'd like to put together a USB drive with
> JMeter,
> > > MySQL and relevant scripts and howto's that can be used on just about
> any
> > > site I end up at. Simplify the startup time. As you point out Thibaut,
> it
> > > takes time to get to that point but it must save a lot of hassle in the
> > > long
> > > run.
> > >
> > > On Wed, Feb 24, 2010 at 1:58 AM, Thibaut Raballand <
> > > thibaut.raballand@gmail.com> wrote:
> > >
> > > > Hi,
> > > >
> > > > As for us,
> > > > - We send the results of each run directly from JMeter to a mysql DB
> > > (with
> > > > a
> > > > listener)
> > > > - We collect load / mem / cpu usage from the servers to the same DB
> > > > automatically
> > > > - We have a PHP web site the correlate automatically those datas
> > > >
> > > > Sure, you need some time to put all this up and running, but it's
> worth
> > > it.
> > > >
> > > > Regards,
> > > > Tibo
> > > >
> > > > On Tue, Feb 23, 2010 at 14:45, Brett Cave <brettcave@gmail.com>
> wrote:
> > > >
> > > > > hi,
> > > > >
> > > > > been using jmeter for a few weeks now, and wondering how other
> users
> > > > > correlate target load / mem / cpu usage into jmeter reporting? My
> > > current
> > > > > method is to enable SNMP and use a seperate RRD-tool based system
> to
> > > > > generate graphs, and then correlate the target resource usage with
> > the
> > > > load
> > > > > injection manually. This is a manual process, and i would like to
> get
> > > > data
> > > > > specific to each test i run (load testing currently runs a number
> of
> > > > tests,
> > > > > 1 by 1).
> > > > >
> > > > > Regards,
> > > > > Brett
> > > > >
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message