Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "COLLECTD-JAVA 5"
COLLECTD-JAVA 5 "2020-07-20" "5.11.0.94.g41b1e33" "collectd"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
collectd-java - Documentation of collectd's "java plugin"
"SYNOPSIS"
Header "SYNOPSIS" .Vb 4 LoadPlugin "java" <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> .Ve
"DESCRIPTION"
Header "DESCRIPTION" The Java plugin embeds a Java Virtual Machine (\s-1JVM\s0) into collectd and provides a Java interface to part of collectd's \s-1API.\s0 This makes it possible to write additions to the daemon in Java.

This plugin is similar in nature to, but shares no code with, the Perl plugin by Sebastian Harl, see collectd-perl\|(5) for details.

"CONFIGURATION"
Header "CONFIGURATION" A short outline of this plugin's configuration can be seen in \*(L"\s-1SYNOPSIS\*(R"\s0 above. For a complete list of all configuration options and their semantics please read "Plugin \*(C`java\*(C'" in collectd.conf\|(5).
"OVERVIEW"
Header "OVERVIEW" When writing additions for collectd in Java, the underlying C base is mostly hidden from you. All complex data types are converted to their Java counterparts before they're passed to your functions. These Java classes reside in the \fIorg.collectd.api namespace.

The Java plugin will create one object of each class configured with the \fBLoadPlugin option. The constructor of this class can then register \*(L"callback methods\*(R", i. e. methods that will be called by the daemon when appropriate.

The available classes are:

"org.collectd.api.Collectd" 4
Item "org.collectd.api.Collectd" All \s-1API\s0 functions exported to Java are implemented as static functions of this class. See \*(L"\s-1EXPORTED API FUNCTIONS\*(R"\s0 below.
"org.collectd.api.OConfigValue" 4
Item "org.collectd.api.OConfigValue" Corresponds to \*(C`oconfig_value_t\*(C', defined in src/liboconfig/oconfig.h.
"org.collectd.api.OConfigItem" 4
Item "org.collectd.api.OConfigItem" Corresponds to \*(C`oconfig_item_t\*(C', defined in src/liboconfig/oconfig.h.
"org.collectd.api.DataSource" 4
Item "org.collectd.api.DataSource" Corresponds to \*(C`data_source_t\*(C', defined in src/plugin.h.
"org.collectd.api.DataSet" 4
Item "org.collectd.api.DataSet" Corresponds to \*(C`data_set_t\*(C', defined in src/plugin.h.
"org.collectd.api.ValueList" 4
Item "org.collectd.api.ValueList" Corresponds to \*(C`value_list_t\*(C', defined in src/plugin.h.
"org.collectd.api.Notification" 4
Item "org.collectd.api.Notification" Corresponds to \*(C`notification_t\*(C', defined in src/plugin.h.

In the remainder of this document, we'll use the short form of these names, for example ValueList. In order to be able to use these abbreviated names, you need to import the classes.

"EXPORTED API FUNCTIONS"
Header "EXPORTED API FUNCTIONS" All collectd \s-1API\s0 functions that are available to Java plugins are implemented as public static functions of the Collectd class. This makes calling these functions pretty straight forward. For example, to send an error message to the daemon, you'd do something like this:

.Vb 1 Collectd.logError ("That wasn\*(Aqt chicken!"); .Ve

The following are the currently exported functions.

"registerConfig"
Subsection "registerConfig" Signature: int registerConfig (String name, \fICollectdConfigInterface object);

Registers the config function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"config callback\*(R" below.

"registerInit"
Subsection "registerInit" Signature: int registerInit (String name, \fICollectdInitInterface object);

Registers the init function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"init callback\*(R" below.

"registerRead"
Subsection "registerRead" Signature: int registerRead (String name, \fICollectdReadInterface object)

Registers the read function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"read callback\*(R" below.

"registerWrite"
Subsection "registerWrite" Signature: int registerWrite (String name, \fICollectdWriteInterface object)

Registers the write function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"write callback\*(R" below.

"registerFlush"
Subsection "registerFlush" Signature: int registerFlush (String name, \fICollectdFlushInterface object)

Registers the flush function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"flush callback\*(R" below.

"registerShutdown"
Subsection "registerShutdown" Signature: int registerShutdown (String name, \fICollectdShutdownInterface object);

Registers the shutdown function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"shutdown callback\*(R" below.

"registerLog"
Subsection "registerLog" Signature: int registerLog (String name, \fICollectdLogInterface object);

Registers the log function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"log callback\*(R" below.

"registerNotification"
Subsection "registerNotification" Signature: int registerNotification (String name, \fICollectdNotificationInterface object);

Registers the notification function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"notification callback\*(R" below.

"registerMatch"
Subsection "registerMatch" Signature: int registerMatch (String name, \fICollectdMatchFactoryInterface object);

Registers the createMatch function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"match callback\*(R" below.

"registerTarget"
Subsection "registerTarget" Signature: int registerTarget (String name, \fICollectdTargetFactoryInterface object);

Registers the createTarget function of object with the daemon.

Returns zero upon success and non-zero when an error occurred.

See \*(L"target callback\*(R" below.

"dispatchValues"
Subsection "dispatchValues" Signature: int dispatchValues (ValueList)

Passes the values represented by the ValueList object to the \f(CW\*(C`plugin_dispatch_values\*(C' function of the daemon. The \*(L"data set\*(R" (or list of \*(L"data sources\*(R") associated with the object are ignored, because \f(CW\*(C`plugin_dispatch_values\*(C' will automatically lookup the required data set. It is therefore absolutely okay to leave this blank.

Returns zero upon success or non-zero upon failure.

"getDS"
Subsection "getDS" Signature: DataSet getDS (String)

Returns the appropriate type or null if the type is not defined.

"logError"
Subsection "logError" Signature: void logError (String)

Sends a log message with severity \s-1ERROR\s0 to the daemon.

"logWarning"
Subsection "logWarning" Signature: void logWarning (String)

Sends a log message with severity \s-1WARNING\s0 to the daemon.

"logNotice"
Subsection "logNotice" Signature: void logNotice (String)

Sends a log message with severity \s-1NOTICE\s0 to the daemon.

"logInfo"
Subsection "logInfo" Signature: void logInfo (String)

Sends a log message with severity \s-1INFO\s0 to the daemon.

"logDebug"
Subsection "logDebug" Signature: void logDebug (String)

Sends a log message with severity \s-1DEBUG\s0 to the daemon.

"REGISTERING CALLBACKS"
Header "REGISTERING CALLBACKS" When starting up, collectd creates an object of each configured class. The constructor of this class should then register \*(L"callbacks\*(R" with the daemon, using the appropriate static functions in Collectd, see \*(L"\s-1EXPORTED API FUNCTIONS\*(R"\s0 above. To register a callback, the object being passed to one of the register functions must implement an appropriate interface, which are all in the org.collectd.api namespace.

A constructor may register any number of these callbacks, even none. An object without callback methods is never actively called by collectd, but may still call the exported \s-1API\s0 functions. One could, for example, start a new thread in the constructor and dispatch (submit to the daemon) values asynchronously, whenever one is available.

Each callback method is now explained in more detail:

"config callback"
Subsection "config callback" Interface: org.collectd.api.CollectdConfigInterface

Signature: int config (OConfigItem ci)

This method is passed a OConfigItem object, if both, method and configuration, are available. OConfigItem is the root of a tree representing the configuration for this plugin. The root itself is the representation of the \fB<Plugin /> block, so in next to all cases the children of the root are the first interesting objects.

To signal success, this method has to return zero. Anything else will be considered an error condition and the plugin will be disabled entirely.

See \*(L"registerConfig\*(R" above.

"init callback"
Subsection "init callback" Interface: org.collectd.api.CollectdInitInterface

Signature: int init ()

This method is called after the configuration has been handled. It is supposed to set up the plugin. e. g. start threads, open connections, or check if can do anything useful at all.

To signal success, this method has to return zero. Anything else will be considered an error condition and the plugin will be disabled entirely.

See \*(L"registerInit\*(R" above.

"read callback"
Subsection "read callback" Interface: org.collectd.api.CollectdReadInterface

Signature: int read ()

This method is called periodically and is supposed to gather statistics in whatever fashion. These statistics are represented as a ValueList object and sent to the daemon using dispatchValues.

To signal success, this method has to return zero. Anything else will be considered an error condition and cause an appropriate message to be logged. Currently, returning non-zero does not have any other effects. In particular, Java \*(L"read\*(R"-methods are not suspended for increasing intervals like C \*(L"read\*(R"-functions.

See \*(L"registerRead\*(R" above.

"write callback"
Subsection "write callback" Interface: org.collectd.api.CollectdWriteInterface

Signature: int write (ValueList vl)

This method is called whenever a value is dispatched to the daemon. The corresponding C \*(L"write\*(R"-functions are passed a \*(C`data_set_t\*(C', so they can decide which values are absolute values (gauge) and which are counter values. To get the corresponding \*(C`List<DataSource>\*(C', call the getDataSource method of the ValueList object.

To signal success, this method has to return zero. Anything else will be considered an error condition and cause an appropriate message to be logged.

See \*(L"registerWrite\*(R" above.

"flush callback"
Subsection "flush callback" Interface: org.collectd.api.CollectdFlushInterface

Signature: int flush (int timeout, String identifier)

This method is called when the daemon received a flush command. This can either be done using the \*(C`USR1\*(C' signal (see collectd\|(1)) or using the unixsock plugin (see collectd-unixsock\|(5)).

If timeout is greater than zero, only values older than this number of seconds should be flushed. To signal that all values should be flushed regardless of age, this argument is set to a negative number.

The identifier specifies which value should be flushed. If it is not possible to flush one specific value, flush all values. To signal that all values should be flushed, this argument is set to null.

To signal success, this method has to return zero. Anything else will be considered an error condition and cause an appropriate message to be logged.

See \*(L"registerFlush\*(R" above.

"shutdown callback"
Subsection "shutdown callback" Interface: org.collectd.api.CollectdShutdownInterface

Signature: int shutdown ()

This method is called when the daemon is shutting down. You should not rely on the destructor to clean up behind the object but use this function instead.

To signal success, this method has to return zero. Anything else will be considered an error condition and cause an appropriate message to be logged.

See \*(L"registerShutdown\*(R" above.

"log callback"
Subsection "log callback" Interface: org.collectd.api.CollectdLogInterface

Signature: void log (int severity, String message)

This callback can be used to receive log messages from the daemon.

The argument severity is one of:

"\(bu" 4
org.collectd.api.Collectd.LOG_ERR
"\(bu" 4
org.collectd.api.Collectd.LOG_WARNING
"\(bu" 4
org.collectd.api.Collectd.LOG_NOTICE
"\(bu" 4
org.collectd.api.Collectd.LOG_INFO
"\(bu" 4
org.collectd.api.Collectd.LOG_DEBUG

The function does not return any value.

See \*(L"registerLog\*(R" above.

"notification callback"
Subsection "notification callback" Interface: org.collectd.api.CollectdNotificationInterface

Signature: int notification (Notification n)

This callback can be used to receive notifications from the daemon.

To signal success, this method has to return zero. Anything else will be considered an error condition and cause an appropriate message to be logged.

See \*(L"registerNotification\*(R" above.

"match callback"
Subsection "match callback" The match (and target, see \*(L"target callback\*(R" below) callbacks work a bit different from the other callbacks above: You don't register a match callback with the daemon directly, but you register a function which, when called, creates an appropriate object. The object creating the \*(L"match\*(R" objects is called \*(L"match factory\*(R".

See \*(L"registerMatch\*(R" above.

Factory object Subsection "Factory object"

Interface: org.collectd.api.CollectdMatchFactoryInterface

Signature: CollectdMatchInterface createMatch (OConfigItem ci);

Called by the daemon to create \*(L"match\*(R" objects.

Returns: A new object which implements the CollectdMatchInterface interface.

Match object Subsection "Match object"

Interface: org.collectd.api.CollectdMatchInterface

Signature: int match (DataSet ds, ValueList vl);

Called when processing a chain to determine whether or not a ValueList matches. How values are matches is up to the implementing class.

Has to return one of:

"\(bu" 4
\fBCollectd.FC_MATCH_NO_MATCH
"\(bu" 4
\fBCollectd.FC_MATCH_MATCHES
"target callback"
Subsection "target callback" The target (and match, see \*(L"match callback\*(R" above) callbacks work a bit different from the other callbacks above: You don't register a target callback with the daemon directly, but you register a function which, when called, creates an appropriate object. The object creating the \*(L"target\*(R" objects is called \*(L"target factory\*(R".

See \*(L"registerTarget\*(R" above.

Factory object Subsection "Factory object"

Interface: org.collectd.api.CollectdTargetFactoryInterface

Signature: CollectdTargetInterface createTarget (OConfigItem ci);

Called by the daemon to create \*(L"target\*(R" objects.

Returns: A new object which implements the CollectdTargetInterface interface.

Target object Subsection "Target object"

Interface: org.collectd.api.CollectdTargetInterface

Signature: int invoke (DataSet ds, ValueList vl);

Called when processing a chain to perform some action. The action performed is up to the implementing class.

Has to return one of:

"\(bu" 4
\fBCollectd.FC_TARGET_CONTINUE
"\(bu" 4
\fBCollectd.FC_TARGET_STOP
"\(bu" 4
\fBCollectd.FC_TARGET_RETURN
"EXAMPLE"
Header "EXAMPLE" This short example demonstrates how to register a read callback with the daemon:

.Vb 2 import org.collectd.api.Collectd; import org.collectd.api.ValueList; import org.collectd.api.CollectdReadInterface; public class Foobar implements CollectdReadInterface { public Foobar () { Collectd.registerRead ("Foobar", this); } public int read () { ValueList vl; /* Do something... */ Collectd.dispatchValues (vl); } } .Ve

"PLUGINS"
Header "PLUGINS" The following plugins are implemented in Java. Both, the LoadPlugin option and the Plugin block must be inside the \fB<Plugin java> block (see above).
"GenericJMX plugin"
Subsection "GenericJMX plugin" The GenericJMX plugin reads Managed Beans (MBeans) from an MBeanServer using \s-1JMX. JMX\s0 is a generic framework to provide and query various management information. The interface is used by Java processes to provide internal statistics as well as by the Java Virtual Machine (\s-1JVM\s0) to provide information about the memory used, threads and so on.

The configuration of the GenericJMX plugin consists of two blocks: MBean blocks that define a mapping of MBean attributes to the XtypesX used by \fIcollectd, and Connection blocks which define the parameters needed to connect to an MBeanServer and what data to collect. The configuration of the \fI\s-1SNMP\s0 plugin is similar in nature, in case you know it.

MBean blocks Subsection "MBean blocks"

\fIMBean blocks specify what data is retrieved from MBeans and how that data is mapped on the collectd data types. The block requires one string argument, a name. This name is used in the Connection blocks (see below) to refer to a specific MBean block. Therefore, the names must be unique.

The following options are recognized within MBean blocks:

"ObjectName pattern" 4
Item "ObjectName pattern" Sets the pattern which is used to retrieve MBeans from the MBeanServer. If more than one MBean is returned you should use the InstanceFrom option (see below) to make the identifiers unique. .Sp See also: <http://java.sun.com/javase/6/docs/api/javax/management/ObjectName.html>
"InstancePrefix prefix" 4
Item "InstancePrefix prefix" Prefixes the generated plugin instance with prefix. (optional)
"InstanceFrom property" 4
Item "InstanceFrom property" The object names used by \s-1JMX\s0 to identify MBeans include so called \fIXpropertiesX which are basically key-value-pairs. If the given object name is not unique and multiple MBeans are returned, the values of those properties usually differ. You can use this option to build the plugin instance from the appropriate property values. This option is optional and may be repeated to generate the plugin instance from multiple property values.
"<value /> blocks" 4
Item "<value /> blocks" The value blocks map one or more attributes of an MBean to a value list in collectd. There must be at least one Value block within each MBean block.

"Type type" 4
Item "Type type" Sets the data set used within collectd to handle the values of the MBean attribute.
"InstancePrefix prefix" 4
Item "InstancePrefix prefix" Works like the option of the same name directly beneath the MBean block, but sets the type instance instead. (optional)
"InstanceFrom prefix" 4
Item "InstanceFrom prefix" Works like the option of the same name directly beneath the MBean block, but sets the type instance instead. (optional)
"PluginName name" 4
Item "PluginName name" When set, overrides the default setting for the plugin field (\*(C`GenericJMX\*(C').
"Table true|false" 4
Item "Table true|false" Set this to true if the returned attribute is a composite type. If set to true, the keys within the composite type is appended to the \fItype instance.
"Attribute path" 4
Item "Attribute path" Sets the name of the attribute from which to read the value. You can access the keys of composite types by using a dot to concatenate the key name to the attribute name. For example: Xattrib0.key42X. If Table is set to true \fIpath must point to a composite type, otherwise it must point to a numeric type.

Connection blocks Subsection "Connection blocks"

Connection blocks specify how to connect to an MBeanServer and what data to retrieve. The following configuration options are available:

"Host name" 4
Item "Host name" Host name used when dispatching the values to collectd. The option sets this field only, it is not used to connect to anything and doesn't need to be a real, resolvable name.
"ServiceURL \s-1URL\s0" 4
Item "ServiceURL URL" Specifies how the MBeanServer can be reached. Any string accepted by the \fIJMXServiceURL is valid. .Sp See also: <http://java.sun.com/javase/6/docs/api/javax/management/remote/JMXServiceURL.html>
"User name" 4
Item "User name" Use name to authenticate to the server. If not configured, XmonitorRoleX will be used.
"Password password" 4
Item "Password password" Use password to authenticate to the server. If not given, unauthenticated access is used.
"InstancePrefix prefix" 4
Item "InstancePrefix prefix" Prefixes the generated plugin instance with prefix. If a second \fIInstancePrefix is specified in a referenced MBean block, the prefix specified in the Connection block will appear at the beginning of the \fIplugin instance, the prefix specified in the MBean block will be appended to it.
"Collect mbean_block_name" 4
Item "Collect mbean_block_name" Configures which of the MBean blocks to use with this connection. May be repeated to collect multiple MBeans from this server.
"SEE ALSO"
Header "SEE ALSO" \fBcollectd\|(1), \fBcollectd.conf\|(5), \fBcollectd-perl\|(5), \fBtypes.db\|(5)
"AUTHOR"
Header "AUTHOR" Florian Forster <octo at collectd.org>