[prev in list] [next in list] [prev in thread] [next in thread] 

List:       collectd
Subject:    Re: [collectd] GenericJMX read MBean array
From:       Geoff Kramer <kramer.geoff () gmail ! com>
Date:       2016-08-02 16:25:51
Message-ID: CAO7GUJzsA3KGou4tYPO=sSiM1NHmKoagi6cuBTUFxTJF_ooL9g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

[Attachment #5 (text/html)]

<div dir="ltr"><div>So I answered my own question here:   </div><div>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 &quot;Business \
reasons&quot;.   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:</div><div><br></div><div>in \
./bindings/java/org/collectd/java/GenericJMXConfValue.java</div><div><br></div><div>  \
private Number genericObjectToNumber (Object obj, int ds_type) /* {{{ */</div><div>   \
{</div><div>      Collectd.logError (&quot;Class: &quot; + obj.getClass().getName() + \
&quot;+++&quot;);</div><div><br></div><div>this threw back a \
&quot;[J&quot;</div><div>which thanks to google is an array of long \
primitives</div><div><br></div><div>so I updated genericObjectToNumber with an extra \
case</div><div><br></div><div>      else if (obj instanceof long[])</div><div>      \
{</div><div>         long[] array = (long[]) obj;</div><div>         return \
(genericObjectToNumber(array[array.length-1], ds_type));</div><div>      \
}</div><div><br></div><div>and viola I have my data</div><div><br></div><div>as a \
side note, I also added bools</div><div>      else if (obj instanceof \
Boolean)</div><div>      {</div><div>         Boolean bool = (Boolean) \
obj;</div><div>         return (bool==true?1:0);</div><div>      \
}</div><div><br></div><div>thanks to anyone that looked at it.</div></div>



_______________________________________________
collectd mailing list
collectd@verplant.org
https://mailman.verplant.org/listinfo/collectd

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic