Using Jmeter OS Process Sampler to collect script data

1.7k views Asked by At

Is it possible to collect the output of a python script using the "OS Process Sampler"?

My python script does a database query and returns "r1=123 r2=456 r3=789" Is there a way to collect the r1, r2, r3 values and graph them?

2

There are 2 answers

0
Dmitri T On BEST ANSWER

You can use Regular Expression Extractor to get the values from the OS Process Sampler as follows:

  1. Add Regular Expression Extractor as a child of the OS Process Sampler
  2. Configure it as follows:

    • Reference Name: variable name of your choice, i.e. r
    • Regular Expression: r1=(\d+) r2=(\d+) r3=(\d+)
    • Template: $1$$2$$3$

It will result in the following variables:

r=123456789
r_g=3
r_g0=r1=123 r2=456 r3=789
r_g1=123
r_g2=456
r_g3=789

You can "tell" JMeter to store these values into .jtl results file by adding the following line to user.properties file (it is located in /bin folder of your JMeter installation)

sample_variables=r_g1,r_g2,r_g3

Variables will be stored in .jtl file along with the other test result information like

1434196234292,251,OS Process Sampler,0,OK,Thread Group 1-1,text,true,21,1,1,0,123,456,789

(scroll to the right of the line as the values may be hidden)

See Apache JMeter Properties Customization Guide to learn more about JMeter properties and ways of setting/overriding them.

Once you store results you should be able to graph the values you can use Microsoft Excel, Libre Office or equivalent.

0
sbos61 On

Hi you just have to print the data you need to pass to jmeter, and then use one (or more) regular expression to extract values.