From: Florian Forster Date: Fri, 10 Oct 2008 07:02:33 +0000 (+0200) Subject: Merge branch 'collectd-4.5' X-Git-Tag: collectd-4.6.0~178 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=332cf199806de625661fa3a9bf9555f7a47ba9f9;hp=86f6ca2b5631e3ba487e420a670a7203260c8371 Merge branch 'collectd-4.5' Conflicts: configure.in --- diff --git a/README b/README index 8c8160ce..b6bdb413 100644 --- a/README +++ b/README @@ -472,9 +472,11 @@ Configuring / Compiling / Installing disable all plugins whose requirements cannot be fulfilled (any other plugin will be enabled). To enable a plugin, install missing dependencies (see section `Prerequisites' above) and rerun `configure'. If you specify the - `--enable-' configure option, you can force the plugin to be built. - This will most likely fail though unless you're working in a very unusual - setup and you really know what you're doing. + `--enable-' configure option, the script will fail if the depen- + dencies for the specified plugin are not met. If you specify the + `--disable-' configure option, the plugin will not be built. Both + options are meant for package maintainers and should not be used in everyday + situations. By default, collectd will be installed into `/opt/collectd'. You can adjust this setting by specifying the `--prefix' configure option - see INSTALL for diff --git a/configure.in b/configure.in index ffaacc3c..d416e696 100644 --- a/configure.in +++ b/configure.in @@ -2567,7 +2567,13 @@ AC_DEFUN( ]) if test "x$enable_plugin" = "xyes" then - AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.]) + if test "x$2" = "xyes" + then + AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.]) + else # User passed "yes" but dependency checking yielded "no" => Dependency problem. + dependency_error="yes" + enable_plugin="no (dependency error)" + fi fi AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes") enable_$1="$enable_plugin" @@ -2581,6 +2587,7 @@ AC_COLLECTD([debug], [enable], [feature], [debugging]) AC_COLLECTD([daemon], [disable], [feature], [daemon mode]) AC_COLLECTD([getifaddrs],[enable], [feature], [getifaddrs under Linux]) +dependency_error="no" plugin_ascent="no" plugin_battery="no" plugin_cpu="no" @@ -3004,4 +3011,8 @@ Configuration: EOF +if test "x$dependency_error" = "xyes"; then + AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details") +fi + # vim: set fdm=marker : diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 1bf5b3f3..ca72a68c 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -150,6 +150,7 @@ static int get_values (int *ret_values_num, double **ret_values, char **values_names; int i; + int j; fd = socket (PF_UNIX, SOCK_STREAM, 0); if (fd < 0) @@ -229,31 +230,58 @@ static int get_values (int *ret_values_num, double **ret_values, free (values); return (-1); } + memset (values_names, 0, values_num * sizeof (char *)); - i = 0; + i = 0; /* index of the values returned by the server */ + j = 0; /* number of values in `values_names' and `values' */ while (fgets (buffer, sizeof (buffer), fh_in) != NULL) { - char *key; - char *value; + do /* while (0) */ + { + char *key; + char *value; + char *endptr; + + key = buffer; - key = buffer; + value = strchr (key, '='); + if (value == NULL) + { + fprintf (stderr, "Cannot parse line: %s\n", buffer); + break; + } + *value = 0; + value++; - value = strchr (key, '='); - if (value == NULL) - continue; - *value = '\0'; value++; + if (ignore_ds (key) != 0) + break; - if (ignore_ds (key) != 0) - continue; + endptr = NULL; + errno = 0; + values[j] = strtod (value, &endptr); + if ((endptr == value) || (errno != 0)) + { + fprintf (stderr, "Could not parse buffer " + "as number: %s\n", value); + break; + } - values_names[i] = strdup (key); - values[i] = atof (value); + values_names[j] = strdup (key); + if (values_names[j] == NULL) + { + fprintf (stderr, "strdup failed.\n"); + break; + } + j++; + } while (0); i++; if (i >= values_num) break; } - values_num = i; + /* Set `values_num' to the number of values actually stored in the + * array. */ + values_num = j; fclose (fh_in); fh_in = NULL; fd = -1; fclose (fh_out); fh_out = NULL; diff --git a/src/collectd-nagios.pod b/src/collectd-nagios.pod index 7b2442e5..49800255 100644 --- a/src/collectd-nagios.pod +++ b/src/collectd-nagios.pod @@ -45,7 +45,7 @@ handled according to the consolidation function given with the B<-g> option. =item B<-g> BI<|>BI<|>B -When multiple data sources are selected from a value spec they can be handled +When multiple data sources are selected from a value spec, they can be handled differently depending on this option. The values of the following meaning: =over 4 @@ -71,22 +71,32 @@ The warning and critical ranges are applied to the sum of all values. Set the critical (B<-c>) and warning (B<-w>) ranges. These options mostly follow the normal syntax of Nagios plugins. The general format is -"IB<:>I". If a value if smaller than I or bigger than I a -warning or critical is returned, otherwise okay is returned. I (and the -colon) may be omitted and are then assumed to be zero. If I (but not the -colon) is omitted I is set to positive infinity. If either I or -I if set to B<~> they are set to negative and positive infinity, -respectively. +"IB<:>I". If a value is smaller than I or bigger than I, a +I or I status is returned, otherwise the status is +I. + +The tilde sign (B<~>) can be used to explicitly specify infinity. If B<~> is +used as a I value, negative infinity is used. In case of I, it is +interpreted as positive infinity. + +If the first character of the I is the atEsign (B<@>), the meaning +of the range will be inverted. I.Ee. all values I the range will +yield a I or I status, while all values I the range +will result in a I status. + +I (and the colon) may be omitted, +I is then assumed to be zero. If I (but not the trailing colon) is +omitted, I is assumed to be positive infinity. =back =head1 RETURN VALUE -As usual for Nagios plugins this program writes a short, one line status +As usual for Nagios plugins, this program writes a short, one line status message to STDOUT and signals success or failure with it's return value. It -exists with a return value of B<0> for success or B<1> or B<2> for warning and -critical, respectively. If the values is not available or some other error -occurred it returns B<3> for "unknown". +exits with a return value of B<0> for I, B<1> for I and B<2> +for I. If the values are not available or some other error occurred, +it returns B<3> for I. =head1 SEE ALSO diff --git a/src/configfile.c b/src/configfile.c index d483032a..9609086f 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -887,7 +887,11 @@ int cf_read (char *filename) dispatch_block (conf->children + i); } + oconfig_free (conf); + + /* Read the default types.db if no `TypesDB' option was given. */ if (cf_default_typesdb) - read_types_list (PLUGINDIR"/types.db"); /* FIXME: Configure path */ + read_types_list (PLUGINDIR"/types.db"); + return (0); } /* int cf_read */ diff --git a/src/netlink.c b/src/netlink.c index c2e4c9b4..d14e5101 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -364,7 +364,7 @@ static int qos_filter (const struct sockaddr_nl *sa, if (msg->tcm_ifindex >= iflist_len) { ERROR ("netlink plugin: qos_filter: msg->tcm_ifindex = %i " - ">= iflist_len = %i", + ">= iflist_len = %zu", msg->tcm_ifindex, iflist_len); return (-1); } diff --git a/src/network.c b/src/network.c index 39069aa7..fbbcd122 100644 --- a/src/network.c +++ b/src/network.c @@ -1548,7 +1548,10 @@ static int network_config (const char *key, const char *val) fields_num = strsplit (val_cpy, fields, 3); if ((fields_num != 1) && (fields_num != 2)) + { + sfree (val_cpy); return (1); + } else if (fields_num == 2) { if ((service = strchr (fields[1], '.')) != NULL) @@ -1561,6 +1564,8 @@ static int network_config (const char *key, const char *val) network_add_listen_socket (node, service); else network_add_sending_socket (node, service); + + sfree (val_cpy); } else if (strcasecmp ("TimeToLive", key) == 0) { diff --git a/src/utils_cache.c b/src/utils_cache.c index d0e77ef3..241aa726 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -298,6 +298,7 @@ int uc_check_timeout (void) ERROR ("uc_check_timeout: c_avl_remove (%s) failed.", keys[i]); } sfree (keys[i]); + sfree (key); cache_free (ce); } else if (status == 1) /* persist */