collectd-unixsock(5): Fixed some typos.
[collectd.git] / src / collectd-unixsock.pod
1 =head1 NAME
2
3 collectd-unixsock - Documentation of collectd's C<unixsock plugin>
4
5 =head1 SYNOPSIS
6
7   # See collectd.conf(5)
8   LoadPlugin unixsock
9   # ...
10   <Plugin unixsock>
11     SocketFile "/path/to/socket"
12     SocketGroup "collectd"
13     SocketPerms "0770"
14   </Plugin>
15
16 =head1 DESCRIPTION
17
18 The C<unixsock plugin> opens an UNIX-socket over which one can interact with
19 the daemon. This can be used to use the values collected by collectd in other
20 applications, such as monitoring, or submit externally collected values to
21 collectd.
22
23 This plugin is used by L<collectd-nagios(1)> to check if some value is in a
24 certain range and exit with a Nagios-compatible exit code.
25
26 =head1 COMMANDS
27
28 Upon start the C<unixsock plugin> opens a UNIX-socket and waits for
29 connections. Once a connection is established the client can send commands to
30 the daemon which it will answer, if it understand them.
31
32 The following commands are implemented:
33
34 =over 4
35
36 =item B<GETVAL> I<Identifier>
37
38 If the value identified by I<Identifier> (see below) is found the complete
39 value-list is returned. The response is a space separated list of
40 name-value-pairs:
41
42 I<num> I<name>B<=>I<value>[ I<name>B<=>I<value>[ ...]]
43
44 If I<num> is less then zero, an error occurred. Otherwise it contains the
45 number of values that follow. Each value is of the form I<name>B<=>I<value>.
46 Counter-values are converted to a rate, e.E<nbsp>g. bytes per second.
47 Undefined values are returned as B<NaN>.
48
49 Example:
50   -> | GETVAL myhost/cpu-0/cpu-user
51   <- | 1 value=1.260000e+00
52
53 =item B<LISTVAL>
54
55 Returns a list of the values available in the value cache together with the
56 time of the last update, so that querying applications can issue a B<GETVAL>
57 command for the values that have changed.
58
59 The first line's status number is the number of identifiers returned or less
60 than zero if an error occurred. Each of the following lines contains the
61 update time as an epoch value and the identifier, separated by a space.
62
63 Example:
64   -> | LISTVAL
65   <- | 69 Values found
66   <- | 1182204284 leeloo/cpu-0/cpu-idle
67   <- | 1182204284 leeloo/cpu-0/cpu-nice
68   <- | 1182204284 leeloo/cpu-0/cpu-system
69   <- | 1182204284 leeloo/cpu-0/cpu-user
70   ...
71
72 =item B<PUTVAL> I<Identifier> [I<OptionList>] I<Valuelist>
73
74 Submits one or more values (identified by I<Identifier>, see below) to the
75 daemon which will dispatch it to all it's write-plugins.
76
77 An I<Identifier> is of the form
78 C<I<host>B</>I<plugin>B<->I<instance>B</>I<type>B<->I<instance>> with both
79 I<instance>-parts being optional. If they're omitted the hyphen must be
80 omitted, too. I<plugin> and each I<instance>-part may be chosen freely as long
81 as the tuple (plugin, plugin instance, type instance) uniquely identifies the
82 plugin within collectd. I<type> identifies the type and number of values
83 (i.E<nbsp>e. data-set) passed to collectd. A large list of predefined
84 data-sets is available in the B<types.db> file.
85
86 The I<OptionList> is an optional list of I<Options>, where each option is a
87 key-value-pair. A list of currently understood options can be found below, all
88 other options will be ignored.
89
90 I<Valuelist> is a colon-separated list of the time and the values, each either
91 an integer if the data-source is a counter, or a double if the data-source is
92 of type "gauge". You can submit an undefined gauge-value by using B<U>. When
93 submitting B<U> to a counter the behavior is undefined. The time is given as
94 epoch (i.E<nbsp>e. standard UNIX time).
95
96 You can mix options and values, but the order is important: Options only
97 effect following values, so specifying an option as last field is allowed, but
98 useless. Also, an option applies to B<all> following values, so you don't need
99 to re-set an option over and over again.
100
101 The currently defined B<Options> are:
102
103 =over 4
104
105 =item B<interval=>I<seconds>
106
107 Gives the interval in which the data identified by I<Identifier> is being
108 collected.
109
110 =back
111
112 Please note that this is the same format as used in the B<exec plugin>, see
113 L<collectd-exec(5)>.
114
115 Example:
116   -> | PUTVAL testhost/interface/if_octets-test0 interval=10 1179574444:123:456
117   <- | 0 Success
118
119 =back
120
121 =head2 Identifiers
122
123 Value or value-lists are identified in a uniform fashion:
124
125 I<Hostname>/I<Plugin>/I<Type>
126
127 Where I<Plugin> and I<Type> are both either of type "I<Name>" or
128 "I<Name>-I<Instance>". This sounds more complicated than it is, so here are
129 some examples:
130
131   myhost/cpu-0/cpu-user
132   myhost/load/load
133   myhost/memory/memory-used
134   myhost/disk-sda/disk_octets
135
136 =head2 Return values
137
138 Unless otherwise noted the plugin answers with a line of the following form:
139
140 I<Num> I<Message>
141
142 If I<Num> is zero the message indicates success, if I<Num> is non-zero the
143 message indicates failure. I<Message> is a human-readable string that describes
144 the return value further.
145
146 Commands that return values may use I<Num> to return the number of values that
147 follow, such as the B<GETVAL> command. These commands usually return a negative
148 value on failure and never return zero.
149
150 =head1 ABSTRACTION LAYER
151
152 Shipped with the sourcecode comes the Perl-Module L<Collectd::Unixsock> which
153 provides an abstraction layer over the actual socket connection. It can be
154 found in the directory F<contrib/PerlLib>. If you want to use Perl to
155 communicate with the daemon, you're encouraged to use and expand this module.
156
157 =head1 SEE ALSO
158
159 L<collectd(1)>,
160 L<collectd.conf(5)>,
161 L<collectd-nagios(1)>,
162 L<unix(7)>
163
164 =head1 AUTHOR
165
166 Florian Forster E<lt>octo@verplant.orgE<gt>
167
168 =cut