Discussion:
Display User Variable in Results
Michael.OBrien
2014-03-11 15:23:34 UTC
Permalink
Hi Jmeter users,

I'd like to display or output the values of user defined variables but I've only come across instructions for re-using variables in additional http requests.

I don't see how the variable values can be graphed, charted or displayed using jmeter listeners
Is there a way for me to just dump the user variables out in View Results Tree or View Results in Table?

The test script I wish to create is to
1. Contact the website at IP address XYZ
2. Check for response code 200
3. Use RegExp to extract www\d from the body to variable RespondingMachine
4. Output and possible count each unique value of RespondingMachine


I'm using jmeter 2.11 without any extra plugins. I did find the RegExp Tester option in "View Results Tree" so my expression will work I'm just not sure how to get it to display alongside the table or tree

Anyone able to help me out?
Michael
ZK
2014-03-12 09:07:20 UTC
Permalink
Hi,
one possibility is: you could just use a debug sampler after the regular
expression extractor
this would list all the values you want to review

If you set the 'Match No.' of the Regular Expression Extractor to be -1
there will be a variable named: 'RespondingMachine_MatchNr', this would
inform you of how many matches your regEx has found

Alternately you could write some beanshell code and output the variables to
the console


ZK



--
View this message in context: http://jmeter.512774.n5.nabble.com/Display-User-Variable-in-Results-tp5719555p5719559.html
Sent from the JMeter - User mailing list archive at Nabble.com.
Michael.OBrien
2014-03-12 10:09:31 UTC
Permalink
Hi ZK,

Thanks that debug sampler shows me my reg expression is working but I'm only really interested in the total number of matches for each occurrence after the thread group has finished executing (not the number of times its found in a single thread execution) and would ideally like to chart them
Its to demo a load balancer does actually distribute the requests to different servers and I'd like to run jmeter for X threads and at the end have a chart that shows the total each server handled.

Is it possible to chart counters in jmeter?

Michael

-----Original Message-----
From: ZK [mailto:***@gmail.com]
Sent: 12 March 2014 09:07
To: jmeter-***@jakarta.apache.org
Subject: Re: Display User Variable in Results

Hi,
one possibility is: you could just use a debug sampler after the regular expression extractor this would list all the values you want to review

If you set the 'Match No.' of the Regular Expression Extractor to be -1 there will be a variable named: 'RespondingMachine_MatchNr', this would inform you of how many matches your regEx has found

Alternately you could write some beanshell code and output the variables to the console


ZK



--
View this message in context: http://jmeter.512774.n5.nabble.com/Display-User-Variable-in-Results-tp5719555p5719559.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@jmeter.apache.org
For additional commands, e-mail: user-***@jmeter.apache.org
ZK
2014-03-12 17:02:52 UTC
Permalink
Hi,
its not possible to chart counters in jmeter but could be done easily in
Excel


Another possibility would be to have a ramp up for your test i.e (10 seconds
before each thread starts (this is because you need time for the last thread
to end): so if you are running with 10 threads, have a ramp up of 100
seconds)

In your regEx extractor have the refernceName as:
RespondingMachine_${__threadNum}

then have a beanshell post processor to output to the console (or you could
change it to write to an external file)with something like:

import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.samplers.*;
import org.apache.jmeter.control.*;

currentVar= "RespondingMachine_"+${__threadNum}+"_matchNr";
totalThreads=JMeterContextService.getTotalThreads();

if (${__threadNum} == totalThreads){ // this is to check if it is the last
thread, hence the reason for the ramp up at the start of the test (not
perfect I know)
int totalMatchNr;
int i;
for (i = 1; i <= totalThreads; i++) {
totalMatchNr=totalMatchNr+Integer.decode(vars.get(currentVar));
}
print("Number Of Matches = "+totalMatchNr);
}


Maybe someone knows of a more elegant solution to determine if the test has
ended
Just some ideas for you anyway!

HTH

ZK




--
View this message in context: http://jmeter.512774.n5.nabble.com/Display-User-Variable-in-Results-tp5719555p5719570.html
Sent from the JMeter - User mailing list archive at Nabble.com.
sebb
2014-03-13 13:47:28 UTC
Permalink
Post by Michael.OBrien
Hi Jmeter users,
I'd like to display or output the values of user defined variables but I've only come across instructions for re-using variables in additional http requests.
I don't see how the variable values can be graphed, charted or displayed using jmeter listeners
Is there a way for me to just dump the user variables out in View Results Tree or View Results in Table?
The test script I wish to create is to
1. Contact the website at IP address XYZ
2. Check for response code 200
3. Use RegExp to extract www\d from the body to variable RespondingMachine
4. Output and possible count each unique value of RespondingMachine
I'm using jmeter 2.11 without any extra plugins. I did find the RegExp Tester option in "View Results Tree" so my expression will work I'm just not sure how to get it to display alongside the table or tree
Have you seen:

http://jmeter.apache.org/usermanual/listeners.html#sample_variables
Post by Michael.OBrien
Anyone able to help me out?
Michael
Continue reading on narkive:
Loading...