X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fcollectd-java.pod;h=aade08a456b701aff4fdc94f70f1907617de1127;hp=14e542d89d68dbb15a660eef3083132f24b0603b;hb=633c3966f770e4d46651a2fe219a18d8a9907a9f;hpb=773467790bd066ec6b9693732d165d7fde9f18f7 diff --git a/src/collectd-java.pod b/src/collectd-java.pod index 14e542d8..aade08a4 100644 --- a/src/collectd-java.pod +++ b/src/collectd-java.pod @@ -1,3 +1,5 @@ +=encoding UTF-8 + =head1 NAME collectd-java - Documentation of collectd's "java plugin" @@ -37,10 +39,20 @@ 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 I namespace. +The I plugin will create one object of each class configured with the +B option. The constructor of this class can then register "callback +methods", i.Ee. methods that will be called by the daemon when +appropriate. + The available classes are: =over 4 +=item B + +All API functions exported to Java are implemented as static functions of this +class. See L<"EXPORTED API FUNCTIONS"> below. + =item B Corresponds to C, defined in F. @@ -61,22 +73,191 @@ Corresponds to C, defined in F. Corresponds to C, defined in F. +=item B + +Corresponds to C, defined in F. + =back In the remainder of this document, we'll use the short form of these names, for example B. In order to be able to use these abbreviated names, you need to B the classes. -The API functions that are available from Java are implemented as I -functions of the B class. -See L<"CALLING API FUNCTIONS"> below for details. +=head1 EXPORTED API FUNCTIONS + +All collectd API functions that are available to Java plugins are implemented +as Istatic> functions of the B 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: + + Collectd.logError ("That wasn't chicken!"); + +The following are the currently exported functions. + +=head2 registerConfig + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"config callback"> below. + +=head2 registerInit + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"init callback"> below. + +=head2 registerRead + +Signature: I B (I name, +I object) + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"read callback"> below. + +=head2 registerWrite + +Signature: I B (I name, +I object) + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"write callback"> below. + +=head2 registerFlush + +Signature: I B (I name, +I object) + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"flush callback"> below. + +=head2 registerShutdown + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"shutdown callback"> below. + +=head2 registerLog + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"log callback"> below. + +=head2 registerNotification + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"notification callback"> below. + +=head2 registerMatch + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"match callback"> below. + +=head2 registerTarget + +Signature: I B (I name, +I object); + +Registers the B function of I with the daemon. + +Returns zero upon success and non-zero when an error occurred. + +See L<"target callback"> below. + +=head2 dispatchValues + +Signature: I B (I) + +Passes the values represented by the B object to the +C function of the daemon. The "data set" (or list of +"data sources") associated with the object are ignored, because +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. + +=head2 getDS + +Signature: I B (I) + +Returns the appropriate I or B if the type is not defined. + +=head2 logError + +Signature: I B (I) + +Sends a log message with severity B to the daemon. + +=head2 logWarning + +Signature: I B (I) + +Sends a log message with severity B to the daemon. + +=head2 logNotice + +Signature: I B (I) + +Sends a log message with severity B to the daemon. + +=head2 logInfo + +Signature: I B (I) + +Sends a log message with severity B to the daemon. + +=head2 logDebug + +Signature: I B (I) + +Sends a log message with severity B to the daemon. =head1 REGISTERING CALLBACKS When starting up, collectd creates an object of each configured class. The constructor of this class should then register "callbacks" with the daemon, using the appropriate static functions in B, -see L<"CALLING API FUNCTIONS"> below. To register a callback, the object being +see L<"EXPORTED API FUNCTIONS"> 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 B namespace. @@ -103,6 +284,8 @@ 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"> above. + =head2 init callback Interface: B @@ -116,6 +299,8 @@ 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"> above. + =head2 read callback Interface: B @@ -124,8 +309,7 @@ Signature: I B () This method is called periodically and is supposed to gather statistics in whatever fashion. These statistics are represented as a B object and -sent to the daemon using B, see L<"CALLING API FUNCTIONS"> -below. +sent to the daemon using L. 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. @@ -133,6 +317,8 @@ Currently, returning non-zero does not have any other effects. In particular, Java "read"-methods are not suspended for increasing intervals like C "read"-functions. +See L<"registerRead"> above. + =head2 write callback Interface: B @@ -148,6 +334,8 @@ method of the B 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"> above. + =head2 flush callback Interface: B @@ -156,7 +344,7 @@ Signature: I B (I timeout, I identifier) This method is called when the daemon received a flush command. This can either be done using the C signal (see L) or using the I -plugin (see L). +plugin (see L). If I is greater than zero, only values older than this number of seconds should be flushed. To signal that all values should be flushed @@ -169,6 +357,8 @@ values should be flushed, this argument is set to I. 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"> above. + =head2 shutdown callback Interface: B @@ -181,6 +371,8 @@ 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"> above. + =head2 log callback Interface: B @@ -217,7 +409,115 @@ org.collectd.api.Collectd.LOG_DEBUG The function does not return any value. -=head2 Example +See L<"registerLog"> above. + +=head2 notification callback + +Interface: B + +Signature: I B (I 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"> above. + +=head2 match callback + +The match (and target, see L<"target callback"> 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 "match" objects is +called "match factory". + +See L<"registerMatch"> above. + +=head3 Factory object + +Interface: B + +Signature: I B +(I ci); + +Called by the daemon to create "match" objects. + +Returns: A new object which implements the B interface. + +=head3 Match object + +Interface: B + +Signature: I B (I ds, I vl); + +Called when processing a chain to determine whether or not a I +matches. How values are matches is up to the implementing class. + +Has to return one of: + +=over 4 + +=item * + +B + +=item * + +B + +=back + +=head2 target callback + +The target (and match, see L<"match callback"> 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 "target" objects is +called "target factory". + +See L<"registerTarget"> above. + +=head3 Factory object + +Interface: B + +Signature: I B +(I ci); + +Called by the daemon to create "target" objects. + +Returns: A new object which implements the B +interface. + +=head3 Target object + +Interface: B + +Signature: I B (I ds, I vl); + +Called when processing a chain to perform some action. The action performed is +up to the implementing class. + +Has to return one of: + +=over 4 + +=item * + +B + +=item * + +B + +=item * + +B + +=back + +=head1 EXAMPLE This short example demonstrates how to register a read callback with the daemon: @@ -244,125 +544,145 @@ daemon: } } -=head1 CALLING API FUNCTIONS - -All collectd API functions that are available to Java plugins are implemented -as Istatic> functions of the B class. -This makes calling these functions pretty straight forward. - -The following are the currently exported functions. For information on the -interfaces used, please see L<"REGISTERING CALLBACKS"> above. - -=head2 registerConfig +=head1 PLUGINS -Signature: I B (I name, -I object); - -Registers the B function of I with the daemon. - -Returns zero upon success and non-zero when an error occurred. +The following plugins are implemented in I. Both, the B +option and the B block must be inside the +BPluginEjavaE> block (see above). -=head2 registerInit +=head2 GenericJMX plugin -Signature: I B (I name, -I object); +The GenericJMX plugin reads I (MBeans) from an I +using JMX. JMX 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 I (JVM) to provide +information about the memory used, threads and so on. -Registers the B function of I with the daemon. +The configuration of the I consists of two blocks: I +blocks that define a mapping of MBean attributes to the “types” used by +I, and I blocks which define the parameters needed to +connect to an I and what data to collect. The configuration of the +I is similar in nature, in case you know it. -Returns zero upon success and non-zero when an error occurred. +=head3 MBean blocks -=head2 registerRead +I blocks specify what data is retrieved from I and how that data +is mapped on the I data types. The block requires one string +argument, a name. This name is used in the I blocks (see below) to +refer to a specific I block. Therefore, the names must be unique. -Signature: I B (I name, -I object) +The following options are recognized within I blocks: -Registers the B function of I with the daemon. +=over 4 -Returns zero upon success and non-zero when an error occurred. +=item B I -=head2 registerWrite +Sets the pattern which is used to retrieve I from the I. +If more than one MBean is returned you should use the B option +(see below) to make the identifiers unique. -Signature: I B (I name, -I object) +See also: +L -Registers the B function of I with the daemon. +=item B I -Returns zero upon success and non-zero when an error occurred. +Prefixes the generated I with I. I<(optional)> -=head2 registerFlush +=item B I -Signature: I B (I name, -I object) +The I used by JMX to identify I include so called +I<“properties”> 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 I from +the appropriate property values. This option is optional and may be repeated to +generate the I from multiple property values. -Registers the B function of I with the daemon. +=item Bvalue /E> blocks -Returns zero upon success and non-zero when an error occurred. +The I blocks map one or more attributes of an I to a value list +in I. There must be at least one Value block within each I +block. -=head2 registerShutdown +=over 4 -Signature: I B (I name, -I object); +=item B type -Registers the B function of I with the daemon. +Sets the data set used within I to handle the values of the I +attribute. -Returns zero upon success and non-zero when an error occurred. +=item B I -=head2 registerLog +Works like the option of the same name directly beneath the I block, but +sets the type instance instead. I<(optional)> -Signature: I B (I name, -I object); +=item B I -Registers the B function of I with the daemon. +Works like the option of the same name directly beneath the I block, but +sets the type instance instead. I<(optional)> -Returns zero upon success and non-zero when an error occurred. +=item B B|B -=head2 dispatchValues +Set this to true if the returned attribute is a I. If set to +true, the keys within the I is appended to the +I. -Signature: I B (I) +=item B I -Passes the values represented by the B object to the -C function of the daemon. The "data set" (or list of -"data sources") associated with the object are ignored, because -C will automatically lookup the required data set. It -is therefore absolutely okay to leave this blank. +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: “attrib0.key42”. If B
is set to B +I must point to a I, otherwise it must point to a numeric +type. -Returns zero upon success or non-zero upon failure. +=back -=head2 getDS +=back -Signature: I B (I) +=head3 Connection blocks -Returns the approrpate I or B if the type is not defined. +Connection blocks specify I to connect to an I and what data +to retrieve. The following configuration options are available: -=head2 logError +=over 4 -Signature: I B (I) +=item B I -Sends a log message with severity B to the daemon. +Host name used when dispatching the values to I. The option sets this +field only, it is I used to connect to anything and doesn't need to be a +real, resolvable name. -=head2 logWarning +=item B I -Signature: I B (I) +Specifies how the I can be reached. Any string accepted by the +I is valid. -Sends a log message with severity B to the daemon. +See also: +L -=head2 logNotice +=item B I -Signature: I B (I) +Use I to authenticate to the server. If not configured, “monitorRole” +will be used. -Sends a log message with severity B to the daemon. +=item B I -=head2 logInfo +Use I to authenticate to the server. If not given, unauthenticated +access is used. -Signature: I B (I) +=item B I -Sends a log message with severity B to the daemon. +Prefixes the generated I with I. If a second +I is specified in a referenced I block, the prefix +specified in the I block will appear at the beginning of the +I, the prefix specified in the I block will be appended +to it. -=head2 logDebug +=item B I -Signature: I B (I) +Configures which of the I blocks to use with this connection. May be +repeated to collect multiple I from this server. -Sends a log message with severity B to the daemon. +=back =head1 SEE ALSO @@ -373,5 +693,5 @@ L =head1 AUTHOR -Florian Forster EoctoEatEverplant.orgE +Florian Forster EoctoEatEcollectd.orgE