[collectd] GenericJMX read MBean array

Geoff Kramer kramer.geoff at gmail.com
Tue Aug 2 18:25:51 CEST 2016


So I answered my own question here:
After pulling down multiple versions of generic-jmx.jar I could not get
compatibility working and building from source on the machine was not an
option due to "Business reasons".  Ultimately I pulled down the source code
for my version 5.4.1 to local built it copied my jar up with an added
logger to figure out the type:

in ./bindings/java/org/collectd/java/GenericJMXConfValue.java

  private Number genericObjectToNumber (Object obj, int ds_type) /* {{{ */
  {
    Collectd.logError ("Class: " + obj.getClass().getName() + "+++");

this threw back a "[J"
which thanks to google is an array of long primitives

so I updated genericObjectToNumber with an extra case

    else if (obj instanceof long[])
    {
      long[] array = (long[]) obj;
      return (genericObjectToNumber(array[array.length-1], ds_type));
    }

and viola I have my data

as a side note, I also added bools
    else if (obj instanceof Boolean)
    {
      Boolean bool = (Boolean) obj;
      return (bool==true?1:0);
    }

thanks to anyone that looked at it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20160802/9591b365/attachment.html>


More information about the collectd mailing list