.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" 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'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "COLLECTD-EXEC 5" .TH COLLECTD-EXEC 5 2024-02-04 5.12.0.git collectd .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME collectd\-exec \- Documentation of collectd's "exec plugin" .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 8 \& # See collectd.conf(5) \& LoadPlugin exec \& # ... \& \& Exec "myuser:mygroup" "myprog" \& Exec "otheruser" "/path/to/another/binary" "arg0" "arg1" \& NotificationExec "user" "/usr/lib/collectd/exec/handle_notification" \& .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" The \f(CW\*(C`exec plugin\*(C'\fR forks off an executable either to receive values or to dispatch notifications to the outside world. The syntax of the configuration is explained in \fBcollectd.conf\fR\|(5) but summarized in the above synopsis. .PP If you want/need better performance or more functionality you should take a long look at the \f(CW\*(C`perl plugin\*(C'\fR, \fBcollectd\-perl\fR\|(5). .SH "EXECUTABLE TYPES" .IX Header "EXECUTABLE TYPES" There are currently two types of executables that can be executed by the \&\f(CW\*(C`exec plugin\*(C'\fR: .ie n .IP """Exec""" 4 .el .IP \f(CWExec\fR 4 .IX Item "Exec" These programs are forked and values that it writes to \f(CW\*(C`STDOUT\*(C'\fR are read back. The executable is forked in a fashion similar to init: It is forked once and not again until it exits. If it exited, it will be forked again after at most \&\fIInterval\fR seconds. It is perfectly legal for the executable to run for a long time and continuously write values to \f(CW\*(C`STDOUT\*(C'\fR. .Sp See "EXEC DATA FORMAT" below for a description of the output format expected from these programs. .Sp \&\fBWarning:\fR If the executable only writes one value and then exits it will be executed every \fIInterval\fR seconds. If \fIInterval\fR is short (the default is 10 seconds) this may result in serious system load. .ie n .IP """NotificationExec""" 4 .el .IP \f(CWNotificationExec\fR 4 .IX Item "NotificationExec" The program is forked once for each notification that is handled by the daemon. The notification is passed to the program on \f(CW\*(C`STDIN\*(C'\fR in a fashion similar to HTTP-headers. In contrast to programs specified with \f(CW\*(C`Exec\*(C'\fR the execution of this program is not serialized, so that several instances of this program may run at once if multiple notifications are received. .Sp See "NOTIFICATION DATA FORMAT" below for a description of the data passed to these programs. .SH "EXEC DATA FORMAT" .IX Header "EXEC DATA FORMAT" The forked executable is expected to print values to \f(CW\*(C`STDOUT\*(C'\fR. The expected format is as follows: .IP Comments 4 .IX Item "Comments" Each line beginning with a \f(CW\*(C`#\*(C'\fR (hash mark) is ignored. .IP "\fBPUTVAL\fR \fIIdentifier\fR [\fIOptionList\fR] \fIValuelist\fR" 4 .IX Item "PUTVAL Identifier [OptionList] Valuelist" Submits one or more values (identified by \fIIdentifier\fR, see below) to the daemon which will dispatch it to all its write-plugins. .Sp An \fIIdentifier\fR is of the form \&\f(CW\*(C`\fR\f(CIhost\fR\f(CB/\fR\f(CW\fR\f(CIplugin\fR\f(CW\fR\f(CB\-\fR\f(CW\fR\f(CIinstance\fR\f(CW\fR\f(CB/\fR\f(CW\fR\f(CItype\fR\f(CW\fR\f(CB\-\fR\f(CW\fR\f(CIinstance\fR\f(CW\*(C'\fR with both \&\fIinstance\fR\-parts being optional. If they're omitted the hyphen must be omitted, too. \fIplugin\fR and each \fIinstance\fR\-part may be chosen freely as long as the tuple (plugin, plugin instance, type instance) uniquely identifies the plugin within collectd. \fItype\fR identifies the type and number of values (i.\ e. data-set) passed to collectd. A large list of predefined data-sets is available in the \fBtypes.db\fR file. See \fBtypes.db\fR\|(5) for a description of the format of this file. .Sp The \fIOptionList\fR is an optional list of \fIOptions\fR, where each option is a key-value-pair. A list of currently understood options can be found below, all other options will be ignored. Values that contain spaces must be quoted with double quotes. .Sp \&\fIValuelist\fR is a colon-separated list of the time and the values, each either an integer if the data-source is a counter, or a double if the data-source is of type "gauge". You can submit an undefined gauge-value by using \fBU\fR. When submitting \fBU\fR to a counter the behavior is undefined. The time is given as epoch (i.\ e. standard UNIX time) or \fBN\fR to use the current time. .Sp You can mix options and values, but the order is important: Options only effect following values, so specifying an option as last field is allowed, but useless. Also, an option applies to \fBall\fR following values, so you don't need to re-set an option over and over again. .Sp The currently defined \fBOptions\fR are: .RS 4 .IP \fBinterval=\fR\fIseconds\fR 4 .IX Item "interval=seconds" Gives the interval in which the data identified by \fIIdentifier\fR is being collected. .IP meta:\fBkey\fR=\fIvalue\fR 4 .IX Item "meta:key=value" Add meta data with the key \fBkey\fR and the value \fIvalue\fR. .RE .RS 4 .Sp Please note that this is the same format as used in the \fBunixsock plugin\fR, see \&\fBcollectd\-unixsock\fR\|(5). There's also a bit more information on identifiers in case you're confused. .Sp Since examples usually let one understand a lot better, here are some: .Sp .Vb 2 \& PUTVAL leeloo/cpu\-0/cpu\-idle N:2299366 \& PUTVAL alice/interface/if_octets\-eth0 interval=10 1180647081:421465:479194 .Ve .RE .IP "\fBPUTNOTIF\fR [\fIOptionList\fR] \fBmessage=\fR\fIMessage\fR" 4 .IX Item "PUTNOTIF [OptionList] message=Message" Submits a notification to the daemon which will then dispatch it to all plugins which have registered for receiving notifications. .Sp The \fBPUTNOTIF\fR if followed by a list of options which further describe the notification. The \fBmessage\fR option is special in that it will consume the rest of the line as its value. The \fBmessage\fR, \fBseverity\fR, and \fBtime\fR options are mandatory. .Sp Valid options are: .RS 4 .IP "\fBmessage=\fR\fIMessage\fR (\fBREQUIRED\fR)" 4 .IX Item "message=Message (REQUIRED)" Sets the message of the notification. This is the message that will be made accessible to the user, so it should contain some useful information. As with all options: If the message includes spaces, it must be quoted with double quotes. This option is mandatory. .IP "\fBseverity=failure\fR|\fBwarning\fR|\fBokay\fR (\fBREQUIRED\fR)" 4 .IX Item "severity=failure|warning|okay (REQUIRED)" Sets the severity of the notification. This option is mandatory. .IP "\fBtime=\fR\fITime\fR (\fBREQUIRED\fR)" 4 .IX Item "time=Time (REQUIRED)" Sets the time of the notification. The time is given as "epoch", i.\ e. as seconds since January 1st, 1970, 00:00:00. This option is mandatory. .IP \fBhost=\fR\fIHostname\fR 4 .IX Item "host=Hostname" .PD 0 .IP \fBplugin=\fR\fIPlugin\fR 4 .IX Item "plugin=Plugin" .IP \fBplugin_instance=\fR\fIPlugin-Instance\fR 4 .IX Item "plugin_instance=Plugin-Instance" .IP \fBtype=\fR\fIType\fR 4 .IX Item "type=Type" .IP \fBtype_instance=\fR\fIType-Instance\fR 4 .IX Item "type_instance=Type-Instance" .PD These "associative" options establish a relation between this notification and collected performance data. This connection is purely informal, i.\ e. the daemon itself doesn't do anything with this information. However, websites or GUIs may use this information to place notifications near the affected graph or table. All the options are optional, but \fBplugin_instance\fR without \fBplugin\fR or \fBtype_instance\fR without \fBtype\fR doesn't make much sense and should be avoided. .IP \fBtype:key=\fR\fIvalue\fR 4 .IX Item "type:key=value" Sets user defined meta information. The \fBtype\fR key is a single character defining the type of the meta information. .Sp The current supported types are: .RS 4 .IP "\fBs\fR A string passed as-is." 8 .IX Item "s A string passed as-is." .RE .RS 4 .RE .RE .RS 4 .RE .PP Please note that this is the same format as used in the \fBunixsock plugin\fR, see \&\fBcollectd\-unixsock\fR\|(5). .PP When collectd exits it sends a \fBSIGTERM\fR to all still running child-processes upon which they have to quit. .SH "NOTIFICATION DATA FORMAT" .IX Header "NOTIFICATION DATA FORMAT" The notification executables receive values rather than providing them. In fact, after the program is started \f(CW\*(C`STDOUT\*(C'\fR is connected to \f(CW\*(C`/dev/null\*(C'\fR. .PP The data is passed to the executables over \f(CW\*(C`STDIN\*(C'\fR in a format very similar to HTTP: At first there is a "header" with one line per field. Every line consists of a field name, ended by a colon, and the associated value until end-of-line. The "header" is ended by two newlines immediately following another, i.e. an empty line. The rest, basically the "body", is the message of the notification. .PP The following is an example notification passed to a program: .PP .Vb 5 \& Severity: FAILURE \& Time: 1200928930.515 \& Host: myhost.mydomain.org \& \en \& This is a test notification to demonstrate the format .Ve .PP The following header files are currently used. Please note, however, that you should ignore unknown header files to be as forward-compatible as possible. .IP \fBSeverity\fR 4 .IX Item "Severity" Severity of the notification. May either be \fBFAILURE\fR, \fBWARNING\fR, or \fBOKAY\fR. .IP \fBTime\fR 4 .IX Item "Time" The time in epoch, i.e. as seconds since 1970\-01\-01 00:00:00 UTC. The value currently has millisecond precision (i.e. three decimal places), but scripts should accept arbitrary numbers of decimal places, including no decimal places. .IP \fBHost\fR 4 .IX Item "Host" .PD 0 .IP \fBPlugin\fR 4 .IX Item "Plugin" .IP \fBPluginInstance\fR 4 .IX Item "PluginInstance" .IP \fBType\fR 4 .IX Item "Type" .IP \fBTypeInstance\fR 4 .IX Item "TypeInstance" .PD Identification of the performance data this notification is associated with. All of these fields are optional because notifications do not \fBneed\fR to be associated with a certain value. .SH ENVIRONMENT .IX Header "ENVIRONMENT" The following environment variables are set by the plugin before calling \&\fIexec\fR: .IP COLLECTD_INTERVAL 4 .IX Item "COLLECTD_INTERVAL" Value of the global interval setting. .IP COLLECTD_HOSTNAME 4 .IX Item "COLLECTD_HOSTNAME" Hostname used by \fIcollectd\fR to dispatch local values. .SH "USING NAGIOS PLUGINS" .IX Header "USING NAGIOS PLUGINS" Though the interface is far from perfect, there are tons of plugins for Nagios. You can use these plugins with collectd by using a simple transition layer, \&\f(CW\*(C`exec\-nagios.px\*(C'\fR, which is shipped with the collectd distribution in the \&\f(CW\*(C`contrib/\*(C'\fR directory. It is a simple Perl script that comes with embedded documentation. To see it, run the following command: .PP .Vb 1 \& perldoc exec\-nagios.px .Ve .PP This script expects a configuration file, \f(CW\*(C`exec\-nagios.conf\*(C'\fR. You can find an example in the \f(CW\*(C`contrib/\*(C'\fR directory, too. .PP Even a simple mechanism to submit "performance data" to collectd is implemented. If you need a more sophisticated setup, please rewrite the plugin to make use of collectd's more powerful interface. .SH CAVEATS .IX Header "CAVEATS" .IP \(bu 4 The user, the binary is executed as, may not have root privileges, i.\ e. must have an UID that is non-zero. This is for your own good. .IP \(bu 4 Early versions of the plugin did not use a command but treated all lines as if they were arguments to the \fIPUTVAL\fR command. When the \fIPUTNOTIF\fR command was implemented, this behavior was kept for lines which start with an unknown command for backwards compatibility. This compatibility code has been removed in \fIcollectd\ 5\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBcollectd\fR\|(1), \&\fBcollectd.conf\fR\|(5), \&\fBcollectd\-perl\fR\|(5), \&\fBcollectd\-unixsock\fR\|(5), \&\fBfork\fR\|(2), \fBexec\fR\|(3) .SH AUTHOR .IX Header "AUTHOR" Florian Forster