1COLLECTD-EXEC(5) collectd COLLECTD-EXEC(5)
2
3
4
6 collectd-exec - Documentation of collectd's "exec plugin"
7
9 # See collectd.conf(5)
10 LoadPlugin exec
11 # ...
12 <Plugin exec>
13 Exec "myuser:mygroup" "myprog"
14 Exec "otheruser" "/path/to/another/binary" "arg0" "arg1"
15 NotificationExec "user" "/usr/lib/collectd/exec/handle_notification"
16 </Plugin>
17
19 The "exec plugin" forks off an executable either to receive values or
20 to dispatch notifications to the outside world. The syntax of the
21 configuration is explained in collectd.conf(5) but summarized in the
22 above synopsis.
23
24 If you want/need better performance or more functionality you should
25 take a long look at the "perl plugin", collectd-perl(5).
26
28 There are currently two types of executables that can be executed by
29 the "exec plugin":
30
31 "Exec"
32 These programs are forked and values that it writes to "STDOUT" are
33 read back. The executable is forked in a fashion similar to init:
34 It is forked once and not again until it exits. If it exited, it
35 will be forked again after at most Interval seconds. It is
36 perfectly legal for the executable to run for a long time and
37 continuously write values to "STDOUT".
38
39 See "EXEC DATA FORMAT" below for a description of the output format
40 expected from these programs.
41
42 Warning: If the executable only writes one value and then exits it
43 will be executed every Interval seconds. If Interval is short (the
44 default is 10 seconds) this may result in serious system load.
45
46 "NotificationExec"
47 The program is forked once for each notification that is handled by
48 the daemon. The notification is passed to the program on "STDIN"
49 in a fashion similar to HTTP-headers. In contrast to programs
50 specified with "Exec" the execution of this program is not
51 serialized, so that several instances of this program may run at
52 once if multiple notifications are received.
53
54 See "NOTIFICATION DATA FORMAT" below for a description of the data
55 passed to these programs.
56
58 The forked executable is expected to print values to "STDOUT". The
59 expected format is as follows:
60
61 Comments
62 Each line beginning with a "#" (hash mark) is ignored.
63
64 PUTVAL Identifier [OptionList] Valuelist
65 Submits one or more values (identified by Identifier, see below) to
66 the daemon which will dispatch it to all its write-plugins.
67
68 An Identifier is of the form "host/plugin-instance/type-instance"
69 with both instance-parts being optional. If they're omitted the
70 hyphen must be omitted, too. plugin and each instance-part may be
71 chosen freely as long as the tuple (plugin, plugin instance, type
72 instance) uniquely identifies the plugin within collectd. type
73 identifies the type and number of values (i. e. data-set) passed to
74 collectd. A large list of predefined data-sets is available in the
75 types.db file. See types.db(5) for a description of the format of
76 this file.
77
78 The OptionList is an optional list of Options, where each option is
79 a key-value-pair. A list of currently understood options can be
80 found below, all other options will be ignored. Values that contain
81 spaces must be quoted with double quotes.
82
83 Valuelist is a colon-separated list of the time and the values,
84 each either an integer if the data-source is a counter, or a double
85 if the data-source is of type "gauge". You can submit an undefined
86 gauge-value by using U. When submitting U to a counter the behavior
87 is undefined. The time is given as epoch (i. e. standard UNIX time)
88 or N to use the current time.
89
90 You can mix options and values, but the order is important: Options
91 only effect following values, so specifying an option as last field
92 is allowed, but useless. Also, an option applies to all following
93 values, so you don't need to re-set an option over and over again.
94
95 The currently defined Options are:
96
97 interval=seconds
98 Gives the interval in which the data identified by Identifier
99 is being collected.
100
101 meta:key=value
102 Add meta data with the key key and the value value.
103
104 Please note that this is the same format as used in the unixsock
105 plugin, see collectd-unixsock(5). There's also a bit more
106 information on identifiers in case you're confused.
107
108 Since examples usually let one understand a lot better, here are
109 some:
110
111 PUTVAL leeloo/cpu-0/cpu-idle N:2299366
112 PUTVAL alice/interface/if_octets-eth0 interval=10 1180647081:421465:479194
113
114 PUTNOTIF [OptionList] message=Message
115 Submits a notification to the daemon which will then dispatch it to
116 all plugins which have registered for receiving notifications.
117
118 The PUTNOTIF if followed by a list of options which further
119 describe the notification. The message option is special in that it
120 will consume the rest of the line as its value. The message,
121 severity, and time options are mandatory.
122
123 Valid options are:
124
125 message=Message (REQUIRED)
126 Sets the message of the notification. This is the message that
127 will be made accessible to the user, so it should contain some
128 useful information. As with all options: If the message
129 includes spaces, it must be quoted with double quotes. This
130 option is mandatory.
131
132 severity=failure|warning|okay (REQUIRED)
133 Sets the severity of the notification. This option is
134 mandatory.
135
136 time=Time (REQUIRED)
137 Sets the time of the notification. The time is given as
138 "epoch", i. e. as seconds since January 1st, 1970, 00:00:00.
139 This option is mandatory.
140
141 host=Hostname
142 plugin=Plugin
143 plugin_instance=Plugin-Instance
144 type=Type
145 type_instance=Type-Instance
146 These "associative" options establish a relation between this
147 notification and collected performance data. This connection is
148 purely informal, i. e. the daemon itself doesn't do anything
149 with this information. However, websites or GUIs may use this
150 information to place notifications near the affected graph or
151 table. All the options are optional, but plugin_instance
152 without plugin or type_instance without type doesn't make much
153 sense and should be avoided.
154
155 type:key=value
156 Sets user defined meta information. The type key is a single
157 character defining the type of the meta information.
158
159 The current supported types are:
160
161 s A string passed as-is.
162
163 Please note that this is the same format as used in the unixsock
164 plugin, see collectd-unixsock(5).
165
166 When collectd exits it sends a SIGTERM to all still running child-
167 processes upon which they have to quit.
168
170 The notification executables receive values rather than providing them.
171 In fact, after the program is started "STDOUT" is connected to
172 "/dev/null".
173
174 The data is passed to the executables over "STDIN" in a format very
175 similar to HTTP: At first there is a "header" with one line per field.
176 Every line consists of a field name, ended by a colon, and the
177 associated value until end-of-line. The "header" is ended by two
178 newlines immediately following another, i.e. an empty line. The rest,
179 basically the "body", is the message of the notification.
180
181 The following is an example notification passed to a program:
182
183 Severity: FAILURE
184 Time: 1200928930.515
185 Host: myhost.mydomain.org
186 \n
187 This is a test notification to demonstrate the format
188
189 The following header files are currently used. Please note, however,
190 that you should ignore unknown header files to be as forward-compatible
191 as possible.
192
193 Severity
194 Severity of the notification. May either be FAILURE, WARNING, or
195 OKAY.
196
197 Time
198 The time in epoch, i.e. as seconds since 1970-01-01 00:00:00 UTC.
199 The value currently has millisecond precision (i.e. three decimal
200 places), but scripts should accept arbitrary numbers of decimal
201 places, including no decimal places.
202
203 Host
204 Plugin
205 PluginInstance
206 Type
207 TypeInstance
208 Identification of the performance data this notification is
209 associated with. All of these fields are optional because
210 notifications do not need to be associated with a certain value.
211
213 The following environment variables are set by the plugin before
214 calling exec:
215
216 COLLECTD_INTERVAL
217 Value of the global interval setting.
218
219 COLLECTD_HOSTNAME
220 Hostname used by collectd to dispatch local values.
221
223 Though the interface is far from perfect, there are tons of plugins for
224 Nagios. You can use these plugins with collectd by using a simple
225 transition layer, "exec-nagios.px", which is shipped with the collectd
226 distribution in the "contrib/" directory. It is a simple Perl script
227 that comes with embedded documentation. To see it, run the following
228 command:
229
230 perldoc exec-nagios.px
231
232 This script expects a configuration file, "exec-nagios.conf". You can
233 find an example in the "contrib/" directory, too.
234
235 Even a simple mechanism to submit "performance data" to collectd is
236 implemented. If you need a more sophisticated setup, please rewrite the
237 plugin to make use of collectd's more powerful interface.
238
240 · The user, the binary is executed as, may not have root privileges,
241 i. e. must have an UID that is non-zero. This is for your own
242 good.
243
244 · Early versions of the plugin did not use a command but treated all
245 lines as if they were arguments to the PUTVAL command. When the
246 PUTNOTIF command was implemented, this behavior was kept for lines
247 which start with an unknown command for backwards compatibility.
248 This compatibility code has been removed in collectd 5.
249
251 collectd(1), collectd.conf(5), collectd-perl(5), collectd-unixsock(5),
252 fork(2), exec(3)
253
255 Florian Forster <octo@collectd.org>
256
257
258
2595.9.1.599.gbb5cfbc 2020-03-08 COLLECTD-EXEC(5)