JMXMon Samples Collector. How to get an element of an array of values

52 views
Skip to first unread message

Aksiniya Ryzhova

unread,
Nov 1, 2018, 11:11:51 AM11/1/18
to jmeter-plugins
I am trying to collect statistics with JMXMon Samples Collector.

There is an element for which the key looks like:

 name   |    value
per hour | java.lang.Long[168]
per minute | java.lang.Long[60]
per second | java.lang.Long[60]
per week | java.lang.Long[168]


As seen above, in the "value" field is an array.
If in the sampler in the field "key" specify only "per minute" for example, then I get the error:

ERROR - jmeter.JMeter: Uncaught exception:  java.lang.NumberFormatException: For input string: "[J@37abc20b"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)


Please tell me how I can compose the value for the "key" field to get a certain element of this array, for example the last

Till Neunast

unread,
Nov 3, 2018, 11:31:44 PM11/3/18
to jmeter-plugins

On Friday, November 2, 2018 at 4:11:51 AM UTC+13, Aksiniya Ryzhova wrote:
Please tell me how I can compose the value for the "key" field to get a certain element of this array, for example the last

The "key" field is only used for CompositeDataSupport objects, so you will have to submit a pull request.

if (key != null && !key.equals("")) {
    log
.error("key specified, but didnt get composite object from JMX. Will continue anyway.");
}

...could become something like this:

if (key != null && !key.equals("")) {
   
if (o.getClass().isArray()) {
       
int index = "-1".equals(key) ? java.lang.reflect.Array.getLength(o)-1 : Integer.parseInt(key);
        o
= java.lang.reflect.Array.get(o, index);
   
} else {
        log
.error("key specified, but didnt get composite object from JMX. Will continue anyway.");
   
}
}

HTH,
Till


Reply all
Reply to author
Forward
0 new messages