1COLLECTD-UNIXSOCK(5) collectd COLLECTD-UNIXSOCK(5)
2
3
4
6 collectd-unixsock - Documentation of collectd's "unixsock plugin"
7
9 # See collectd.conf(5)
10 LoadPlugin unixsock
11 # ...
12 <Plugin unixsock>
13 SocketFile "/path/to/socket"
14 SocketGroup "collectd"
15 SocketPerms "0770"
16 DeleteSocket false
17 </Plugin>
18
20 The "unixsock plugin" opens an UNIX-socket over which one can interact
21 with the daemon. This can be used to use the values collected by
22 collectd in other applications, such as monitoring solutions, or submit
23 externally collected values to collectd.
24
25 For example, this plugin is used by collectd-nagios(1) to check if some
26 value is in a certain range and exit with a Nagios-compatible exit
27 code.
28
30 Upon start the "unixsock plugin" opens a UNIX-socket and waits for
31 connections. Once a connection is established the client can send
32 commands to the daemon which it will answer, if it understand them.
33
34 In general the plugin answers with a status line of the following form:
35
36 Status Message
37
38 If Status is greater than or equal to zero the message indicates
39 success, if Status is less than zero the message indicates failure.
40 Message is a human-readable string that further describes the return
41 value.
42
43 On success, Status furthermore indicates the number of subsequent lines
44 of output (not including the status line). Each such lines usually
45 contains a single return value. See the description of each command for
46 details.
47
48 The following commands are implemented:
49
50 GETVAL Identifier
51 If the value identified by Identifier (see below) is found the
52 complete value-list is returned. The response is a list of name-
53 value-pairs, each pair on its own line (the number of lines is
54 indicated by the status line - see above). Each name-value-pair is
55 of the form name=value. Counter-values are converted to a rate,
56 e. g. bytes per second. Undefined values are returned as NaN.
57
58 Example:
59 -> | GETVAL myhost/cpu-0/cpu-user
60 <- | 1 Value found
61 <- | value=1.260000e+00
62
63 LISTVAL
64 Returns a list of the values available in the value cache together
65 with the time of the last update, so that querying applications can
66 issue a GETVAL command for the values that have changed. Each
67 return value consists of the update time as an epoch value and the
68 identifier, separated by a space. The update time is the time of
69 the last value, as provided by the collecting instance and may be
70 very different from the time the server considers to be "now".
71
72 Example:
73 -> | LISTVAL
74 <- | 69 Values found
75 <- | 1182204284 myhost/cpu-0/cpu-idle
76 <- | 1182204284 myhost/cpu-0/cpu-nice
77 <- | 1182204284 myhost/cpu-0/cpu-system
78 <- | 1182204284 myhost/cpu-0/cpu-user
79 ...
80
81 PUTVAL Identifier [OptionList] Valuelist
82 Submits one or more values (identified by Identifier, see below) to
83 the daemon which will dispatch it to all its write-plugins.
84
85 An Identifier is of the form "host/plugin-instance/type-instance"
86 with both instance-parts being optional. If they're omitted the
87 hyphen must be omitted, too. plugin and each instance-part may be
88 chosen freely as long as the tuple (plugin, plugin instance, type
89 instance) uniquely identifies the plugin within collectd. type
90 identifies the type and number of values (i. e. data-set) passed to
91 collectd. A large list of predefined data-sets is available in the
92 types.db file.
93
94 The OptionList is an optional list of Options, where each option is
95 a key-value-pair. A list of currently understood options can be
96 found below, all other options will be ignored. Values that contain
97 spaces must be quoted with double quotes.
98
99 Valuelist is a colon-separated list of the time and the values,
100 each either an integer if the data-source is a counter, or a double
101 if the data-source is of type "gauge". You can submit an undefined
102 gauge-value by using U. When submitting U to a counter the behavior
103 is undefined. The time is given as epoch (i. e. standard UNIX
104 time).
105
106 You can mix options and values, but the order is important: Options
107 only effect following values, so specifying an option as last field
108 is allowed, but useless. Also, an option applies to all following
109 values, so you don't need to re-set an option over and over again.
110
111 The currently defined Options are:
112
113 interval=seconds
114 Gives the interval in which the data identified by Identifier
115 is being collected.
116
117 meta:key=value
118 Add meta data with the key key and the value value.
119
120 Please note that this is the same format as used in the exec
121 plugin, see collectd-exec(5).
122
123 Example:
124 -> | PUTVAL testhost/interface/if_octets-test0 interval=10
125 1179574444:123:456
126 <- | 0 Success
127
128 PUTNOTIF [OptionList] message=Message
129 Submits a notification to the daemon which will then dispatch it to
130 all plugins which have registered for receiving notifications.
131
132 The PUTNOTIF command is followed by a list of options which further
133 describe the notification. The message option is special in that it
134 will consume the rest of the line as its value. The message,
135 severity, and time options are mandatory.
136
137 Valid options are:
138
139 message=Message (REQUIRED)
140 Sets the message of the notification. This is the message that
141 will be made accessible to the user, so it should contain some
142 useful information. As with all options: If the message
143 includes spaces, it must be quoted with double quotes. This
144 option is mandatory.
145
146 severity=failure|warning|okay (REQUIRED)
147 Sets the severity of the notification. This option is
148 mandatory.
149
150 time=Time (REQUIRED)
151 Sets the time of the notification. The time is given as
152 "epoch", i. e. as seconds since January 1st, 1970, 00:00:00.
153 This option is mandatory.
154
155 host=Hostname
156 plugin=Plugin
157 plugin_instance=Plugin-Instance
158 type=Type
159 type_instance=Type-Instance
160 These "associative" options establish a relation between this
161 notification and collected performance data. This connection is
162 purely informal, i. e. the daemon itself doesn't do anything
163 with this information. However, websites or GUIs may use this
164 information to place notifications near the affected graph or
165 table. All the options are optional, but plugin_instance
166 without plugin or type_instance without type doesn't make much
167 sense and should be avoided.
168
169 type:key=value
170 Sets user defined meta information. The type key is a single
171 character defining the type of the meta information.
172
173 The current supported types are:
174
175 s A string passed as-is.
176
177 Please note that this is the same format as used in the exec
178 plugin, see collectd-exec(5).
179
180 Example:
181 -> | PUTNOTIF type=temperature severity=warning time=1201094702
182 message=The roof is on fire!
183 <- | 0 Success
184
185 FLUSH [timeout=Timeout] [plugin=Plugin [...]] [identifier=Ident [...]]
186 Flushes all cached data older than Timeout seconds. If no timeout
187 has been specified, it defaults to -1 which causes all data to be
188 flushed.
189
190 If the plugin option has been specified, only the Plugin plugin
191 will be flushed. You can have multiple plugin options to flush
192 multiple plugins in one go. If the plugin option is not given all
193 plugins providing a flush callback will be flushed.
194
195 If the identifier option is given only the specified values will be
196 flushed. This is meant to be used by graphing or displaying
197 frontends which want to have the latest values for a specific
198 graph. Again, you can specify the identifier option multiple times
199 to flush several values. If this option is not specified at all,
200 all values will be flushed.
201
202 Example:
203 -> | FLUSH plugin=rrdtool identifier=localhost/df/df-root
204 identifier=localhost/df/df-var
205 <- | 0 Done: 2 successful, 0 errors
206
207 Identifiers
208 Value or value-lists are identified in a uniform fashion:
209
210 Hostname/Plugin/Type
211
212 Where Plugin and Type are both either of type "Name" or
213 "Name-Instance". If the identifier includes spaces, it must be quoted
214 using double quotes. This sounds more complicated than it is, so here
215 are some examples:
216
217 myhost/cpu-0/cpu-user
218 myhost/load/load
219 myhost/memory/memory-used
220 myhost/disk-sda/disk_octets
221 "myups/snmp/temperature-Outlet 1"
222
224 collectd ships the Perl-Module Collectd::Unixsock which provides an
225 abstraction layer over the actual socket connection. It can be found in
226 the directory bindings/perl/ in the source distribution or (usually)
227 somewhere near /usr/share/perl5/ if you're using a package. If you want
228 to use Perl to communicate with the daemon, you're encouraged to use
229 and expand this module.
230
232 collectd(1), collectd.conf(5), collectd-nagios(1), unix(7)
233
235 Florian Forster <octo@collectd.org>
236
237
238
2395.11.0.94.g41b1e33 2020-07-20 COLLECTD-UNIXSOCK(5)