I am trying to write a simple class that gives the system load using
java.lang.management.OperatingSystemMXBean

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");
try{
     vl.addValue (avgload);
     vl.setTypeInstance ("load");
     Collectd.dispatchValues (vl);
     vl.clearValues ();
}
catch(Exception e){
Collectd.logError("Example2 unexpected error:"+e);
e.printStackTrace();
}


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
failed.
[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
_______________________________________________
collectd mailing list
collectd@verplant.org
http://mailman.verplant.org/listinfo/collectd

Reply via email to