forked from collectd/collectd
/
collectd.conf.pod
5624 lines (3814 loc) · 178 KB
/
collectd.conf.pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=head1 NAME
collectd.conf - Configuration for the system statistics collection daemon B<collectd>
=head1 SYNOPSIS
BaseDir "/path/to/data/"
PIDFile "/path/to/pidfile/collectd.pid"
Server "123.123.123.123" 12345
LoadPlugin cpu
LoadPlugin load
LoadPlugin ping
<Plugin ping>
Host "example.org"
Host "provider.net"
</Plugin>
=head1 DESCRIPTION
This config file controls how the system statistics collection daemon
B<collectd> behaves. The most significant option is B<LoadPlugin>, which
controls which plugins to load. These plugins ultimately define collectd's
behavior.
The syntax of this config file is similar to the config file of the famous
B<Apache Webserver>. Each line contains either a key-value-pair or a
section-start or -end. Empty lines and everything after the hash-symbol `#' is
ignored. Values are either string, enclosed in double-quotes,
(floating-point-)numbers or a boolean expression, i.E<nbsp>e. either B<true> or
B<false>. String containing of only alphanumeric characters and underscores do
not need to be quoted. Lines may be wrapped by using `\' as the last character
before the newline. This allows long lines to be split into multiple lines.
Quoted strings may be wrapped as well. However, those are treated special in
that whitespace at the beginning of the following lines will be ignored, which
allows for nicely indenting the wrapped lines.
The configuration is read and processed in order, i.E<nbsp>e. from top to
bottom. So the plugins are loaded in the order listed in this config file. It
is a good idea to load any logging plugins first in order to catch messages
from plugins during configuration. Also, the C<LoadPlugin> option B<must> occur
B<before> the C<E<lt>Plugin ...E<gt>> block.
=head1 GLOBAL OPTIONS
=over 4
=item B<BaseDir> I<Directory>
Sets the base directory. This is the directory beneath all RRD-files are
created. Possibly more subdirectories are created. This is also the working
directory for the daemon.
=item B<LoadPlugin> I<Plugin>
Loads the plugin I<Plugin>. There must be at least one such line or B<collectd>
will be mostly useless.
Starting with collectd 4.9, this may also be a block in which further options
affecting the behavior of B<LoadPlugin> may be specified. The following
options are allowed inside a B<LoadPlugin> block:
<LoadPlugin perl>
Globals true
</LoadPlugin>
=over 4
=item B<Globals> B<true|false>
If enabled, collectd will export all global symbols of the plugin (and of all
libraries loaded as dependencies of the plugin) and, thus, makes those symbols
available for resolving unresolved symbols in subsequently loaded plugins if
that is supported by your system.
This is useful (or possibly even required), e.g., when loading a plugin that
embeds some scripting language into the daemon (e.g. the I<Perl> and
I<Python plugins>). Scripting languages usually provide means to load
extensions written in C. Those extensions require symbols provided by the
interpreter, which is loaded as a dependency of the respective collectd plugin.
See the documentation of those plugins (e.g., L<collectd-perl(5)> or
L<collectd-python(5)>) for details.
By default, this is disabled. As a special exception, if the plugin name is
either C<perl> or C<python>, the default is changed to enabled in order to keep
the average user from ever having to deal with this low level linking stuff.
=back
=item B<Include> I<Path>
If I<Path> points to a file, includes that file. If I<Path> points to a
directory, recursively includes all files within that directory and its
subdirectories. If the C<wordexp> function is available on your system,
shell-like wildcards are expanded before files are included. This means you can
use statements like the following:
Include "/etc/collectd.d/*.conf"
If more than one files are included by a single B<Include> option, the files
will be included in lexicographical order (as defined by the C<strcmp>
function). Thus, you can e.E<nbsp>g. use numbered prefixes to specify the
order in which the files are loaded.
To prevent loops and shooting yourself in the foot in interesting ways the
nesting is limited to a depth of 8E<nbsp>levels, which should be sufficient for
most uses. Since symlinks are followed it is still possible to crash the daemon
by looping symlinks. In our opinion significant stupidity should result in an
appropriate amount of pain.
It is no problem to have a block like C<E<lt>Plugin fooE<gt>> in more than one
file, but you cannot include files from within blocks.
=item B<PIDFile> I<File>
Sets where to write the PID file to. This file is overwritten when it exists
and deleted when the program is stopped. Some init-scripts might override this
setting using the B<-P> command-line option.
=item B<PluginDir> I<Directory>
Path to the plugins (shared objects) of collectd.
=item B<TypesDB> I<File> [I<File> ...]
Set one or more files that contain the data-set descriptions. See
L<types.db(5)> for a description of the format of this file.
=item B<Interval> I<Seconds>
Configures the interval in which to query the read plugins. Obviously smaller
values lead to a higher system load produced by collectd, while higher values
lead to more coarse statistics.
B<Warning:> You should set this once and then never touch it again. If you do,
I<you will have to delete all your RRD files> or know some serious RRDtool
magic! (Assuming you're using the I<RRDtool> or I<RRDCacheD> plugin.)
=item B<Timeout> I<Iterations>
Consider a value list "missing" when no update has been read or received for
I<Iterations> iterations. By default, I<collectd> considers a value list
missing when no update has been received for twice the update interval. Since
this setting uses iterations, the maximum allowed time without update depends
on the I<Interval> information contained in each value list. This is used in
the I<Threshold> configuration to dispatch notifications about missing values,
see L<collectd-threshold(5)> for details.
=item B<ReadThreads> I<Num>
Number of threads to start for reading plugins. The default value is B<5>, but
you may want to increase this if you have more than five plugins that take a
long time to read. Mostly those are plugin that do network-IO. Setting this to
a value higher than the number of plugins you've loaded is totally useless.
=item B<Hostname> I<Name>
Sets the hostname that identifies a host. If you omit this setting, the
hostname will be determined using the L<gethostname(2)> system call.
=item B<FQDNLookup> B<true|false>
If B<Hostname> is determined automatically this setting controls whether or not
the daemon should try to figure out the "fully qualified domain name", FQDN.
This is done using a lookup of the name returned by C<gethostname>. This option
is enabled by default.
=item B<PreCacheChain> I<ChainName>
=item B<PostCacheChain> I<ChainName>
Configure the name of the "pre-cache chain" and the "post-cache chain". Please
see L<FILTER CONFIGURATION> below on information on chains and how these
setting change the daemon's behavior.
=back
=head1 PLUGIN OPTIONS
Some plugins may register own options. These options must be enclosed in a
C<Plugin>-Section. Which options exist depends on the plugin used. Some plugins
require external configuration, too. The C<apache plugin>, for example,
required C<mod_status> to be configured in the webserver you're going to
collect data from. These plugins are listed below as well, even if they don't
require any configuration within collectd's configfile.
A list of all plugins and a short summary for each plugin can be found in the
F<README> file shipped with the sourcecode and hopefully binary packets as
well.
=head2 Plugin C<amqp>
The I<AMQMP plugin> can be used to communicate with other instances of
I<collectd> or third party applications using an AMQP message broker. Values
are sent to or received from the broker, which handles routing, queueing and
possibly filtering or messages.
<Plugin "amqp">
# Send values to an AMQP broker
<Publish "some_name">
Host "localhost"
Port "5672"
VHost "/"
User "guest"
Password "guest"
Exchange "amq.fanout"
# ExchangeType "fanout"
# RoutingKey "collectd"
# Persistent false
# Format "command"
# StoreRates false
</Publish>
# Receive values from an AMQP broker
<Subscribe "some_name">
Host "localhost"
Port "5672"
VHost "/"
User "guest"
Password "guest"
Exchange "amq.fanout"
# ExchangeType "fanout"
# Queue "queue_name"
# RoutingKey "collectd.#"
</Subscribe>
</Plugin>
The plugin's configuration consists of a number of I<Publish> and I<Subscribe>
blocks, which configure sending and receiving of values respectively. The two
blocks are very similar, so unless otherwise noted, an option can be used in
either block. The name given in the blocks starting tag is only used for
reporting messages, but may be used to support I<flushing> of certain
I<Publish> blocks in the future.
=over 4
=item B<Host> I<Host>
Hostname or IP-address of the AMQP broker. Defaults to the default behavior of
the underlying communications library, I<rabbitmq-c>, which is "localhost".
=item B<Port> I<Port>
Service name or port number on which the AMQP broker accepts connections. This
argument must be a string, even if the numeric form is used. Defaults to
"5672".
=item B<VHost> I<VHost>
Name of the I<virtual host> on the AMQP broker to use. Defaults to "/".
=item B<User> I<User>
=item B<Password> I<Password>
Credentials used to authenticate to the AMQP broker. By default "guest"/"guest"
is used.
=item B<Exchange> I<Exchange>
In I<Publish> blocks, this option specifies the I<exchange> to send values to.
By default, "amq.fanout" will be used.
In I<Subscribe> blocks this option is optional. If given, a I<binding> between
the given exchange and the I<queue> is created, using the I<routing key> if
configured. See the B<Queue> and B<RoutingKey> options below.
=item B<ExchangeType> I<Type>
If given, the plugin will try to create the configured I<exchange> with this
I<type> after connecting. When in a I<Subscribe> block, the I<queue> will then
be bound to this exchange.
=item B<Queue> I<Queue> (Subscribe only)
Configures the I<queue> name to subscribe to. If no queue name was configures
explicitly, a unique queue name will be created by the broker.
=item B<RoutingKey> I<Key>
In I<Publish> blocks, this configures the routing key to set on all outgoing
messages. If not given, the routing key will be computed from the I<identifier>
of the value. The host, plugin, type and the two instances are concatenated
together using dots as the separator and all containing dots replaced with
slashes. For example "collectd.host/example/com.cpu.0.cpu.user". This makes it
possible to receive only specific values using a "topic" exchange.
In I<Subscribe> blocks, configures the I<routing key> used when creating a
I<binding> between an I<exchange> and the I<queue>. The usual wildcards can be
used to filter messages when using a "topic" exchange. If you're only
interested in CPU statistics, you could use the routing key "collectd.*.cpu.#"
for example.
=item B<Persistent> B<true>|B<false> (Publish only)
Selects the I<delivery method> to use. If set to B<true>, the I<persistent>
mode will be used, i.e. delivery is guaranteed. If set to B<false> (the
default), the I<transient> delivery mode will be used, i.e. messages may be
lost due to high load, overflowing queues or similar issues.
=item B<Format> B<Command>|B<JSON> (Publish only)
Selects the format in which messages are sent to the broker. If set to
B<Command> (the default), values are sent as C<PUTVAL> commands which are
identical to the syntax used by the I<Exec> and I<UnixSock plugins>. In this
case, the C<Content-Type> header field will be set to C<text/collectd>.
If set to B<JSON>, the values are encoded in the I<JavaScript Object Notation>,
an easy and straight forward exchange format. The C<Content-Type> header field
will be set to C<application/json>.
A subscribing client I<should> use the C<Content-Type> header field to
determine how to decode the values. Currently, the I<AMQP plugin> itself can
only decode the B<Command> format.
=item B<StoreRates> B<true>|B<false> (Publish only)
Determines whether or not C<COUNTER>, C<DERIVE> and C<ABSOLUTE> data sources
are converted to a I<rate> (i.e. a C<GAUGE> value). If set to B<false> (the
default), no conversion is performed. Otherwise the conversion is performed
using the internal value cache.
Please note that currently this option is only used if the B<Format> option has
been set to B<JSON>.
=back
=head2 Plugin C<apache>
To configure the C<apache>-plugin you first need to configure the Apache
webserver correctly. The Apache-plugin C<mod_status> needs to be loaded and
working and the C<ExtendedStatus> directive needs to be B<enabled>. You can use
the following snipped to base your Apache config upon:
ExtendedStatus on
<IfModule mod_status.c>
<Location /mod_status>
SetHandler server-status
</Location>
</IfModule>
Since its C<mod_status> module is very similar to Apache's, B<lighttpd> is
also supported. It introduces a new field, called C<BusyServers>, to count the
number of currently connected clients. This field is also supported.
The configuration of the I<Apache> plugin consists of one or more
C<E<lt>InstanceE<nbsp>/E<gt>> blocks. Each block requires one string argument
as the instance name. For example:
<Plugin "apache">
<Instance "www1">
URL "http://www1.example.com/mod_status?auto"
</Instance>
<Instance "www2">
URL "http://www2.example.com/mod_status?auto"
</Instance>
</Plugin>
The instance name will be used as the I<plugin instance>. To emulate the old
(versionE<nbsp>4) behavior, you can use an empty string (""). In order for the
plugin to work correctly, each instance name must be unique. This is not
enforced by the plugin and it is your responsibility to ensure it.
The following options are accepted within each I<Instance> block:
=over 4
=item B<URL> I<http://host/mod_status?auto>
Sets the URL of the C<mod_status> output. This needs to be the output generated
by C<ExtendedStatus on> and it needs to be the machine readable output
generated by appending the C<?auto> argument. This option is I<mandatory>.
=item B<User> I<Username>
Optional user name needed for authentication.
=item B<Password> I<Password>
Optional password needed for authentication.
=item B<VerifyPeer> B<true|false>
Enable or disable peer SSL certificate verification. See
L<http://curl.haxx.se/docs/sslcerts.html> for details. Enabled by default.
=item B<VerifyHost> B<true|false>
Enable or disable peer host name verification. If enabled, the plugin checks
if the C<Common Name> or a C<Subject Alternate Name> field of the SSL
certificate matches the host name provided by the B<URL> option. If this
identity check fails, the connection is aborted. Obviously, only works when
connecting to a SSL enabled server. Enabled by default.
=item B<CACert> I<File>
File that holds one or more SSL certificates. If you want to use HTTPS you will
possibly need this option. What CA certificates come bundled with C<libcurl>
and are checked by default depends on the distribution you use.
=back
=head2 Plugin C<apcups>
=over 4
=item B<Host> I<Hostname>
Hostname of the host running B<apcupsd>. Defaults to B<localhost>. Please note
that IPv6 support has been disabled unless someone can confirm or decline that
B<apcupsd> can handle it.
=item B<Port> I<Port>
TCP-Port to connect to. Defaults to B<3551>.
=back
=head2 Plugin C<ascent>
This plugin collects information about an Ascent server, a free server for the
"World of Warcraft" game. This plugin gathers the information by fetching the
XML status page using C<libcurl> and parses it using C<libxml2>.
The configuration options are the same as for the C<apache> plugin above:
=over 4
=item B<URL> I<http://localhost/ascent/status/>
Sets the URL of the XML status output.
=item B<User> I<Username>
Optional user name needed for authentication.
=item B<Password> I<Password>
Optional password needed for authentication.
=item B<VerifyPeer> B<true|false>
Enable or disable peer SSL certificate verification. See
L<http://curl.haxx.se/docs/sslcerts.html> for details. Enabled by default.
=item B<VerifyHost> B<true|false>
Enable or disable peer host name verification. If enabled, the plugin checks
if the C<Common Name> or a C<Subject Alternate Name> field of the SSL
certificate matches the host name provided by the B<URL> option. If this
identity check fails, the connection is aborted. Obviously, only works when
connecting to a SSL enabled server. Enabled by default.
=item B<CACert> I<File>
File that holds one or more SSL certificates. If you want to use HTTPS you will
possibly need this option. What CA certificates come bundled with C<libcurl>
and are checked by default depends on the distribution you use.
=back
=head2 Plugin C<bind>
Starting with BIND 9.5.0, the most widely used DNS server software provides
extensive statistics about queries, responses and lots of other information.
The bind plugin retrieves this information that's encoded in XML and provided
via HTTP and submits the values to collectd.
To use this plugin, you first need to tell BIND to make this information
available. This is done with the C<statistics-channels> configuration option:
statistics-channels {
inet localhost port 8053;
};
The configuration follows the grouping that can be seen when looking at the
data with an XSLT compatible viewer, such as a modern web browser. It's
probably a good idea to make yourself familiar with the provided values, so you
can understand what the collected statistics actually mean.
Synopsis:
<Plugin "bind">
URL "http://localhost:8053/"
OpCodes true
QTypes true
ServerStats true
ZoneMaintStats true
ResolverStats false
MemoryStats true
<View "_default">
QTypes true
ResolverStats true
CacheRRSets true
Zone "127.in-addr.arpa/IN"
</View>
</Plugin>
The bind plugin accepts the following configuration options:
=over 4
=item B<URL> I<URL>
URL from which to retrieve the XML data. If not specified,
C<http://localhost:8053/> will be used.
=item B<OpCodes> I<true>|I<false>
When enabled, statistics about the I<"OpCodes">, for example the number of
C<QUERY> packets, are collected.
Default: Enabled.
=item B<QTypes> I<true>|I<false>
When enabled, the number of I<incoming> queries by query types (for example
C<A>, C<MX>, C<AAAA>) is collected.
Default: Enabled.
=item B<ServerStats> I<true>|I<false>
Collect global server statistics, such as requests received over IPv4 and IPv6,
successful queries, and failed updates.
Default: Enabled.
=item B<ZoneMaintStats> I<true>|I<false>
Collect zone maintenance statistics, mostly information about notifications
(zone updates) and zone transfers.
Default: Enabled.
=item B<ResolverStats> I<true>|I<false>
Collect resolver statistics, i.E<nbsp>e. statistics about outgoing requests
(e.E<nbsp>g. queries over IPv4, lame servers). Since the global resolver
counters apparently were removed in BIND 9.5.1 and 9.6.0, this is disabled by
default. Use the B<ResolverStats> option within a B<View "_default"> block
instead for the same functionality.
Default: Disabled.
=item B<MemoryStats>
Collect global memory statistics.
Default: Enabled.
=item B<View> I<Name>
Collect statistics about a specific I<"view">. BIND can behave different,
mostly depending on the source IP-address of the request. These different
configurations are called "views". If you don't use this feature, you most
likely are only interested in the C<_default> view.
Within a E<lt>B<View>E<nbsp>I<name>E<gt> block, you can specify which
information you want to collect about a view. If no B<View> block is
configured, no detailed view statistics will be collected.
=over 4
=item B<QTypes> I<true>|I<false>
If enabled, the number of I<outgoing> queries by query type (e.E<nbsp>g. C<A>,
C<MX>) is collected.
Default: Enabled.
=item B<ResolverStats> I<true>|I<false>
Collect resolver statistics, i.E<nbsp>e. statistics about outgoing requests
(e.E<nbsp>g. queries over IPv4, lame servers).
Default: Enabled.
=item B<CacheRRSets> I<true>|I<false>
If enabled, the number of entries (I<"RR sets">) in the view's cache by query
type is collected. Negative entries (queries which resulted in an error, for
example names that do not exist) are reported with a leading exclamation mark,
e.E<nbsp>g. "!A".
Default: Enabled.
=item B<Zone> I<Name>
When given, collect detailed information about the given zone in the view. The
information collected if very similar to the global B<ServerStats> information
(see above).
You can repeat this option to collect detailed information about multiple
zones.
By default no detailed zone information is collected.
=back
=back
=head2 Plugin C<cpufreq>
This plugin doesn't have any options. It reads
F</sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq> (for the first CPU
installed) to get the current CPU frequency. If this file does not exist make
sure B<cpufreqd> (L<http://cpufreqd.sourceforge.net/>) or a similar tool is
installed and an "cpu governor" (that's a kernel module) is loaded.
=head2 Plugin C<csv>
=over 4
=item B<DataDir> I<Directory>
Set the directory to store CSV-files under. Per default CSV-files are generated
beneath the daemon's working directory, i.E<nbsp>e. the B<BaseDir>.
The special strings B<stdout> and B<stderr> can be used to write to the standard
output and standard error channels, respectively. This, of course, only makes
much sense when collectd is running in foreground- or non-daemon-mode.
=item B<StoreRates> B<true|false>
If set to B<true>, convert counter values to rates. If set to B<false> (the
default) counter values are stored as is, i.E<nbsp>e. as an increasing integer
number.
=back
=head2 Plugin C<curl>
The curl plugin uses the B<libcurl> (L<http://curl.haxx.se/>) to read web pages
and the match infrastructure (the same code used by the tail plugin) to use
regular expressions with the received data.
The following example will read the current value of AMD stock from Google's
finance page and dispatch the value to collectd.
<Plugin curl>
<Page "stock_quotes">
URL "http://finance.google.com/finance?q=NYSE%3AAMD"
User "foo"
Password "bar"
<Match>
Regex "<span +class=\"pr\"[^>]*> *([0-9]*\\.[0-9]+) *</span>"
DSType "GaugeAverage"
# Note: `stock_value' is not a standard type.
Type "stock_value"
Instance "AMD"
</Match>
</Page>
</Plugin>
In the B<Plugin> block, there may be one or more B<Page> blocks, each defining
a web page and one or more "matches" to be performed on the returned data. The
string argument to the B<Page> block is used as plugin instance.
The following options are valid within B<Page> blocks:
=over 4
=item B<URL> I<URL>
URL of the web site to retrieve. Since a regular expression will be used to
extract information from this data, non-binary data is a big plus here ;)
=item B<User> I<Name>
Username to use if authorization is required to read the page.
=item B<Password> I<Password>
Password to use if authorization is required to read the page.
=item B<VerifyPeer> B<true>|B<false>
Enable or disable peer SSL certificate verification. See
L<http://curl.haxx.se/docs/sslcerts.html> for details. Enabled by default.
=item B<VerifyHost> B<true>|B<false>
Enable or disable peer host name verification. If enabled, the plugin checks if
the C<Common Name> or a C<Subject Alternate Name> field of the SSL certificate
matches the host name provided by the B<URL> option. If this identity check
fails, the connection is aborted. Obviously, only works when connecting to a
SSL enabled server. Enabled by default.
=item B<CACert> I<file>
File that holds one or more SSL certificates. If you want to use HTTPS you will
possibly need this option. What CA certificates come bundled with C<libcurl>
and are checked by default depends on the distribution you use.
=item B<MeasureResponseTime> B<true>|B<false>
Measure response time for the request. If this setting is enabled, B<Match>
blocks (see below) are optional. Disabled by default.
=item B<E<lt>MatchE<gt>>
One or more B<Match> blocks that define how to match information in the data
returned by C<libcurl>. The C<curl> plugin uses the same infrastructure that's
used by the C<tail> plugin, so please see the documentation of the C<tail>
plugin below on how matches are defined. If the B<MeasureResponseTime> option
is set to B<true>, B<Match> blocks are optional.
=back
=head2 Plugin C<curl_json>
The B<curl_json plugin> uses B<libcurl> (L<http://curl.haxx.se/>) and
B<libyajl> (L<http://www.lloydforge.org/projects/yajl/>) to retrieve JSON data
via cURL. This can be used to collect values from CouchDB documents (which are
stored JSON notation), for example.
The following example will collect several values from the built-in `_stats'
runtime statistics module of CouchDB
(L<http://wiki.apache.org/couchdb/Runtime_Statistics>).
<Plugin curl_json>
<URL "http://localhost:5984/_stats">
Instance "httpd"
<Key "httpd/requests/count">
Type "http_requests"
</Key>
<Key "httpd_request_methods/*/count">
Type "http_request_methods"
</Key>
<Key "httpd_status_codes/*/count">
Type "http_response_codes"
</Key>
</URL>
</Plugin>
In the B<Plugin> block, there may be one or more B<URL> blocks, each defining
a URL to be fetched via HTTP (using libcurl) and one or more B<Key> blocks.
The B<Key> string argument must be in a path format, which is used to collect a
value from a JSON map object. If a path element of B<Key> is the
I<*>E<nbsp>wildcard, the values for all keys will be collectd.
The following options are valid within B<URL> blocks:
=over 4
=item B<Instance> I<Instance>
Sets the plugin instance to I<Instance>.
=item B<User> I<Name>
Username to use if authorization is required to read the page.
=item B<Password> I<Password>
Password to use if authorization is required to read the page.
=item B<VerifyPeer> B<true>|B<false>
Enable or disable peer SSL certificate verification. See
L<http://curl.haxx.se/docs/sslcerts.html> for details. Enabled by default.
=item B<VerifyHost> B<true>|B<false>
Enable or disable peer host name verification. If enabled, the plugin checks if
the C<Common Name> or a C<Subject Alternate Name> field of the SSL certificate
matches the host name provided by the B<URL> option. If this identity check
fails, the connection is aborted. Obviously, only works when connecting to a
SSL enabled server. Enabled by default.
=item B<CACert> I<file>
File that holds one or more SSL certificates. If you want to use HTTPS you will
possibly need this option. What CA certificates come bundled with C<libcurl>
and are checked by default depends on the distribution you use.
=back
The following options are valid within B<Key> blocks:
=over 4
=item B<Type> I<Type>
Sets the type used to dispatch the values to the daemon. Detailed information
about types and their configuration can be found in L<types.db(5)>. This
option is mandatory.
=item B<Instance> I<Instance>
Type-instance to use. Defaults to the current map key or current string array element value.
=back
=head2 Plugin C<curl_xml>
The B<curl_xml plugin> uses B<libcurl> (L<http://curl.haxx.se/>) and B<libxml2>
(L<http://xmlsoft.org/>) to retrieve XML data via cURL.
<Plugin "curl_xml">
<URL "http://localhost/stats.xml">
Host "my_host"
Instance "some_instance"
User "collectd"
Password "thaiNg0I"
VerifyPeer true
VerifyHost true
CACert "/path/to/ca.crt"
<XPath "table[@id=\"magic_level\"]/tr">
Type "magic_level"
#InstancePrefix "prefix-"
InstanceFrom "td[1]"
ValuesFrom "td[2]/span[@class=\"level\"]"
</XPath>
</URL>
</Plugin>
In the B<Plugin> block, there may be one or more B<URL> blocks, each defining a
URL to be fetched via HTTP (using libcurl). Within each B<URL> block there are
options which specify the connection parameters, for example authentication
information, and one or more B<XPath> blocks.
Each B<XPath> block specifies how to get one type of information. The
string argument must be a valid XPath expression which returns a list
of "base elements". One value is dispatched for each "base element". The
I<type instance> and values are looked up using further I<XPath> expressions
that should be relative to the base element.
Within the B<URL> block the following options are accepted:
=over 4
=item B<Host> I<Name>
Use I<Name> as the host name when submitting values. Defaults to the global
host name setting.
=item B<Instance> I<Instance>
Use I<Instance> as the plugin instance when submitting values. Defaults to an
empty string (no plugin instance).
=item B<User> I<User>
=item B<Password> I<Password>
=item B<VerifyPeer> B<true>|B<false>
=item B<VerifyHost> B<true>|B<false>
=item B<CACert> I<CA Cert File>
These options behave exactly equivalent to the appropriate options of the
I<cURL> and I<cURL-JSON> plugins. Please see there for a detailed description.
=item E<lt>B<XPath> I<XPath-expression>E<gt>
Within each B<URL> block, there must be one or more B<XPath> blocks. Each
B<XPath> block specifies how to get one type of information. The string
argument must be a valid XPath expression which returns a list of "base
elements". One value is dispatched for each "base element".
Within the B<XPath> block the following options are accepted:
=over 4
=item B<Type> I<Type>
Specifies the I<Type> used for submitting patches. This determines the number
of values that are required / expected and whether the strings are parsed as
signed or unsigned integer or as double values. See L<types.db(5)> for details.
This option is required.
=item B<InstancePrefix> I<InstancePrefix>
Prefix the I<type instance> with I<InstancePrefix>. The values are simply
concatenated together without any separator.
This option is optional.
=item B<InstanceFrom> I<InstanceFrom>
Specifies a XPath expression to use for determining the I<type instance>. The
XPath expression must return exactly one element. The element's value is then
used as I<type instance>, possibly prefixed with I<InstancePrefix> (see above).
This value is required. As a special exception, if the "base XPath expression"
(the argument to the B<XPath> block) returns exactly one argument, then this
option may be omitted.
=item B<ValuesFrom> I<ValuesFrom> [I<ValuesFrom> ...]
Specifies one or more XPath expression to use for reading the values. The
number of XPath expressions must match the number of data sources in the
I<type> specified with B<Type> (see above). Each XPath expression must return
exactly one element. The element's value is then parsed as a number and used as
value for the appropriate value in the value list dispatched to the daemon.
=back
=back
=head2 Plugin C<dbi>
This plugin uses the B<dbi> library (L<http://libdbi.sourceforge.net/>) to
connect to various databases, execute I<SQL> statements and read back the
results. I<dbi> is an acronym for "database interface" in case you were
wondering about the name. You can configure how each column is to be
interpreted and the plugin will generate one or more data sets from each row
returned according to these rules.
Because the plugin is very generic, the configuration is a little more complex
than those of other plugins. It usually looks something like this:
<Plugin dbi>
<Query "out_of_stock">
Statement "SELECT category, COUNT(*) AS value FROM products WHERE in_stock = 0 GROUP BY category"
# Use with MySQL 5.0.0 or later
MinVersion 50000
<Result>
Type "gauge"
InstancePrefix "out_of_stock"
InstancesFrom "category"
ValuesFrom "value"
</Result>
</Query>
<Database "product_information">
Driver "mysql"
DriverOption "host" "localhost"
DriverOption "username" "collectd"
DriverOption "password" "aZo6daiw"
DriverOption "dbname" "prod_info"
SelectDB "prod_info"
Query "out_of_stock"
</Database>
</Plugin>
The configuration above defines one query with one result and one database. The
query is then linked to the database with the B<Query> option I<within> the
B<E<lt>DatabaseE<gt>> block. You can have any number of queries and databases
and you can also use the B<Include> statement to split up the configuration
file in multiple, smaller files. However, the B<E<lt>QueryE<gt>> block I<must>
precede the B<E<lt>DatabaseE<gt>> blocks, because the file is interpreted from
top to bottom!
The following is a complete list of options:
=head3 B<Query> blocks
Query blocks define I<SQL> statements and how the returned data should be
interpreted. They are identified by the name that is given in the opening line
of the block. Thus the name needs to be unique. Other than that, the name is
not used in collectd.
In each B<Query> block, there is one or more B<Result> blocks. B<Result> blocks
define which column holds which value or instance information. You can use
multiple B<Result> blocks to create multiple values from one returned row. This
is especially useful, when queries take a long time and sending almost the same
query again and again is not desirable.
Example:
<Query "environment">
Statement "select station, temperature, humidity from environment"
<Result>
Type "temperature"
# InstancePrefix "foo"
InstancesFrom "station"
ValuesFrom "temperature"
</Result>
<Result>
Type "humidity"
InstancesFrom "station"
ValuesFrom "humidity"
</Result>
</Query>
The following options are accepted:
=over 4
=item B<Statement> I<SQL>
Sets the statement that should be executed on the server. This is B<not>
interpreted by collectd, but simply passed to the database server. Therefore,
the SQL dialect that's used depends on the server collectd is connected to.
The query has to return at least two columns, one for the instance and one
value. You cannot omit the instance, even if the statement is guaranteed to
always return exactly one line. In that case, you can usually specify something
like this:
Statement "SELECT \"instance\", COUNT(*) AS value FROM table"
(That works with MySQL but may not be valid SQL according to the spec. If you
use a more strict database server, you may have to select from a dummy table or
something.)