From: Ruben Kerkhof Date: Fri, 26 Feb 2016 17:04:33 +0000 (+0100) Subject: Merge pull request #1506 from mfournier/apache-content-type-1170 X-Git-Tag: collectd-5.5.2~6^2~40 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=73664a19a54b440056f0f346e444b1d06626f481;hp=f2919408f226280cdf9cab2de81dd1716ec31a93;p=collectd.git Merge pull request #1506 from mfournier/apache-content-type-1170 apache: warn about possible misconfiguration --- diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 0ab7cf6e..18af78bb 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -407,7 +407,6 @@ # FSType "ext3" # IgnoreSelected false # ReportByDevice false -# ReportReserved false # ReportInodes false # ValuesAbsolute true # ValuesPercentage false diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 25e2b77a..d856d21c 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -2002,6 +2002,23 @@ do that: By setting B to I the effect of 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. + + =back =head2 Plugin C @@ -3734,6 +3751,18 @@ Default: C =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 diff --git a/src/df.c b/src/df.c index 74292d7e..f3bc7e42 100644 --- a/src/df.c +++ b/src/df.c @@ -53,7 +53,6 @@ static const char *config_keys[] = "FSType", "IgnoreSelected", "ReportByDevice", - "ReportReserved", "ReportInodes", "ValuesAbsolute", "ValuesPercentage" @@ -271,11 +270,7 @@ static int df_read (void) else { if (strcmp (mnt_ptr->dir, "/") == 0) - { - if (strcmp (mnt_ptr->type, "rootfs") == 0) - continue; sstrncpy (disk_name, "root", sizeof (disk_name)); - } else { int i, len; diff --git a/src/exec.c b/src/exec.c old mode 100755 new mode 100644 diff --git a/src/libvirt.c b/src/libvirt.c index 6a397db3..4cbe38d2 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -259,8 +259,8 @@ lv_init (void) { if (virInitialize () != 0) return -1; - - return 0; + else + return 0; } static int diff --git a/src/modbus.c b/src/modbus.c index 2cef4aa2..7349dc56 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -288,7 +288,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ if (host == NULL) return (EINVAL); +#if COLLECT_DEBUG modbus_set_debug (&host->connection, 1); +#endif /* We'll do the error handling ourselves. */ modbus_set_error_handling (&host->connection, NOP_ON_ERROR); @@ -341,7 +343,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ return (-1); } +#if COLLECT_DEBUG modbus_set_debug (host->connection, 1); +#endif /* We'll do the error handling ourselves. */ modbus_set_error_recovery (host->connection, 0); @@ -377,7 +381,7 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ uint16_t values[2]; int values_num; const data_set_t *ds; - int status; + int status = 0; if ((host == NULL) || (slave == NULL) || (data == NULL)) return (EINVAL); diff --git a/src/processes.c b/src/processes.c index bcc4ad54..86486147 100644 --- a/src/processes.c +++ b/src/processes.c @@ -302,7 +302,9 @@ static void ps_list_register (const char *name, const char *regexp) "`ProcessMatch' with the same name. " "All but the first setting will be " "ignored."); +#if HAVE_REGEX_H sfree (new->re); +#endif sfree (new); return; } @@ -1014,7 +1016,7 @@ int ps_read_process (int pid, procstat_t *ps, char *state) /* Leave the rest at zero if this is only a zombi */ if (ps->num_proc == 0) { - DEBUG ("processes plugin: This is only a zombi: pid = %i; " + DEBUG ("processes plugin: This is only a zombie: pid = %i; " "name = %s;", pid, ps->name); return (0); } @@ -1211,8 +1213,8 @@ static int read_fork_rate () #endif /*KERNEL_LINUX */ #if KERNEL_SOLARIS -static const char *ps_get_cmdline (long pid, /* {{{ */ - char *buffer, size_t buffer_size) +static char *ps_get_cmdline (pid_t pid, char *name __attribute__((unused)), /* {{{ */ + char *buffer, size_t buffer_size) { char path[PATH_MAX]; psinfo_t info; @@ -2163,7 +2165,7 @@ static int ps_read (void) ps_list_add (ps.name, - ps_get_cmdline (pid, cmdline, sizeof (cmdline)), + ps_get_cmdline (pid, ps.name, cmdline, sizeof (cmdline)), &pse); } /* while(readdir) */ closedir (proc); diff --git a/src/rrdtool.c b/src/rrdtool.c index 9b04d10e..7cfdae60 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -1018,11 +1018,11 @@ static int rrd_config (const char *key, const char *value) return (1); } - len = strlen (datadir); - while ((len > 0) && (datadir[len - 1] == '/')) + len = strlen (tmp); + while ((len > 0) && (tmp[len - 1] == '/')) { len--; - datadir[len] = 0; + tmp[len] = 0; } if (len == 0) @@ -1032,7 +1032,11 @@ static int rrd_config (const char *key, const char *value) return (1); } - sfree (datadir); + if (datadir != NULL) + { + sfree (datadir); + } + datadir = tmp; } else if (strcasecmp ("StepSize", key) == 0) diff --git a/src/tail.c b/src/tail.c index 72d97a38..181b752f 100644 --- a/src/tail.c +++ b/src/tail.c @@ -230,7 +230,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; - int status; + int status = 0; if (strcasecmp ("Match", option->key) == 0) { diff --git a/src/users.c b/src/users.c index 1e337540..ca05f50d 100644 --- a/src/users.c +++ b/src/users.c @@ -40,9 +40,6 @@ #elif HAVE_UTMP_H # include /* #endif HAVE_UTMP_H */ - -#else -# error "No applicable input method." #endif static void users_submit (gauge_t value) diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index c6ddf0e6..0828c55f 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -13,10 +13,9 @@ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * - * You should have received a copy of the GNU General Public - * Licence along with this program; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: * Lubos Stanek diff --git a/src/utils_ignorelist.h b/src/utils_ignorelist.h index b47b55ad..db7535fd 100644 --- a/src/utils_ignorelist.h +++ b/src/utils_ignorelist.h @@ -12,10 +12,9 @@ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * - * You should have received a copy of the GNU General Public - * Licence along with this program; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: * Lubos Stanek diff --git a/src/utils_latency.c b/src/utils_latency.c index 893bded3..90479741 100644 --- a/src/utils_latency.c +++ b/src/utils_latency.c @@ -30,12 +30,20 @@ #include "common.h" #include +#include + +#ifndef LLONG_MAX +# define LLONG_MAX 9223372036854775807LL +#endif #ifndef HISTOGRAM_NUM_BINS # define HISTOGRAM_NUM_BINS 1000 #endif -static const int HISTOGRAM_DEFAULT_BIN_WIDTH = 1; +#ifndef HISTOGRAM_DEFAULT_BIN_WIDTH +/* 1048576 = 2^20 ^= 1/1024 s */ +# define HISTOGRAM_DEFAULT_BIN_WIDTH 1048576 +#endif struct latency_counter_s { @@ -47,7 +55,7 @@ struct latency_counter_s cdtime_t min; cdtime_t max; - int bin_width; + cdtime_t bin_width; int histogram[HISTOGRAM_NUM_BINS]; }; @@ -67,47 +75,46 @@ struct latency_counter_s * * So, if the required bin width is 300, then new bin width will be 512 as it is * the next nearest power of 2. -* */ -void change_bin_width (latency_counter_t *lc, size_t val) /* {{{ */ +void change_bin_width (latency_counter_t *lc, cdtime_t latency) /* {{{ */ { - int i=0; /* This function is called because the new value is above histogram's range. * First find the required bin width: * requiredBinWidth = (value + 1) / numBins * then get the next nearest power of 2 * newBinWidth = 2^(ceil(log2(requiredBinWidth))) */ - double required_bin_width = (double)(val + 1) / HISTOGRAM_NUM_BINS; - double required_bin_width_logbase2 = log(required_bin_width) / log(2.0); - int new_bin_width = (int)(pow(2.0, ceil( required_bin_width_logbase2))); - int old_bin_width = lc->bin_width; + double required_bin_width = ((double) (latency + 1)) / ((double) HISTOGRAM_NUM_BINS); + double required_bin_width_logbase2 = log (required_bin_width) / log (2.0); + cdtime_t new_bin_width = (cdtime_t) (pow (2.0, ceil (required_bin_width_logbase2)) + .5); + cdtime_t old_bin_width = lc->bin_width; + lc->bin_width = new_bin_width; - /* - * bin width has been increased, now iterate through all bins and move the - * old bin's count to new bin. - */ + /* bin_width has been increased, now iterate through all bins and move the + * old bin's count to new bin. */ if (lc->num > 0) // if the histogram has data then iterate else skip { - double width_change_ratio = old_bin_width / new_bin_width; - for (i=0; ihistogram[new_bin] += lc->histogram[i]; lc->histogram[i] = 0; } - DEBUG("utils_latency: change_bin_width: fixed all bins"); } - DEBUG("utils_latency: change_bin_width: val-[%zu], oldBinWidth-[%d], " - "newBinWidth-[%d], required_bin_width-[%f], " - "required_bin_width_logbase2-[%f]", - val, old_bin_width, new_bin_width, required_bin_width, - required_bin_width_logbase2); - + DEBUG("utils_latency: change_bin_width: latency = %.3f; " + "old_bin_width = %.3f; new_bin_width = %.3f;", + CDTIME_T_TO_DOUBLE (latency), + CDTIME_T_TO_DOUBLE (old_bin_width), + CDTIME_T_TO_DOUBLE (new_bin_width)); } /* }}} void change_bin_width */ latency_counter_t *latency_counter_create () /* {{{ */ @@ -131,9 +138,9 @@ void latency_counter_destroy (latency_counter_t *lc) /* {{{ */ void latency_counter_add (latency_counter_t *lc, cdtime_t latency) /* {{{ */ { - size_t latency_ms; + cdtime_t bin; - if ((lc == NULL) || (latency == 0)) + if ((lc == NULL) || (latency == 0) || (latency > ((cdtime_t) LLONG_MAX))) return; lc->sum += latency; @@ -149,16 +156,14 @@ void latency_counter_add (latency_counter_t *lc, cdtime_t latency) /* {{{ */ /* A latency of _exactly_ 1.0 ms should be stored in the buffer 0, so * subtract one from the cdtime_t value so that exactly 1.0 ms get sorted * accordingly. */ - latency_ms = (size_t) CDTIME_T_TO_MS (latency - 1); - - int bin = (int)(latency_ms / lc->bin_width); + bin = (latency - 1) / lc->bin_width; if (bin >= HISTOGRAM_NUM_BINS) { - change_bin_width(lc, latency_ms); - bin = (int)(latency_ms / lc->bin_width); + change_bin_width (lc, latency); + bin = (latency - 1) / lc->bin_width; if (bin >= HISTOGRAM_NUM_BINS) { - ERROR("utils_latency: latency_counter_add: Invalid bin %d", bin); + ERROR ("utils_latency: latency_counter_add: Invalid bin: %"PRIu64, bin); return; } } @@ -170,7 +175,7 @@ void latency_counter_reset (latency_counter_t *lc) /* {{{ */ if (lc == NULL) return; - int bin_width = lc->bin_width; + cdtime_t bin_width = lc->bin_width; memset (lc, 0, sizeof (*lc)); /* preserve bin width */ @@ -217,14 +222,14 @@ cdtime_t latency_counter_get_average (latency_counter_t *lc) /* {{{ */ return (DOUBLE_TO_CDTIME_T (average)); } /* }}} cdtime_t latency_counter_get_average */ -cdtime_t latency_counter_get_percentile (latency_counter_t *lc, +cdtime_t latency_counter_get_percentile (latency_counter_t *lc, /* {{{ */ double percent) { double percent_upper; double percent_lower; - double ms_upper; - double ms_lower; - double ms_interpolated; + double p; + cdtime_t latency_lower; + cdtime_t latency_interpolated; int sum; size_t i; @@ -254,16 +259,18 @@ cdtime_t latency_counter_get_percentile (latency_counter_t *lc, assert (percent_upper >= percent); assert (percent_lower < percent); - ms_upper = (double) ( (i + 1) * lc->bin_width ); - ms_lower = (double) ( i * lc->bin_width ); if (i == 0) - return (MS_TO_CDTIME_T (ms_upper)); + return (lc->bin_width); + + latency_lower = ((cdtime_t) i) * lc->bin_width; + p = (percent - percent_lower) / (percent_upper - percent_lower); - ms_interpolated = (((percent_upper - percent) * ms_lower) - + ((percent - percent_lower) * ms_upper)) - / (percent_upper - percent_lower); + latency_interpolated = latency_lower + + DOUBLE_TO_CDTIME_T (p * CDTIME_T_TO_DOUBLE (lc->bin_width)); - return (MS_TO_CDTIME_T (ms_interpolated)); + DEBUG ("latency_counter_get_percentile: latency_interpolated = %.3f", + CDTIME_T_TO_DOUBLE (latency_interpolated)); + return (latency_interpolated); } /* }}} cdtime_t latency_counter_get_percentile */ /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/utils_llist.c b/src/utils_llist.c index 11f838d2..4c5645b1 100644 --- a/src/utils_llist.c +++ b/src/utils_llist.c @@ -12,10 +12,9 @@ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * - * You should have received a copy of the GNU General Public - * Licence along with this program; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: * Florian Forster diff --git a/src/utils_llist.h b/src/utils_llist.h index 19d8d947..6214190f 100644 --- a/src/utils_llist.h +++ b/src/utils_llist.h @@ -12,10 +12,9 @@ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * - * You should have received a copy of the GNU General Public - * Licence along with this program; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: * Florian Forster diff --git a/src/utils_mount.c b/src/utils_mount.c index 7b4c9276..05bc1a14 100644 --- a/src/utils_mount.c +++ b/src/utils_mount.c @@ -12,10 +12,9 @@ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * - * You should have received a copy of the GNU General Public - * Licence along with this program; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Author: * Niki W. Waibel diff --git a/src/utils_mount.h b/src/utils_mount.h index 83f789be..ef0bf759 100644 --- a/src/utils_mount.h +++ b/src/utils_mount.h @@ -12,10 +12,9 @@ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * - * You should have received a copy of the GNU General Public - * Licence along with this program; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, - * USA. + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Author: * Niki W. Waibel diff --git a/src/varnish.c b/src/varnish.c index bf248456..c0460ab0 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -505,7 +505,7 @@ static int varnish_read (user_data_t *ud) /* {{{ */ stats = VSC_Main(vd); varnish_monitor (conf, stats); - VSM_Close (vd); + VSM_Delete (vd); return (0); } /* }}} */ diff --git a/src/write_redis.c b/src/write_redis.c index ecbea4e2..5dd674cf 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -70,10 +70,11 @@ static int wr_write (const data_set_t *ds, /* {{{ */ value_ptr = &value[0]; status = format_values (value_ptr, value_size, ds, vl, /* store rates = */ 0); - pthread_mutex_lock (&node->lock); if (status != 0) return (status); + pthread_mutex_lock (&node->lock); + if (node->conn == NULL) { node->conn = credis_connect (node->host, node->port, node->timeout);