From: Marc Fournier Date: Tue, 10 May 2016 08:24:29 +0000 (+0200) Subject: Merge pull request #1308 from mfournier/openldap-persistent-connection X-Git-Tag: collectd-5.6.0~300 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=354f9991530248e45207d236eb74c1cc3d5238ef;hp=-c Merge pull request #1308 from mfournier/openldap-persistent-connection Openldap: persistent connection + sane default timeout --- 354f9991530248e45207d236eb74c1cc3d5238ef diff --combined src/collectd.conf.pod index 23af31ad,48de6f90..0853fffd --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@@ -38,7 -38,7 +38,7 @@@ i.e. a CPluginE...E> bl The syntax of this config file is similar to the config file of the famous I webserver. Each line contains either an option (a key and a list of one or more values) or a section-start or -end. Empty lines and everything -after a non-quoted hash-symbol (C<#>) is ignored. I are unquoted +after a non-quoted hash-symbol (C<#>) are ignored. I are unquoted strings, consisting only of alphanumeric characters and the underscore (C<_>) character. Keys are handled case insensitive by I itself and all plugins included with it. I can either be an I, a @@@ -70,7 -70,7 +70,7 @@@ CB ...E> block =item B I -Sets the base directory. This is the directory beneath all RRD-files are +Sets the base directory. This is the directory beneath which all RRD-files are created. Possibly more subdirectories are created. This is also the working directory for the daemon. @@@ -83,7 -83,7 +83,7 @@@ I will be mostly useless Only the first B statement or block for a given plugin name has any effect. This is useful when you want to split up the configuration into smaller files and want each file to be "self contained", i.e. it contains a B -block I then appropriate B statement. The downside is that if +block I the appropriate B statement. The downside is that if you have multiple conflicting B blocks, e.g. when they specify different intervals, only one of them (the first one encountered) will take effect and all others will be silently ignored. @@@ -127,13 -127,13 +127,13 @@@ the average user from ever having to de =item B I Sets a plugin-specific interval for collecting metrics. This overrides the -global B setting. If a plugin provides own support for specifying an -interval, that setting will take precedence. +global B setting. If a plugin provides its own support for specifying +an interval, that setting will take precedence. =item B I -Specifies the the interval, in seconds, to call the flush callback if it's -defined in this plugin. By default, this is disabled +Specifies the interval, in seconds, to call the flush callback if it's +defined in this plugin. By default, this is disabled. =item B I @@@ -159,27 -159,12 +159,27 @@@ plugins that don't provide any configur When set to B, various statistics about the I daemon will be collected, with "collectd" as the I. Defaults to B. -The "write_queue" I reports the number of elements currently -queued and the number of elements dropped off the queue by the -B/B mechanism. +The following metrics are reported: -The "cache" I reports the number of elements in the value list -cache (the cache you can interact with using L). +=over 4 + +=item C + +The number of metrics currently in the write queue. You can limit the queue +length with the B and B options. + +=item C + +The number of metrics dropped due to a queue length limitation. +If this value is non-zero, your system can't handle all incoming metrics and +protects itself against overload by dropping metrics. + +=item C + +The number of elements in the metric cache (the cache you can interact with +using L). + +=back =item B I [I] @@@ -208,11 -193,13 +208,11 @@@ I may be specified to filter w in combination with recursively including a directory to easily be able to arbitrarily mix configuration files and other documents (e.g. README files). The given example is similar to the first example above but includes all files -matching C<*.conf> in any subdirectory of C: - - Include "/etc/collectd.d" "*.conf" +matching C<*.conf> in any subdirectory of C. =back -If more than one files are included by a single B option, the files +If more than one file is included by a single B option, the files will be included in lexicographical order (as defined by the C function). Thus, you can e.Eg. use numbered prefixes to specify the order in which the files are loaded. @@@ -253,7 -240,7 +253,7 @@@ magic! (Assuming you're using the I I -Read plugin doubles interval between queries after each failed attempt +A read plugin doubles the interval between queries after each failed attempt to get data. This options limits the maximum value of the interval. The default value is @@@ -834,15 -821,13 +834,15 @@@ default for backwards compatibility, th =item B B|B -By default, the plugin will try to keep the connection to UPS open between -reads. Since this appears to be somewhat brittle (I appears to close -the connection due to inactivity quite quickly), the plugin will try to detect -this problem and switch to an open-read-close mode in such cases. +The plugin is designed to keep the connection to I open between reads. +If plugin poll interval is greater than 15 seconds (hardcoded socket close +timeout in I NIS), then this option is B by default. You can instruct the plugin to close the connection after each read by setting -this option to B. +this option to B or force keeping the connection by setting it to B. + +If I appears to close the connection due to inactivity quite quickly, +the plugin will try to detect this problem and switch to an open-read-close mode. =back @@@ -2531,7 -2516,7 +2531,7 @@@ a more detailed description see B I|I -If no configuration if given, the B-plugin will collect data from +If no configuration if given, the B-plugin will collect data from all interfaces. This may not be practical, especially for loopback- and similar interfaces. Thus, you can use the B-option to pick the interfaces you're interested in. Sometimes, however, it's easier/preferred @@@ -2540,34 -2525,6 +2540,34 @@@ do that: By setting B t B is inverted: All selected interfaces are ignored and all other interfaces are collected. +It is possible to use regular expressions to match interface names, if the +name is surrounded by I and collectd was compiled with support for +regexps. This is useful if there's a need to collect (or ignore) data +for a group of interfaces that are similarly named, without the need to +explicitly list all of them (especially useful if the list is dynamic). +Example: + + Interface "lo" + Interface "/^veth/" + Interface "/^tun[0-9]+/" + IgnoreSelected "true" + +This will ignore the loopback interface, all interfaces with names starting +with I and all interfaces with names starting with I followed by +at least one digit. + + +=item B I|I + +Interface name is not unique on Solaris (KSTAT), interface name is unique +only within a module/instance. Following tuple is considered unique: + (ks_module, ks_instance, ks_name) +If this option is set to true, interface name contains above three fields +separated by an underscore. For more info on KSTAT, visit +L + +This option is only available on Solaris. + =back =head2 Plugin C @@@ -2608,13 -2565,9 +2608,13 @@@ a notification is sent =item B I I [I [I]] -Select the rules to count. If only I
and I are given, this plugin -will collect the counters of all rules which have a comment-match. The comment -is then used as type-instance. +=item B I
I [I [I]] + +Select the iptables/ip6tables filter rules to count packets and bytes from. + +If only I
and I are given, this plugin will collect the counters +of all rules which have a comment-match. The comment is then used as +type-instance. If I or I is given, only the rule with the matching comment or the Ith rule will be collected. Again, the comment (or the number) will be @@@ -3394,38 -3347,6 +3394,38 @@@ Configures the topic(s) to subscribe to multi level C<#> wildcards. Defaults to B, i.e. all topics beneath the B branch. +=item B I + +Path to the PEM-encoded CA certificate file. Setting this option enables TLS +communication with the MQTT broker, and as such, B should be the TLS-enabled +port of the MQTT broker. +A valid TLS configuration requires B, B and B. + +=item B I + +Path to the PEM-encoded certificate file to use as client certificate when +connecting to the MQTT broker. +A valid TLS configuration requires B, B and B. + +=item B I + +Path to the unencrypted PEM-encoded key file corresponding to B. +A valid TLS configuration requires B, B and B. + +=item B I + +If configured, this specifies the string protocol version (e.g. C, +C) to use for the TLS connection to the broker. If not set a default +version is used which depends on the version of OpenSSL the Mosquitto library +was linked against. + +=item B I + +A string describing the ciphers available for use. See L and the +C utility for more information. If unset, the default ciphers +will be used. + + =back =head2 Plugin C @@@ -4483,35 -4404,8 +4483,35 @@@ Default: C + +The I plugin writes notifications to Nagios' I as +a I. + +Available configuration options: + +=over 4 + +=item B I + +Sets the I to write to. Defaults to F. + +=back + =head2 Plugin C +The C plugin collects per-peer ntpd data such as time offset and time +dispersion. + +For talking to B, it mimics what the B control program does on +wire - using B specific requests. This mode is deprecated with +newer B releases (4.2.7p230 and later). For the C plugin to work +correctly with them, the ntp daemon must be explicitly configured to +enable B (which is disabled by default). Refer to the I +manual page for details. + +Available configuration options for the C plugin: + =over 4 =item B I @@@ -4737,12 -4631,12 +4737,12 @@@ I =item B I -Name in the form of an LDAP distinguished name intended to be used for +Name in the form of an LDAP distinguished name intended to be used for authentication. Defaults to empty string to establish an anonymous authorization. =item B I -Password for simple bind authentication. If this option is not set, +Password for simple bind authentication. If this option is not set, unauthenticated bind operation is used. =item B B @@@ -4766,8 -4660,9 +4766,9 @@@ client configuration mechanisms. See ld =item B I - Sets the timeout value for ldap operations. Defaults to B<-1> which results in - an infinite timeout. + Sets the timeout value for ldap operations, in seconds. By default, the + configured B is used to set the timeout. Use B<-1> to disable + (infinite timeout). =item B I @@@ -5016,13 -4911,6 +5017,13 @@@ Default: B<0.9 Sets the Time-To-Live of generated ICMP packets. +=item B I + +Sets the size of the data payload in ICMP packet to specified I (it +will be filled with regular ASCII pattern). If not set, default 56 byte +long string is used so that the packet size of an ICMPv4 packet is exactly +64 bytes, similar to the behaviour of normal ping(1) command. + =item B I Sets the source address to use. I may either be a numerical network @@@ -6150,12 -6038,6 +6151,12 @@@ few ones. This option enables you to d I the effect of B is inverted: All selected sensors are ignored and all other sensors are collected. +=item B I|I + +Configures how sensor readings are reported. When set to I, sensor +readings are reported using their descriptive label (e.g. "VCore"). When set to +I (the default) the sensor name is used ("in0"). + =back =head2 Plugin C @@@ -6304,12 -6186,6 +6305,12 @@@ rate of counters and size of sets will are unchanged. If set to B, the such metrics are not dispatched and removed from the internal cache. +=item B B|B + +When enabled, creates a C metric which reports the change since the last +read. This option primarily exists for compatibility with the I +implementation by Etsy. + =item B I Calculate and dispatch the configured percentile, i.e. compute the latency, so @@@ -6918,13 -6794,13 +6919,13 @@@ fails or if you want to disable this fe =item B I|I Boolean enabling the collection of the temperature of each core. -This option should only be used if the automated detectionfails or +This option should only be used if the automated detectionfails or if you want to disable this feature. =item B I|I Boolean enabling the collection of the temperature of each package. -This option should only be used if the automated detectionfails or +This option should only be used if the automated detectionfails or if you want to disable this feature. =item B I @@@ -7349,14 -7225,6 +7350,14 @@@ Service name or port number to connect Protocol to use when connecting to I. Defaults to C. +=item B I + +When set to non-zero, forces the connection to the Graphite backend to be +closed and re-opend periodically. This behavior is desirable in environments +where the connection to the Graphite backend is done through load balancers, +for example. When set to zero, the default, the connetion is kept open for as +long as possible. + =item B B|B If set to B (the default), logs errors when sending data to I. @@@ -7583,12 -7451,6 +7584,12 @@@ authentication Password required to load the private key in B. +=item B
I
+ +A HTTP header to add to the request. Multiple headers are added if this option is specified more than once. Example: + + Header "X-Custom-Header: custom_value" + =item B B|B|B|B|B|B Define which SSL protocol version must be used. By default C will @@@ -7763,8 -7625,6 +7764,8 @@@ Synopsis Timeout 1000 Prefix "collectd/" Database 1 + MaxSetSize -1 + StoreRates true @@@ -7773,7 -7633,7 +7774,7 @@@ the timestamp as the score. Retrieving C I command. Additionally, all the identifiers of these I are kept in a I called C (or C<${prefix}/values> if the B option was specified) and can be retrieved -using the C I command. You can specify the database to use +using the C I command. You can specify the database to use with the B parameter (default is C<0>). See L and L for details. @@@ -7818,18 -7678,7 +7819,18 @@@ is recommended but not required to incl =item B I -This index selects the redis database to use for writing operations. Defaults to C<0>. +This index selects the redis database to use for writing operations. Defaults +to C<0>. + +=item B I + +The B option limits the number of items that the I can +hold. Negative values for I sets no limit, which is the default behavior. + +=item B B|B + +If set to B (the default), convert counter values to rates. If set to +B counter values are stored as is, i.e. as an increasing integer number. =back @@@ -7875,26 -7724,11 +7876,26 @@@ Hostname or address to connect to. Defa Service name or port number to connect to. Defaults to C<5555>. -=item B B|B +=item B B|B|B Specify the protocol to use when communicating with I. Defaults to B. +=item B I + +When using the B protocol, path to a PEM certificate to present +to remote host. + +=item B I + +When using the B protocol, path to a PEM CA certificate to +use to validate the remote hosts's identity. + +=item B I + +When using the B protocol, path to a PEM private key associated +with the certificate defined by B. + =item B B|B If set to B and B is set to B, @@@ -7914,11 -7748,6 +7915,11 @@@ Defaults to tru Maximum payload size for a riemann packet. Defaults to 8192 +=item B I + +Maximum amount of seconds to wait in between to batch flushes. +No timeout by default. + =item B B|B If set to B (the default), convert counter values to rates. If set to @@@ -7930,7 -7759,7 +7931,7 @@@ C =item B B|B -If set the B, append the name of the I (DS) to the +If set to B, append the name of the I (DS) to the "service", i.e. the field that, together with the "host" field, uniquely identifies a metric in I. If set to B (the default), this is only done when there is more than one DS. @@@ -8085,14 -7914,6 +8086,14 @@@ attribute for each metric being sent ou =back +=head2 Plugin C + +This plugin collects metrics of hardware CPU load for machine running Xen +hypervisor. Load is calculated from 'idle time' value, provided by Xen. +Result is reported using the C type, for each CPU (core). + +This plugin doesn't have any options (yet). + =head2 Plugin C The I will collect statistics from a I server @@@ -8990,8 -8811,6 +8991,8 @@@ Available options =item B I +=item B I I + Set the appropriate field to the given string. The strings for plugin instance and type instance may be empty, the strings for host and plugin may not be empty. It's currently not possible to set the type of a value this way. diff --combined src/openldap.c index 36a29f8d,dc933344..615aee33 --- a/src/openldap.c +++ b/src/openldap.c @@@ -1,7 -1,7 +1,7 @@@ /** * collectd - src/openldap.c * Copyright (C) 2011 Kimo Rosenbaum - * Copyright (C) 2014 Marc Fournier + * Copyright (C) 2014-2015 Marc Fournier * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@@ -31,11 -31,6 +31,11 @@@ #include "plugin.h" #include "configfile.h" +#if defined(__APPLE__) +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wdeprecated-declarations" +#endif + #include #include @@@ -58,6 -53,9 +58,9 @@@ struct cldap_s /* {{{ * }; typedef struct cldap_s cldap_t; /* }}} */ + static cldap_t **databases = NULL; + static size_t databases_num = 0; + static void cldap_free (cldap_t *st) /* {{{ */ { if (st == NULL) @@@ -79,6 -77,13 +82,13 @@@ static int cldap_init_host (cldap_t *st { LDAP *ld; int rc; + + if (st->state && st->ld) + { + DEBUG ("openldap plugin: Already connected to %s", st->url); + return (0); + } + rc = ldap_initialize (&ld, st->url); if (rc != LDAP_SUCCESS) { @@@ -96,6 -101,8 +106,8 @@@ ldap_set_option (st->ld, LDAP_OPT_TIMEOUT, &(const struct timeval){st->timeout, 0}); + ldap_set_option (st->ld, LDAP_OPT_RESTART, LDAP_OPT_ON); + if (st->cacert != NULL) ldap_set_option (st->ld, LDAP_OPT_X_TLS_CACERTFILE, st->cacert); @@@ -160,13 -167,9 +172,9 @@@ static void cldap_submit_value (const c if ((st->host == NULL) || (strcmp ("", st->host) == 0) || (strcmp ("localhost", st->host) == 0)) - { sstrncpy (vl.host, hostname_g, sizeof (vl.host)); - } else - { sstrncpy (vl.host, st->host, sizeof (vl.host)); - } sstrncpy (vl.plugin, "openldap", sizeof (vl.plugin)); if (st->name != NULL) @@@ -236,6 -239,7 +244,7 @@@ static int cldap_read_host (user_data_ ERROR ("openldap plugin: Failed to execute search: %s", ldap_err2string (rc)); ldap_msgfree (result); + st->state = 0; ldap_unbind_ext_s (st->ld, NULL, NULL); return (-1); } @@@ -533,7 -537,6 +542,6 @@@ } ldap_msgfree (result); - ldap_unbind_ext_s (st->ld, NULL, NULL); return (0); } /* }}} int cldap_read_host */ @@@ -553,12 -556,13 +561,12 @@@ static int cldap_config_add (oconfig_it int i; int status; - st = malloc (sizeof (*st)); + st = calloc (1, sizeof (*st)); if (st == NULL) { - ERROR ("openldap plugin: malloc failed."); + ERROR ("openldap plugin: calloc failed."); return (-1); } - memset (st, 0, sizeof (*st)); status = cf_util_get_string (ci, &st->name); if (status != 0) @@@ -568,7 -572,7 +576,7 @@@ } st->starttls = 0; - st->timeout = -1; + st->timeout = (long) (CDTIME_T_TO_MS(plugin_get_interval()) / 1000); st->verifyhost = 1; st->version = LDAP_VERSION3; @@@ -627,32 -631,47 +635,47 @@@ } if ((status == 0) && (ludpp->lud_host != NULL)) - { st->host = strdup (ludpp->lud_host); - } ldap_free_urldesc (ludpp); } if (status == 0) { - user_data_t ud; - char callback_name[3*DATA_MAX_NAME_LEN]; - - memset (&ud, 0, sizeof (ud)); - ud.data = st; - - memset (callback_name, 0, sizeof (callback_name)); - ssnprintf (callback_name, sizeof (callback_name), - "openldap/%s/%s", - (st->host != NULL) ? st->host : hostname_g, - (st->name != NULL) ? st->name : "default"), - - status = plugin_register_complex_read (/* group = */ NULL, - /* name = */ callback_name, - /* callback = */ cldap_read_host, - /* interval = */ 0, - /* user_data = */ &ud); + cldap_t **temp; + + temp = (cldap_t **) realloc (databases, + sizeof (*databases) * (databases_num + 1)); + + if (temp == NULL) + { + ERROR ("openldap plugin: realloc failed"); + status = -1; + } + else + { + user_data_t ud; + char callback_name[3*DATA_MAX_NAME_LEN]; + + databases = temp; + databases[databases_num] = st; + databases_num++; + + memset (&ud, 0, sizeof (ud)); + ud.data = st; + + memset (callback_name, 0, sizeof (callback_name)); + ssnprintf (callback_name, sizeof (callback_name), + "openldap/%s/%s", + (st->host != NULL) ? st->host : hostname_g, + (st->name != NULL) ? st->name : "default"), + + status = plugin_register_complex_read (/* group = */ NULL, + /* name = */ callback_name, + /* callback = */ cldap_read_host, + /* interval = */ 0, + /* user_data = */ &ud); + } } if (status != 0) @@@ -697,12 -716,22 +720,26 @@@ static int cldap_init (void) /* {{{ * return (0); } /* }}} int cldap_init */ + static int cldap_shutdown (void) /* {{{ */ + { + size_t i; + + for (i = 0; i < databases_num; i++) + if (databases[i]->ld != NULL) + ldap_unbind_ext_s (databases[i]->ld, NULL, NULL); + sfree (databases); + databases_num = 0; + + return (0); + } /* }}} int cldap_shutdown */ + void module_register (void) /* {{{ */ { plugin_register_complex_config ("openldap", cldap_config); plugin_register_init ("openldap", cldap_init); + plugin_register_shutdown ("openldap", cldap_shutdown); } /* }}} void module_register */ + +#if defined(__APPLE__) +#pragma clang diagnostic pop +#endif