[collectd] Guide for writing plugins in Java

Hasna SABAH hasna.sabah at gmail.com
Wed Aug 21 01:05:44 CEST 2013

I am trying to write a simple class that gives the system load using

Here is the code of the read callback

OperatingSystemMXBean mbean = ManagementFactory.getOperatingSystemMXBean();
long avgload=new Double(mbean.getSystemLoadAverage()).longValue();
ValueList vl= new ValueList ();
vl.setHost ("proxima");
vl.setPlugin ("Example2");
vl.setPluginInstance ("Example2");
vl.setType ("load");
     vl.addValue (avgload);
     vl.setTypeInstance ("load");
     Collectd.dispatchValues (vl);
     vl.clearValues ();
catch(Exception e){
Collectd.logError("Example2 unexpected error:"+e);

It compiles without problem, I configured collectd to load my mplugin, but
when it starts, I see those errors in logfile:

[2013-08-20 22:47:21] java plugin: jtoc_values_array: GetObjectArrayElement
(1) failed.
[2013-08-20 22:47:21] java plugin: jtoc_value_list: jtoc_values_array
[2013-08-20 22:47:21] java plugin: cjni_api_dispatch_values:
jtoc_value_list failed.
[2013-08-20 22:47:21] Example2 unexpected
error:java.lang.ArrayIndexOutOfBoundsException: 1

I can't figure out what is the problem, any hint?
Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20130820/9e7746ae/attachment.html>

More information about the collectd mailing list