=head1 NAME collectd - System statistics collection daemon =head1 SYNOPSIS collectd I<[options]> =head1 DESCRIPTION collectd is a daemon that receives system statistics and makes them available in a number of ways. The main daemon itself doesn't have any real functionality appart from loading, querying and submitting to plugins. For a description of available plugins please see L below. =head1 OPTIONS Most of collectd's configuration is done using using a configfile. See L for an in-depth description of all options. =over 4 =item B<-C> Iconfig-fileE> Specify an alternative config file. This is the place to go when you wish to change B's behavior. The path may be relative to the current working directory. =item B<-P> Ipid-fileE> Specify an alternative pid file. This overwrites any settings in the config file. This is thought for init-scripts that require the PID-file in a certain directory to work correctly. For everyday-usage use the B config-option. =item B<-f> Don't fork to the background. I will also B close standard file descriptors, detach from the session nor write a pid file. This is mainly thought for 'supervisioning' init replacements such as I. =item B<-h> Output usage information and exit. =back =head1 PLUGINS As noted above, the real power of collectd lies within it's plugins. There are two big groups of plugins, B and B plugins: =over 4 =item Input plugins are queried periodically. They somehow aquire the current value of whatever they where designed to work with and submit these values back to the daemon, i. e. they "dispatch" the values. As an example, the C reads the current cpu-counters of time spent in the various modes (user, system, nice, ...) and dispatches these counters to the daemon. =item Output plugins get the dispatched values from the daemon and does something with them. Common applications are writing to RRD-files, CSV-files or sending the data over a network link to a remote box. =back Of course not all plugins fit neatly into one of the two above categories. The C, for example, is able to send (i.Ee. "write") B receive (i.Ee. "dispatch") values. Also, it opens a socket upon initialization and dispatches the values when it receives them and isn't triggered at the same time the input plugins are being read. You can think if the network receive part as working asynchronous if it helps. In addition to the above, there are "logging plugins". Right now those are the C and the C. With these plugins collectd can provide information about issues and significant situations to the user. Several loglevels let you suppress uninteresting messages. =head1 SPECIAL PLUGINS =head2 apache This module connects to an Apache or lighttpd webserver and expects the output produced by B. If requires B to set up the HTTP connection and issue the request(s). The following is a sample config for the Apache webserver. Under Apache, the use of C is mandatory. ExtendedStatus on SetHandler server-status This plugin requires further configuration. Please read L. =head2 cpufreq This module reads F (for the first CPU installed) to get the current CPU frequency. If this file does not exist make sure B (L) or a similar tool is installed and an "cpu governor" (that's kernel module) is loaded. =head2 email This plugin collects data indirectly by providing a UNIX socket that external programs can connect to. A simple line based protocol is used to communicate with the plugin: E-Mail type (e.g. "ham", "spam", "virus", ...) and size (bytes): e:: If C is less than or equal to zero, C is ignored. Spam score: s: Successful spam checks (e.g. "BAYES_99", "SUBJECT_DRUG_GAP_C", ...): c:[,,...] Each line is limited to 256 characters (including the newline character). Longer lines will be ignored. =head2 exec The C plugin forks of an executable and reads back values that it writes to C. The executable is forked kind of as L does: It is forked once and not again until it exits. If it exited, it will be forked again after at most I seconds. It is perfectly legal for the executable to run for a long time and continuously write values to C. The forked executable is expected to print values to C. The expected format is as follows: =over 4 =item Each line beginning with a C<#> (hash mark) is ignored. =item Any other line must be of the form C,I,I>, where I is either B or B, I may not contain C<,> (comma), C (slash) and C<\0> (null byte) and I is either an integer (if I is B) or a floating-point number (if I is B). =back The values are always considered to be "fresh", i.Ee. the time is set to "now". When collectd exits it sends a B to all still running child-processes upon which they have to quit. =head2 mysql Requires B to be installed. It connects to the database when started and keeps the connection up as long as possible. When the connection is interrupted for whatever reason it will try to re-connect. The syslog will contain loud complaints in case anything goes wrong. This plugin issues C and evaluates C, C and C which correspond to F, F and F. Also, the values of C are put in F and values of C are put in F. Please refer to the B, I<5.2.4. Server Status Variables> for an explanation of these values. =head2 perl The C includes a Perl-interpreter in collectd and provides Perl-equivalents of the plugin-functions. This makes it possible to write plugins in Perl. There are two more complex 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 (I, I, I) Registers a callback-function or data-set. I 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 is the name of the callback-function or the type of the data-set, depending on the value of I. (Please note that the type of the data-set is the value passed as I here and has nothing to do with the I argument which simply tells B what is being registered.) The last argument, I, is either a function- or an array-reference. If I is B, then the I 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 above. If the I argument is any of the other types (B, B, ...) then I is expected to be a function 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, I, and I. I is a string. For the layout of I and I see above. =item TYPE_LOG The arguments are I and I. The log level is small for important messages and high for less important messages. The least important level is B, the most important level is B. In between there are (from least to most important): B, B, and B. I is simply a string B a newline at the end. =back =item B (I, I) Removes a callback or data-set from collectd's internal list of functionsE/ datasets. =item B (I, I) Submits a I of type I to the daemon. If the data-set I 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 (I, I) Submits a I of level I to collectd's logging mechanism. The message is passed to all log-callbacks that are registered with collectd. =back =head2 sensors The B module uses lm_sensors to retrieve sensor-values. This means that all the needed modules have to be loaded and lm_sensors has to be configured (most likely by editing F. Read L for details. The B homepage can be found at L. =head2 mbmon The B module uses mbmon to retrieve temperature, voltage, etc. collectd connects to B (127.0.0.1), port B<411/tcp>. The B and B options can be used to change these default values. See L for details. C has to be running to work correctly. If C is not running timeouts may appear which may interfere with other statistics.. C must be run with the -r option ("print TAG and Value format"); Debian's /etc/init.d/mbmon script already does this, other people will need to ensure that this is the case. =head2 hddtemp To get values from B collectd connects to B (127.0.0.1), port B<7634/tcp>. The B and B options can be used to change these default values. See L for details. C has to be running to work correctly. If C is not running timeouts may appear which may interfere with other statistics.. The B homepage can be found at L. =head2 vserver B support is only available for Linux. It cannot yet be found in a vanilla kernel, though. To make use of this plugin you need a kernel that has B support built in, i.e. you need to apply the patches and compile your own kernel, which will then provide the /proc/virtual filesystem that is required by this plugin. The B homepage can be found at L. =head1 SEE ALSO L, L, L, L, L, L, L =head1 AUTHOR Florian Forster Eocto@verplant.orgE =cut