java plugin¶
| Plugin name | java |
| Type | binding |
| Callbacks | config, flush, init, log, notification, read, shutdown, write |
| Status | supported |
| Since | 4.7 |
| Copyright | 2009 Florian Forster |
| License | GPLv2 |
| Configuration | collectd.conf(5) |
The Java plugin embeds a Java virtual machine (JVM) into collectd and exposes the application programming interface (API) to Java programs. This allows to write own plugins in the popular language, which are then loaded and executed by the daemon without the need to start a new process and JVM every few seconds. Java classes written for the Java plugin are therefore more powerful and efficient than scripts executed by the Exec plugin.
This plugin is a generic plugin, i.e. it cannot work without configuration, because there is no reasonable default behavior. Please read the Plugin java section of the collectd.conf(5) manual page for an in-depth description of the plugin's configuration. The programming interface is documented in detail in the collectd-java(5) manual page.
The JavaDoc documentation of the API is available.
Synopsis¶
<Plugin "java">
JVMArg "-verbose:jni"
JVMArg "-Djava.class.path=/opt/collectd/lib/collectd/bindings/java"
LoadPlugin "org.collectd.java.Foobar"
<Plugin "org.collectd.java.Foobar">
# To be parsed by the plugin
</Plugin>
</Plugin>
Dependencies¶
- Java Native Interface (JNI) /
libjvm
See also¶
- JavaDoc documentation of the API
- GenericJMX plugin
- bindings/java/org/collectd/java/JMXMemory.java – sample file to query memory usage via JMX
- jcollectd
Configuration¶
Configuration options · from collectd.conf(5)
See this section in the full configuration reference
The Java plugin makes it possible to write extensions for collectd in Java. This section only discusses the syntax and semantic of the configuration options. For more in-depth information on the Java plugin, please read collectd-java(5).
Synopsis:
<Plugin "java">
JVMArg "-verbose:jni"
JVMArg "-Djava.class.path=/opt/collectd/lib/collectd/bindings/java"
LoadPlugin "org.collectd.java.Foobar"
<Plugin "org.collectd.java.Foobar">
# To be parsed by the plugin
</Plugin>
</Plugin>
Available configuration options:
- JVMArg Argument
-
Argument that is to be passed to the Java Virtual Machine (JVM). This works exactly the way the arguments to the java binary on the command line work. Execute
javaE<nbsp--help> for details.Please note that all these options must appear before (i. e. above) any other options! When another option is found, the JVM will be started and later options will have to be ignored!
- LoadPlugin JavaClass
-
Instantiates a new JavaClass object. The constructor of this object very likely then registers one or more callback methods with the server.
See collectd-java(5) for details.
When the first such option is found, the virtual machine (JVM) is created. This means that all JVMArg options must appear before (i. e. above) all LoadPlugin options!
- Plugin Name
-
The entire block is passed to the Java plugin as an org.collectd.api.OConfigItem object.
For this to work, the plugin has to register a configuration callback first, see collectd-java(5)/config callback. This means, that the Plugin block must appear after the appropriate LoadPlugin block. Also note, that Name depends on the (Java) plugin registering the callback and is completely independent from the JavaClass argument passed to LoadPlugin.