Code

collectd(1): Added documentation for the `perl' plugin.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 10 Apr 2007 12:46:29 +0000 (14:46 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 10 Apr 2007 12:46:29 +0000 (14:46 +0200)
src/collectd.pod

index bc65f57d5031c7d82c8cf3fff1b965dc8ac458b5..08524901d982a7357075f31fa75906880e3e0fa7 100644 (file)
@@ -266,6 +266,132 @@ C<Qcache_*> are put in F<mysql_qcache.rrd> and values of C<Threads_*> are put
 in F<mysql_threads.rrd>. Please refer to the B<MySQL reference manual>,
 I<5.2.4. Server Status Variables> for an explanation of these values.
 
+=head2 perl
+
+The C<perl plugin> includes a Perl-interpreter in collectd and provides
+Perl-equvalents of the plugin-functions. This makes it possible to write
+plugins in Perl.
+
+There are two more comlex types you need to know about:
+
+=over 4
+
+=item Data-Set
+
+A data-set is a list of one or more data-sources. Each data-source defines a
+name, type, min- and max-value and the data-set wraps them up into one
+structure. The general layout looks like this:
+
+  [{
+    name => 'data_source_name',
+    type => DS_TYPE_COUNTER || DS_TYPE_GAUGE
+    min  => value || undef,
+    max  => value || undef
+  }, ...]
+
+=item Value-List
+
+A value-list is one structure which features an array of values and fields to
+identify the values, i. e. time and host, plugin name and plugin-instance as
+well as a type and type-instance. Since the "type" is not included in the
+value-list but is passed as an extra argument, the general layout looks like
+this:
+
+  {
+    values => [123, 0.5],
+    time   => time (),
+    host   => 'localhost',
+    plugin => 'myplugin',
+    plugin_instance => '',
+    type_instance   => ''
+  }
+
+=back
+
+The following functions provide the C-interface to Perl-modules:
+
+=over 4
+
+=item B<plugin_register> (I<type>, I<name>, I<data>)
+
+Registers a callback-function or data-set.
+
+I<type> can be one of:
+
+=over 4
+
+=item TYPE_INIT
+
+=item TYPE_READ
+
+=item TYPE_WRITE
+
+=item TYPE_LOG
+
+=item TYPE_SHUTDOWN
+
+=item TYPE_DATASET
+
+=back
+
+I<name> is the name of the callback-function or the type of the data-set,
+depending on the value of I<type>. (Please note that the type of the data-set
+is the value passed as I<name> here and has nothing to do with the I<type>
+argument which simply tells B<plugin_register> what is being registered.)
+
+The last argument, I<data>, is either a function- or an array-reference. If
+I<type> is B<TYPE_DATASET>, then the I<data> argument must be an
+array-reference which points to an array of hashes. Each hash describes one
+data-source. For the exact layout see B<Data-Set> above.
+
+If the I<type> argument is any of the other types (B<TYPE_INIT>, B<TYPE_READ>,
+...) when I<data> is expected to be a funtion reference. These functions are
+called in the various stages of the daemon and are passed the following
+arguments:
+
+=over 4
+
+=item TYPE_INIT
+
+=item TYPE_READ
+
+=item TYPE_SHUTDOWN
+
+No arguments are passed
+
+=item TYPE_WRITE
+
+The arguments passed are I<type>, I<data-set>, and I<value-list>. I<type> is a
+string. For the layout of I<data-set> and I<value-list> see above.
+
+=item TYPE_LOG
+
+The arguments are I<log-level> and I<message>. The log level is small for
+important messages and high for less important messages. The least important
+level is B<LOG_DEBUG>, the most important level is B<LOG_ERR>. In between there
+are (from least to most important): B<LOG_INFO>, B<LOG_NOTICE>, and
+B<LOG_WARNING>. I<message> is simply a string B<without> a newline at the end.
+
+=back
+
+=item B<plugin_unregister> (I<type>, I<plugin>)
+
+Removes a callback or data-set from collectd's internal list of
+functionsE<nbsp>/ datasets.
+
+=item B<plugin_dispatch_values> (I<type>, I<value-list>)
+
+Submits a I<value-list> of type I<type> to the daemon. If the data-set I<type>
+is found (and the number of values matches the number of data-sources) then the
+type, data-set and value-list is passed to all write-callbacks that are
+registered with the daemon.
+
+=item B<plugin_log> (I<log-level>, I<message>)
+
+TODO.
+
+=back
+
 =head2 sensors
 
 The B<sensors> module uses lm_sensors to retrieve sensor-values. This means