COLLECTD-UNIXSOCK(5)
okay so welcome to COLLECTD-UNIXSOCK(5) β that's section 5 of the collectd manual, bestie, and it's entirely about the unixsock plugin. grab a snack, we're getting into it π
β¨ NAME β¨
collectd-unixsock β literally the documentation for collectd's unixsock plugin. that's it. that's the name. π
π¦ SYNOPSIS π¦
# See collectd.conf(5)
LoadPlugin unixsock
# ...
<Plugin unixsock>
SocketFile "/path/to/socket"
SocketGroup "collectd"
SocketPerms "0770"
DeleteSocket false
</Plugin>
πΈ DESCRIPTION πΈ
the unixsock plugin opens an UNIX-socket, and over that socket you can interact with the daemon. iconic behavior honestly. so you can take the values collectd collected and use them in other applications β monitoring solutions, whatever you want β or you can push externally collected values into collectd. both directions, we contain multitudes π«Ά
for example (and this is a real one, no cap), this plugin is used by collectd-nagios(1) to check if some value is in a certain range and then exit with a Nagios-compatible exit code. teamwork!
π COMMANDS π
when it starts up, the unixsock plugin opens a UNIX-socket and just waits for connections. once a connection is established, the client can send commands to the daemon, and the daemon will answer them β if it understands them. (if it doesn'tβ¦ well. π)
generally the plugin answers with a status line shaped like this:
Status Message
so: if Status is greater than or equal to zero, that means success π. if Status is less than zero, that means failure π. Message is a human-readable string that further describes the return value β it's the little narrator of your socket journey.
on success, Status furthermore indicates the number of subsequent lines of output (not including the status line itself). each of those lines usually contains a single return value. see the description of each command for the details, bestie.
the following commands are implemented:
GETVALIdentifier β if the value identified by Identifier (see below, keep reading π) is found, the complete value-list is returned. the response is a list of name-value-pairs, each pair on its own line (and the number of lines is indicated by the status line β see above, we just talked about this). each name-value-pair is of the formname=value. Counter-values are converted to a rate, e. g. bytes per second. Undefined values are returned asNaN. slay.
Example:
-> | GETVAL myhost/cpu-0/cpu-user
<- | 1 Value found
<- | value=1.260000e+00
LISTVALβ returns a list of the values available in the value cache together with the time of the last update, so that querying applications can issue aGETVALcommand for the values that have changed. each return value consists of the update time as an epoch value and the identifier, separated by a space. heads up though: the update time is the time of the last value, as provided by the collecting instance, and may be very different from the time the server considers to be "now". so don't come for the server's clock, they're different things β¨
Example:
-> | LISTVAL
<- | 69 Values found
<- | 1182204284 myhost/cpu-0/cpu-idle
<- | 1182204284 myhost/cpu-0/cpu-nice
<- | 1182204284 myhost/cpu-0/cpu-system
<- | 1182204284 myhost/cpu-0/cpu-user
...
PUTVALIdentifier [OptionList] Valuelist β submits one or more values (identified by Identifier, see below) to the daemon, which will dispatch it to all its write-plugins. king behavior.
an Identifier is of the form "host/plugin-instance/type-instance" with both instance-parts being optional. if they're omitted the hyphen must be omitted, too (yes, both of them, don't leave a stray hyphen hanging around π). plugin and each instance-part may be chosen freely as long as the tuple (plugin, plugin instance, type instance) uniquely identifies the plugin within collectd. type 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 types.db file β go look, it's giving encyclopedia.
the OptionList is an optional list of Options, where each option is a key-value-pair. a list of currently understood options can be found below, and all other options will be ignored (rude but okay). values that contain spaces must be quoted with double quotes.
Valuelist 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 U. when submitting U to a counter the behavior is undefined β so like, don't π. the time is given as epoch (i. e. standard UNIX time).
you can mix options and values, but the order is important: Options only affect following values, so specifying an option as last field is allowed, but useless (literally pointless, why would you). also, an option applies to all following values, so you don't need to re-set an option over and over again. we love efficiency π
the currently defined Options are:
interval=secondsβ gives the interval in which the data identified by Identifier is being collected.meta:key=valueβ add meta data with the key key and the value value.
please note that this is the same format as used in the exec plugin, see collectd-exec(5).
Example:
-> | PUTVAL testhost/interface/if_octets-test0 interval=10 1179574444:123:456
<- | 0 Success
PUTNOTIF[OptionList]message=Message β submits a notification to the daemon, which will then dispatch it to all plugins which have registered for receiving notifications. π£
the PUTNOTIF command is followed by a list of options which further describe the notification. the message option is special in that it will consume the rest of the line as its value (iconic, honestly). the message, severity, and time options are mandatory β all three, no skipping.
valid options are:
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.severity=failure|warning|okay(REQUIRED) β sets the severity of the notification. this option is mandatory.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.host=Hostname,plugin=Plugin,plugin_instance=Plugin-Instance,type=Type,type_instance=Type-Instance β 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 β cute little context clues π. all the options are optional, butplugin_instancewithoutpluginortype_instancewithouttypedoesn't make much sense and should be avoided.type:key=valueβ sets user defined meta information. the type key is a single character defining the type of the meta information.
the current supported types are:
sβ A string passed as-is.
please note that this is the same format as used in the exec plugin, see collectd-exec(5).
Example:
-> | PUTNOTIF type=temperature severity=warning time=1201094702 message=The roof is on fire!
<- | 0 Success
FLUSH[timeout=Timeout] [plugin=Plugin [...]] [identifier=Ident [...]] β flushes all cached data older than Timeout seconds. if no timeout has been specified, it defaults to-1, which causes all data to be flushed. everything. the whole cache. π«§
if the plugin option has been specified, only the Plugin plugin will be flushed. you can have multiple plugin options to flush multiple plugins in one go. if the plugin option is not given, all plugins providing a flush callback will be flushed.
if the identifier option is given, only the specified values will be flushed. this is meant to be used by graphing or displaying frontends which want to have the latest values for a specific graph. again, you can specify the identifier option multiple times to flush several values. if this option is not specified at all, all values will be flushed.
Example:
-> | FLUSH plugin=rrdtool identifier=localhost/df/df-root identifier=localhost/df/df-var
<- | 0 Done: 2 successful, 0 errors
π§ Identifiers π§
value or value-lists are identified in a uniform fashion:
Hostname/Plugin/Type
where Plugin and Type are both either of type "Name" or "Name-Instance". if the identifier includes spaces, it must be quoted using double quotes. this sounds more complicated than it is (it always does, doesn't it π), so here are some examples:
myhost/cpu-0/cpu-user
myhost/load/load
myhost/memory/memory-used
myhost/disk-sda/disk_octets
"myups/snmp/temperature-Outlet 1"
see? look at that last one doing its little quoted thing. ate. π₯
π ABSTRACTION LAYER π
collectd ships the Perl-Module Collectd::Unixsock which provides an abstraction layer over the actual socket connection. it can be found in the directory bindings/perl/ in the source distribution or (usually) somewhere near /usr/share/perl5/ if you're using a package. if you want to use Perl to communicate with the daemon, you're encouraged to use and expand this module β go off, Perl besties πͺπ
π SEE ALSO π
collectd(1), collectd.conf(5), collectd-nagios(1), unix(7)
β AUTHOR β
Florian Forster <octo@collectd.org> β the main character who wrote this π
okay that's the whole page, go build something cute with it. this masterpiece is version 5.12.0.348.g93f9bdcb and it's dated 2024-12-18 β mwah, xoxo, happy socketing bestie π
β¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: collectd 5.12.0.348.g93f9bdcb-bp160.1.1 Β· GPL-2.0-only AND MIT
- opensuse-leap 16.0: collectd 5.12.0.348.g93f9bdcb-bp160.1.1 Β· GPL-2.0-only AND MIT
- opensuse-leap 16.0: collectd 5.12.0.348.g93f9bdcb-bp160.1.1 Β· GPL-2.0-only AND MIT
- opensuse-leap 16.0: collectd 5.12.0.348.g93f9bdcb-bp160.1.1 Β· GPL-2.0-only AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms