From: Florian Forster Date: Fri, 7 Sep 2012 09:19:52 +0000 (+0200) Subject: Merge branch 'collectd-5.1' X-Git-Tag: collectd-5.2.0~62 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=59dded4cc1a2077ad11c6e9b507e15ad19e0e38c;hp=0abfaa6a32babf3b2cbb34fce097d9f62fb2bc44;p=collectd.git Merge branch 'collectd-5.1' --- diff --git a/configure.in b/configure.in index 1cfc2fca..a63544a6 100644 --- a/configure.in +++ b/configure.in @@ -91,6 +91,7 @@ fi if test "x$ac_system" = "xSolaris" then AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.]) + AC_DEFINE(_REENTRANT, 1, [Define to enable reentrancy interfaces.]) fi if test "x$ac_system" = "xAIX" then @@ -532,6 +533,8 @@ AC_CHECK_HEADERS(netinet/if_ether.h, [], [], #endif ]) +AC_CHECK_HEADERS(netinet/ip_compat.h) + # For the multimeter plugin have_termios_h="no" AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"]) diff --git a/contrib/collectd_network.py b/contrib/collectd_network.py index 445b1838..0a5d57e6 100644 --- a/contrib/collectd_network.py +++ b/contrib/collectd_network.py @@ -5,18 +5,22 @@ # Copyright © 2009 Adrian Perez # # Distributed under terms of the GPLv2 license. +# +# Frank Marien (frank@apsu.be) 6 Sep 2012 +# - quick fixes for 5.1 binary protocol +# - updated to python 3 +# - fixed for larger packet sizes (possible on lo interface) +# - fixed comment typo (decode_network_string decodes a string) """ Collectd network protocol implementation. """ -import socket -import struct - +import socket,struct,sys try: - from cStringIO import StringIO + from io import StringIO except ImportError: - from StringIO import StringIO + from cStringIO import StringIO from datetime import datetime from copy import deepcopy @@ -31,17 +35,19 @@ DEFAULT_IPv4_GROUP = "239.192.74.66" DEFAULT_IPv6_GROUP = "ff18::efc0:4a42" """Default IPv6 multicast group""" - +HR_TIME_DIV = (2.0**30) # Message kinds TYPE_HOST = 0x0000 TYPE_TIME = 0x0001 +TYPE_TIME_HR = 0x0008 TYPE_PLUGIN = 0x0002 TYPE_PLUGIN_INSTANCE = 0x0003 TYPE_TYPE = 0x0004 TYPE_TYPE_INSTANCE = 0x0005 TYPE_VALUES = 0x0006 TYPE_INTERVAL = 0x0007 +TYPE_INTERVAL_HR = 0x0009 # For notifications TYPE_MESSAGE = 0x0100 @@ -50,14 +56,14 @@ TYPE_SEVERITY = 0x0101 # DS kinds DS_TYPE_COUNTER = 0 DS_TYPE_GAUGE = 1 - +DS_TYPE_DERIVE = 2 +DS_TYPE_ABSOLUTE = 3 header = struct.Struct("!2H") number = struct.Struct("!Q") short = struct.Struct("!H") double = struct.Struct("= 9) && ($n <= 13)) + { + next; + } + elsif ($n < 32) + { + return (1); + } + } + + return; +} + +sub contains_invalid_chars +{ + my $str = shift; + + for (split (m//, $str)) + { + my $n = ord ($_); + + # Whitespace is allowed. + if (($n >= 9) && ($n <= 13)) + { + next; + } + elsif ($n < 32) + { + return (1); + } + } + + return; +} + sub show_selector { my $timespan_selection = get_timespan_selection (); @@ -254,6 +298,7 @@ sub show_selector HTML for (sort (keys %$host_selection)) { + next if contains_invalid_chars ($_); my $host = encode_entities ($_); my $selected = $host_selection->{$_} ? ' selected="selected"' @@ -266,6 +311,7 @@ HTML HTML for (sort (keys %$plugin_selection)) { + next if contains_invalid_chars ($_); my $plugin = encode_entities ($_); my $selected = $plugin_selection->{$_} ? ' selected="selected"' @@ -278,6 +324,7 @@ HTML HTML for (sort { $TimeSpans->{$a} <=> $TimeSpans->{$b} } (keys (%$TimeSpans))) { + next if contains_invalid_chars ($_); my $name = encode_entities ($_); my $value = $TimeSpans->{$_}; my $selected = ($value == $timespan_selection) @@ -304,6 +351,7 @@ sub action_list_hosts for (sort @hosts) { my $url = encode_entities (script_name () . "?action=show_selection;hostname=$_"); + next if contains_invalid_chars ($_); my $name = encode_entities ($_); print qq#
  • $name
  • \n#; } diff --git a/contrib/collection3/lib/Collectd/Graph/Type/Df.pm b/contrib/collection3/lib/Collectd/Graph/Type/Df.pm index 0fbd0d35..4a70c41a 100644 --- a/contrib/collection3/lib/Collectd/Graph/Type/Df.pm +++ b/contrib/collection3/lib/Collectd/Graph/Type/Df.pm @@ -34,7 +34,7 @@ sub new my $obj = Collectd::Graph::Type->new (@_); $obj->{'data_sources'} = [qw(free used)]; $obj->{'rrd_opts'} = ['-v', 'Bytes']; - $obj->{'rrd_title'} = 'Disk space ({type_instance})'; + $obj->{'rrd_title'} = 'Disk space ({instance})'; $obj->{'rrd_format'} = '%5.1lf%sB'; $obj->{'colors'} = [qw(00b000 ff0000)]; @@ -58,7 +58,7 @@ sub getRRDArgs my $faded_green = get_faded_color ('00ff00'); my $faded_red = get_faded_color ('ff0000'); - return (['-t', 'Diskspace (' . $ident->{'type_instance'} . ')', '-v', 'Bytes', '-l', '0', + return (['-t', $obj->getTitle ($ident), '-v', 'Bytes', '-l', '0', "DEF:free_min=${filename}:free:MIN", "DEF:free_avg=${filename}:free:AVERAGE", "DEF:free_max=${filename}:free:MAX", diff --git a/contrib/migrate-4-5.px b/contrib/migrate-4-5.px index d3ff796d..c2a95558 100755 --- a/contrib/migrate-4-5.px +++ b/contrib/migrate-4-5.px @@ -33,6 +33,7 @@ use File::Basename ('dirname'); our $InDir = '/var/lib/collectd'; our $RRDtool = 'rrdtool'; +our $RRDFilter = 'rrd_filter.px'; our %TypesCounterToDerive = # {{{ ( @@ -184,7 +185,15 @@ sub handle_file # {{{ { my $dir = join ('/', @path); print "mkdir -p \"$dir/$plugin-$type_inst\"\n"; - print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n"; + if (($plugin eq 'df') and ($type eq 'df')) + { + print "$RRDFilter --infile=\"$path\" --outfile=\"$dir/$plugin-$type_inst/df_complex-free.rrd\" --map free:value\n"; + print "$RRDFilter --infile=\"$path\" --outfile=\"$dir/$plugin-$type_inst/df_complex-used.rrd\" --map used:value\n"; + } + else + { + print "mv \"$path\" \"$dir/$plugin-$type_inst/$type.rrd\"\n"; + } } } # }}} sub handle_file @@ -223,10 +232,12 @@ migrate-4-5.px [OPTIONS] Valid options are: - --indir Source directory - Default: $InDir - --rrdtool Path to the RRDtool binary - Default: $RRDtool + --indir Source directory + Default: $InDir + --rrdtool Path to the RRDtool binary + Default: $RRDtool + --rrdfilter Path to the rrd_filter.px script + Default: $RRDFilter EOF exit (1); @@ -234,8 +245,11 @@ EOF GetOptions ("indir|i=s" => \$InDir, "rrdtool=s" => \$RRDtool, + "rrdfilter=s" => \$RRDFilter, "help|h" => \&exit_usage) or exit_usage (); +print "#!/bin/bash\n\n"; + scan_dir ($InDir); # vim: set sw=2 sts=2 et fdm=marker : diff --git a/src/Makefile.am b/src/Makefile.am index ab580d75..eef2a609 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -43,7 +43,7 @@ collectd_SOURCES = collectd.c collectd.h \ collectd_CPPFLAGS = $(AM_CPPFLAGS) $(LTDLINCL) collectd_CFLAGS = $(AM_CFLAGS) collectd_LDFLAGS = -export-dynamic -collectd_LDADD = +collectd_LDADD = -lm collectd_DEPENDENCIES = # Link to these libraries.. @@ -70,7 +70,6 @@ collectd_LDADD += -ldevinfo endif if BUILD_AIX collectd_LDFLAGS += -Wl,-bexpall,-brtllib -collectd_LDADD += -lm endif # The daemon needs to call sg_init, so we need to link it against libstatgrab, @@ -1372,7 +1371,7 @@ EXTRA_DIST += collectd.conf.pod \ fi pinba.pb-c.c pinba.pb-c.h: pinba.proto - protoc-c --c_out $(builddir) pinba.proto + protoc-c --c_out . pinba.proto install-exec-hook: $(mkinstalldirs) $(DESTDIR)$(sysconfdir) diff --git a/src/amqp.c b/src/amqp.c index c9929dc0..876f7e9e 100644 --- a/src/amqp.c +++ b/src/amqp.c @@ -650,6 +650,7 @@ static void *camqp_subscribe_thread (void *user_data) /* {{{ */ camqp_config_free (conf); pthread_exit (NULL); + return (NULL); } /* }}} void *camqp_subscribe_thread */ static int camqp_subscribe_init (camqp_config_t *conf) /* {{{ */ diff --git a/src/collectd.c b/src/collectd.c index d33d1d66..915560c0 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -182,10 +182,11 @@ static int init_global_variables (void) static int change_basedir (const char *orig_dir) { - char *dir = strdup (orig_dir); - int dirlen; + char *dir; + size_t dirlen; int status; + dir = strdup (orig_dir); if (dir == NULL) { char errbuf[1024]; @@ -202,39 +203,41 @@ static int change_basedir (const char *orig_dir) return (-1); status = chdir (dir); - free (dir); + if (status == 0) + { + free (dir); + return (0); + } + else if (errno != ENOENT) + { + char errbuf[1024]; + ERROR ("change_basedir: chdir (%s): %s", dir, + sstrerror (errno, errbuf, sizeof (errbuf))); + free (dir); + return (-1); + } + status = mkdir (dir, S_IRWXU | S_IRWXG | S_IRWXO); if (status != 0) { - if (errno == ENOENT) - { - if (mkdir (orig_dir, 0755) == -1) - { - char errbuf[1024]; - ERROR ("change_basedir: mkdir (%s): %s", orig_dir, - sstrerror (errno, errbuf, - sizeof (errbuf))); - return (-1); - } - else if (chdir (orig_dir) == -1) - { - char errbuf[1024]; - ERROR ("chdir (%s): %s", orig_dir, - sstrerror (errno, errbuf, - sizeof (errbuf))); - return (-1); - } - } - else - { - char errbuf[1024]; - ERROR ("chdir (%s): %s", orig_dir, - sstrerror (errno, errbuf, - sizeof (errbuf))); - return (-1); - } + char errbuf[1024]; + ERROR ("change_basedir: mkdir (%s): %s", dir, + sstrerror (errno, errbuf, sizeof (errbuf))); + free (dir); + return (-1); + } + + status = chdir (dir); + if (status != 0) + { + char errbuf[1024]; + ERROR ("change_basedir: chdir (%s): %s", dir, + sstrerror (errno, errbuf, sizeof (errbuf))); + free (dir); + return (-1); } + free (dir); return (0); } /* static int change_basedir (char *dir) */ diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 492071f4..de9da5ac 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -25,22 +25,32 @@ 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. 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.Ee. either B or -B. 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.Ee. 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 option B occur -B the CPlugin ...E> block. +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 +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 +I (enclosed in double-quotes) a I or a I +expression. I consist of only alphanumeric characters and +underscores (C<_>) and do not need to be quoted. I are +enclosed in double quotes (C<">). You can use the backslash character (C<\>) +to include double quotes as part of the string. I can be specified in +decimal and floating point format (using a dot C<.> as decimal separator), +hexadecimal when using the C<0x> prefix and octal with a leading zero (C<0>). +I values are either B or B. + +Lines may be wrapped by using C<\> 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. 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 option B occur B +the appropriate CPlugin ...E> block. =head1 GLOBAL OPTIONS @@ -4965,7 +4975,7 @@ number. If set to B, the plugin instance and type instance will be in their own path component, for example C. If set to B (the default), the plugin and plugin instance (and likewise the type and type -instance) are put into once component, for example C. +instance) are put into one component, for example C. =item B B|B diff --git a/src/collectdctl.c b/src/collectdctl.c index 3bd8f041..61b7fc55 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -485,7 +485,7 @@ static int putval (lcc_connection_t *c, int argc, char **argv) while (value != 0) { char *dot, *endptr; - tmp = strchr (argv[i], (int)':'); + tmp = strchr (value, (int)':'); if (tmp != NULL) { *tmp = '\0'; diff --git a/src/common.c b/src/common.c index 459c7024..406482ad 100644 --- a/src/common.c +++ b/src/common.c @@ -548,7 +548,7 @@ int check_create_dir (const char *file_orig) { if (errno == ENOENT) { - if (mkdir (dir, 0755) == 0) + if (mkdir (dir, S_IRWXU | S_IRWXG | S_IRWXO) == 0) break; /* this might happen, if a different thread created diff --git a/src/df.c b/src/df.c index 41a03cbf..ded374b9 100644 --- a/src/df.c +++ b/src/df.c @@ -228,6 +228,8 @@ static int df_read (void) { if (strcmp (mnt_ptr->dir, "/") == 0) { + if (strcmp (mnt_ptr->type, "rootfs") == 0) + continue; sstrncpy (disk_name, "root", sizeof (disk_name)); } else diff --git a/src/email.c b/src/email.c index 8fc5509f..5870ab1d 100644 --- a/src/email.c +++ b/src/email.c @@ -376,6 +376,7 @@ static void *collect (void *arg) } /* while (1) */ pthread_exit ((void *)0); + return ((void *) 0); } /* static void *collect (void *) */ static void *open_connection (void __attribute__((unused)) *arg) @@ -548,7 +549,9 @@ static void *open_connection (void __attribute__((unused)) *arg) pthread_cond_signal (&conn_available); } - pthread_exit ((void *)0); + + pthread_exit ((void *) 0); + return ((void *) 0); } /* static void *open_connection (void *) */ static int email_init (void) diff --git a/src/memcachec.c b/src/memcachec.c index 8f51e22f..c57a8312 100644 --- a/src/memcachec.c +++ b/src/memcachec.c @@ -328,7 +328,7 @@ static int cmc_config_add_page (oconfig_item_t *ci) /* {{{ */ if (strcasecmp ("Server", child->key) == 0) status = cmc_config_add_string ("Server", &page->server, child); - if (strcasecmp ("Key", child->key) == 0) + else if (strcasecmp ("Key", child->key) == 0) status = cmc_config_add_string ("Key", &page->key, child); else if (strcasecmp ("Match", child->key) == 0) /* Be liberal with failing matches => don't set `status'. */ diff --git a/src/mysql.c b/src/mysql.c index 6b636787..32b352bb 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -192,9 +192,9 @@ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */ ud.data = (void *) db; ud.free_func = mysql_database_free; - if (db->database != NULL) + if (db->instance != NULL) ssnprintf (cb_name, sizeof (cb_name), "mysql-%s", - db->database); + db->instance); else sstrncpy (cb_name, "mysql", sizeof (cb_name)); diff --git a/src/netapp.c b/src/netapp.c index d9bd1ae5..f7bc04d3 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -1,6 +1,6 @@ /** * collectd - src/netapp.c - * Copyright (C) 2009 Sven Trenkel + * Copyright (C) 2009,2010 Sven Trenkel * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -2497,7 +2497,7 @@ static int cna_init_host (host_config_t *host) /* {{{ */ na_server_adminuser(host->srv, host->username, host->password); na_server_set_timeout(host->srv, 5 /* seconds */); - return 0; + return (0); } /* }}} int cna_init_host */ static int cna_init (void) /* {{{ */ @@ -2514,6 +2514,32 @@ static int cna_init (void) /* {{{ */ return (0); } /* }}} cna_init */ +static int cna_read_internal (host_config_t *host) { /* {{{ */ + int status; + + status = cna_query_wafl (host); + if (status != 0) + return (status); + + status = cna_query_disk (host); + if (status != 0) + return (status); + + status = cna_query_volume_perf (host); + if (status != 0) + return (status); + + status = cna_query_volume_usage (host); + if (status != 0) + return (status); + + status = cna_query_system (host); + if (status != 0) + return (status); + + return 0; +} /* }}} int cna_read_internal */ + static int cna_read (user_data_t *ud) { /* {{{ */ host_config_t *host; int status; @@ -2526,12 +2552,14 @@ static int cna_read (user_data_t *ud) { /* {{{ */ status = cna_init_host (host); if (status != 0) return (status); - - cna_query_wafl (host); - cna_query_disk (host); - cna_query_volume_perf (host); - cna_query_volume_usage (host); - cna_query_system (host); + + status = cna_read_internal (host); + if (status != 0) + { + if (host->srv != NULL) + na_server_close (host->srv); + host->srv = NULL; + } return 0; } /* }}} int cna_read */ diff --git a/src/nfs.c b/src/nfs.c index 58f2e0d2..461e806f 100644 --- a/src/nfs.c +++ b/src/nfs.c @@ -332,10 +332,12 @@ static int nfs_read_kstat (kstat_t *ksp, int nfs_version, char *inst, kstat_read(kc, ksp, NULL); for (i = 0; i < proc_names_num; i++) - values[i].counter = (derive_t) get_kstat_value (ksp, proc_names[i]); + values[i].counter = (derive_t) get_kstat_value (ksp, + (char *)proc_names[i]); nfs_procedures_submit (plugin_instance, proc_names, values, proc_names_num); + return (0); } #endif diff --git a/src/oracle.c b/src/oracle.c index 86643ca3..ab0812b7 100644 --- a/src/oracle.c +++ b/src/oracle.c @@ -87,6 +87,7 @@ OCIError *oci_error = NULL; * Functions */ static void o_report_error (const char *where, /* {{{ */ + const char *db_name, const char *query_name, const char *what, OCIError *eh) { char buffer[2048]; @@ -94,6 +95,11 @@ static void o_report_error (const char *where, /* {{{ */ int status; unsigned int record_number; + if (db_name == NULL) + db_name = "(none)"; + if (query_name == NULL) + query_name = "(none)"; + /* An operation may cause / return multiple errors. Loop until we have * handled all errors available (with a fail-save limit of 16). */ for (record_number = 1; record_number <= 16; record_number++) @@ -123,12 +129,14 @@ static void o_report_error (const char *where, /* {{{ */ buffer[buffer_length] = 0; } - ERROR ("oracle plugin: %s: %s failed: %s", where, what, buffer); + ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed: %s", + where, db_name, query_name, what, buffer); } else { - ERROR ("oracle plugin: %s: %s failed. Additionally, OCIErrorGet failed with status %i.", - where, what, status); + ERROR ("oracle plugin: %s (db = %s, query = %s): %s failed. " + "Additionally, OCIErrorGet failed with status %i.", + where, db_name, query_name, what, status); return; } } @@ -408,7 +416,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ OCI_HTYPE_STMT, /* user_data_size = */ 0, /* user_data = */ NULL); if (status != OCI_SUCCESS) { - o_report_error ("o_read_database_query", "OCIHandleAlloc", oci_error); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIHandleAlloc", oci_error); oci_statement = NULL; return (-1); } @@ -419,7 +428,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ /* mode = */ OCI_DEFAULT); if (status != OCI_SUCCESS) { - o_report_error ("o_read_database_query", "OCIStmtPrepare", oci_error); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIStmtPrepare", oci_error); OCIHandleFree (oci_statement, OCI_HTYPE_STMT); oci_statement = NULL; return (-1); @@ -443,10 +453,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ /* mode = */ OCI_DEFAULT); if (status != OCI_SUCCESS) { - DEBUG ("oracle plugin: o_read_database_query: status = %i (%#x)", status, status); - o_report_error ("o_read_database_query", "OCIStmtExecute", oci_error); - ERROR ("oracle plugin: o_read_database_query: " - "Failing statement was: %s", udb_query_get_statement (q)); + o_report_error ("o_read_database_query", db->name, udb_query_get_name (q), + "OCIStmtExecute", oci_error); return (-1); } /* }}} */ @@ -459,7 +467,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ OCI_ATTR_PARAM_COUNT, oci_error); if (status != OCI_SUCCESS) { - o_report_error ("o_read_database_query", "OCIAttrGet", oci_error); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIAttrGet", oci_error); return (-1); } /* }}} */ @@ -537,8 +546,10 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ if (status != OCI_SUCCESS) { /* This is probably alright */ - DEBUG ("oracle plugin: o_read_database_query: status = %#x (= %i);", status, status); - o_report_error ("o_read_database_query", "OCIParamGet", oci_error); + DEBUG ("oracle plugin: o_read_database_query: status = %#x (= %i);", + status, status); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIParamGet", oci_error); status = OCI_SUCCESS; break; } @@ -550,8 +561,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ if (status != OCI_SUCCESS) { OCIDescriptorFree (oci_param, OCI_DTYPE_PARAM); - o_report_error ("o_read_database_query", "OCIAttrGet (OCI_ATTR_NAME)", - oci_error); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIAttrGet (OCI_ATTR_NAME)", oci_error); continue; } @@ -576,7 +587,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ NULL, NULL, NULL, OCI_DEFAULT); if (status != OCI_SUCCESS) { - o_report_error ("o_read_database_query", "OCIDefineByPos", oci_error); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIDefineByPos", oci_error); continue; } } /* for (j = 1; j <= param_counter; j++) */ @@ -608,7 +620,8 @@ static int o_read_database_query (o_database_t *db, /* {{{ */ } else if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO)) { - o_report_error ("o_read_database_query", "OCIStmtFetch2", oci_error); + o_report_error ("o_read_database_query", db->name, + udb_query_get_name (q), "OCIStmtFetch2", oci_error); break; } @@ -645,7 +658,8 @@ static int o_read_database (o_database_t *db) /* {{{ */ OCI_ATTR_SERVER, oci_error); if (status != OCI_SUCCESS) { - o_report_error ("o_read_database", "OCIAttrGet", oci_error); + o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet", + oci_error); return (-1); } @@ -661,7 +675,8 @@ static int o_read_database (o_database_t *db) /* {{{ */ OCI_ATTR_SERVER_STATUS, oci_error); if (status != OCI_SUCCESS) { - o_report_error ("o_read_database", "OCIAttrGet", oci_error); + o_report_error ("o_read_database", db->name, NULL, "OCIAttrGet", + oci_error); return (-1); } } @@ -684,7 +699,11 @@ static int o_read_database (o_database_t *db) /* {{{ */ (OraText *) db->connect_id, (ub4) strlen (db->connect_id)); if ((status != OCI_SUCCESS) && (status != OCI_SUCCESS_WITH_INFO)) { - o_report_error ("o_read_database", "OCILogon", oci_error); + char errfunc[256]; + + ssnprintf (errfunc, sizeof (errfunc), "OCILogon(\"%s\")", db->connect_id); + + o_report_error ("o_read_database", db->name, NULL, errfunc, oci_error); DEBUG ("oracle plugin: OCILogon (%s): db->oci_service_context = %p;", db->connect_id, db->oci_service_context); db->oci_service_context = NULL; diff --git a/src/redis.c b/src/redis.c index 4f4b33bb..439cf4b8 100644 --- a/src/redis.c +++ b/src/redis.c @@ -28,6 +28,10 @@ #include #include +#ifndef HOST_NAME_MAX +# define HOST_NAME_MAX _POSIX_HOST_NAME_MAX +#endif + #define REDIS_DEF_HOST "localhost" #define REDIS_DEF_PORT 6379 #define REDIS_DEF_TIMEOUT 2000 diff --git a/src/rrdtool.c b/src/rrdtool.c index 56a82d03..e5f964e5 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -185,7 +185,7 @@ static int srrd_update (char *filename, char *template, if (status != 0) { WARNING ("rrdtool plugin: rrd_update_r failed: %s: %s", - argv[1], rrd_get_error ()); + filename, rrd_get_error ()); } sfree (new_argv); diff --git a/src/snmp.c b/src/snmp.c index 160687f0..b68baf37 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -301,7 +301,7 @@ static int csnmp_config_add_data_shift (data_definition_t *dd, oconfig_item_t *c if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) { - WARNING ("snmp plugin: The `Scale' config option needs exactly one number argument."); + WARNING ("snmp plugin: The `Shift' config option needs exactly one number argument."); return (-1); } @@ -871,10 +871,12 @@ static int csnmp_check_res_left_subtree (const host_definition_t *host, vb = vb->next_variable, i++) { num_checked++; - if (snmp_oid_ncompare (data->values[i].oid, - data->values[i].oid_len, - vb->name, vb->name_length, - data->values[i].oid_len) != 0) + + if ((vb->type == SNMP_ENDOFMIBVIEW) + || (snmp_oid_ncompare (data->values[i].oid, + data->values[i].oid_len, + vb->name, vb->name_length, + data->values[i].oid_len) != 0)) num_left_subtree++; } diff --git a/src/utils_avltree.c b/src/utils_avltree.c index 0436d8fe..ba7cd95f 100644 --- a/src/utils_avltree.c +++ b/src/utils_avltree.c @@ -487,6 +487,8 @@ c_avl_tree_t *c_avl_create (int (*compare) (const void *, const void *)) void c_avl_destroy (c_avl_tree_t *t) { + if (t == NULL) + return; free_node (t->root); free (t); } diff --git a/src/utils_dns.c b/src/utils_dns.c index 1f171b33..80a2ee57 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -45,6 +45,12 @@ #if HAVE_NETINET_IN_H # include #endif +#if HAVE_NETINET_IP6_H +# include +#endif +#if HAVE_NETINET_IP_COMPAT_H +# include +#endif #if HAVE_ARPA_INET_H # include #endif @@ -449,7 +455,7 @@ handle_ipv6 (struct ip6_hdr *ipv6, int len) unsigned int offset; int nexthdr; - struct in6_addr s_addr; + struct in6_addr c_src_addr; uint16_t payload_len; if (0 > len) @@ -457,10 +463,10 @@ handle_ipv6 (struct ip6_hdr *ipv6, int len) offset = sizeof (struct ip6_hdr); nexthdr = ipv6->ip6_nxt; - s_addr = ipv6->ip6_src; + c_src_addr = ipv6->ip6_src; payload_len = ntohs (ipv6->ip6_plen); - if (ignore_list_match (&s_addr)) + if (ignore_list_match (&c_src_addr)) return (0); /* Parse extension headers. This only handles the standard headers, as @@ -469,7 +475,6 @@ handle_ipv6 (struct ip6_hdr *ipv6, int len) || (IPPROTO_HOPOPTS == nexthdr) /* Hop-by-Hop options. */ || (IPPROTO_FRAGMENT == nexthdr) /* fragmentation header. */ || (IPPROTO_DSTOPTS == nexthdr) /* destination options. */ - || (IPPROTO_DSTOPTS == nexthdr) /* destination options. */ || (IPPROTO_AH == nexthdr) /* destination options. */ || (IPPROTO_ESP == nexthdr)) /* encapsulating security payload. */ { @@ -527,15 +532,15 @@ handle_ip(const struct ip *ip, int len) { char buf[PCAP_SNAPLEN]; int offset = ip->ip_hl << 2; - struct in6_addr s_addr; - struct in6_addr d_addr; + struct in6_addr c_src_addr; + struct in6_addr c_dst_addr; if (ip->ip_v == 6) return (handle_ipv6 ((void *) ip, len)); - in6_addr_from_buffer (&s_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET); - in6_addr_from_buffer (&d_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET); - if (ignore_list_match (&s_addr)) + in6_addr_from_buffer (&c_src_addr, &ip->ip_src.s_addr, sizeof (ip->ip_src.s_addr), AF_INET); + in6_addr_from_buffer (&c_dst_addr, &ip->ip_dst.s_addr, sizeof (ip->ip_dst.s_addr), AF_INET); + if (ignore_list_match (&c_src_addr)) return (0); if (IPPROTO_UDP != ip->ip_p) return 0; diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c index 91ac6ce5..091b5fa6 100644 --- a/src/utils_rrdcreate.c +++ b/src/utils_rrdcreate.c @@ -406,9 +406,9 @@ int cu_rrd_create_file (const char *filename, /* {{{ */ argv[ds_num + rra_num] = NULL; last_up = CDTIME_T_TO_TIME_T (vl->time); - if (last_up <= 10) + if (last_up <= 0) last_up = time (NULL); - last_up -= 10; + last_up -= 1; if (cfg->stepsize > 0) stepsize = cfg->stepsize; diff --git a/src/varnish.c b/src/varnish.c index 357b5f11..de60e39c 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -412,6 +412,11 @@ static int varnish_read (user_data_t *ud) /* {{{ */ vd = VSM_New(); VSC_Setup(vd); + if (VSM_n_Arg(vd, conf->instance) == -1) + { + ERROR ("Varnish plugin : unable to load statistics from instance"); + return (-1); + } if (VSC_Open (vd, /* diag = */ 1)) { ERROR ("varnish plugin: Unable to load statistics."); diff --git a/src/write_mongodb.c b/src/write_mongodb.c index 8d76b608..c7b76820 100644 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@ -195,7 +195,14 @@ static int wm_write (const data_set_t *ds, /* {{{ */ /* Assert if the connection has been established */ assert (mongo_is_connected (node->conn)); - status = mongo_insert (node->conn, collection_name, bson_record); + #if MONGO_MINOR >= 6 + /* There was an API change in 0.6.0 as linked below */ + /* https://github.com/mongodb/mongo-c-driver/blob/master/HISTORY.md */ + status = mongo_insert (node->conn, collection_name, bson_record, NULL); + #else + status = mongo_insert (node->conn, collection_name, bson_record); + #endif + if(status != MONGO_OK) { ERROR ( "write_mongodb plugin: error inserting record: %d", node->conn->err); diff --git a/src/zfs_arc.c b/src/zfs_arc.c index e77569f5..f4352ff4 100644 --- a/src/zfs_arc.c +++ b/src/zfs_arc.c @@ -60,7 +60,7 @@ static int za_read_derive (kstat_t *ksp, const char *kstat_value, long long tmp; value_t v; - tmp = get_kstat_value (ksp, kstat_value); + tmp = get_kstat_value (ksp, (char *)kstat_value); if (tmp == -1LL) { ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); @@ -69,6 +69,7 @@ static int za_read_derive (kstat_t *ksp, const char *kstat_value, v.derive = (derive_t) tmp; za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); + return (0); } static int za_read_gauge (kstat_t *ksp, const char *kstat_value, @@ -77,7 +78,7 @@ static int za_read_gauge (kstat_t *ksp, const char *kstat_value, long long tmp; value_t v; - tmp = get_kstat_value (ksp, kstat_value); + tmp = get_kstat_value (ksp, (char *)kstat_value); if (tmp == -1LL) { ERROR ("zfs_arc plugin: Reading kstat value \"%s\" failed.", kstat_value); @@ -86,6 +87,7 @@ static int za_read_gauge (kstat_t *ksp, const char *kstat_value, v.gauge = (gauge_t) tmp; za_submit (type, type_instance, /* values = */ &v, /* values_num = */ 1); + return (0); } static void za_submit_ratio (const char* type_instance, gauge_t hits, gauge_t misses)