From: Florian Forster Date: Sat, 20 Dec 2008 09:18:21 +0000 (+0100) Subject: Merge branch 'collectd-4.5' X-Git-Tag: collectd-4.6.0~124 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=ef7fec0c4e0bbbabb356e6a570ac6297ee06eb80;hp=bc86995088a08d4d355517dd78d3d2b2027bc338 Merge branch 'collectd-4.5' --- diff --git a/src/Makefile.am b/src/Makefile.am index a631aa5f..35747e76 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -867,7 +867,7 @@ EXTRA_DIST += collectd-email.pod collectd-exec.pod collectd-nagios.pod \ .pod.1: pod2man --release=$(VERSION) --center=$(PACKAGE) $< \ >.pod2man.tmp 2>/dev/null && mv -f .pod2man.tmp $@ || true - if grep '\' $@ >/dev/null 2>&1; \ + @if grep '\' $@ >/dev/null 2>&1; \ then \ echo "$@ has some POD errors!"; false; \ fi @@ -875,7 +875,7 @@ EXTRA_DIST += collectd-email.pod collectd-exec.pod collectd-nagios.pod \ .pod.5: pod2man --section=5 --release=$(VERSION) --center=$(PACKAGE) $< \ >.pod2man.tmp 2>/dev/null && mv -f .pod2man.tmp $@ || true - if grep '\' $@ >/dev/null 2>&1; \ + @if grep '\' $@ >/dev/null 2>&1; \ then \ echo "$@ has some POD errors!"; false; \ fi diff --git a/src/collectd.c b/src/collectd.c index 71eb940f..9526ec91 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -244,7 +244,7 @@ static void update_kstat (void) /* TODO * Remove all settings but `-f' and `-C' */ -static void exit_usage (void) +static void exit_usage (int status) { printf ("Usage: "PACKAGE" [OPTIONS]\n\n" @@ -266,8 +266,8 @@ static void exit_usage (void) "\n"PACKAGE" "VERSION", http://collectd.org/\n" "by Florian octo Forster \n" "for contributions see `AUTHORS'\n"); - exit (0); -} /* static void exit_usage (char *name) */ + exit (status); +} /* static void exit_usage (int status) */ static int do_init (void) { @@ -436,11 +436,16 @@ int main (int argc, char **argv) break; #endif /* COLLECT_DAEMON */ case 'h': + exit_usage (0); + break; default: - exit_usage (); + exit_usage (1); } /* switch (c) */ } /* while (1) */ + if (optind < argc) + exit_usage (1); + /* * Read options from the config file, the environment and the command * line (in that order, with later options overwriting previous ones in diff --git a/src/collectd.conf.in b/src/collectd.conf.in index f6b75e7d..a474fdcd 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -414,7 +414,7 @@ FQDNLookup true # # Regex "\\" # DSType "CounterInc" -# Type "email_count" +# Type "counter" # Instance "local_user" # # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 40bdf113..55aa69b6 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1019,12 +1019,12 @@ database when started and keeps the connection up as long as possible. When the connection is interrupted for whatever reason it will try to re-connect. The plugin will complaint loudly in case anything goes wrong. -This plugin issues C and evaluates C, -C and C which correspond to F, -F and F. Also, the values of -C are put in F and values of C are put -in F. Please refer to the B, -I<5.2.4. Server Status Variables> for an explanation of these values. +This plugin issues the MySQL C command and collects information +about MySQL network traffic, executed statements, requests, the query cache +and threads by evaluating the C, C, +C, C and C return values. Please refer to the +B, I<5.1.6. Server Status Variables> for an +explanation of these values. Use the following options to configure the plugin: @@ -1036,7 +1036,9 @@ Hostname of the database server. Defaults to B. =item B I -Username to use when connecting to the database. +Username to use when connecting to the database. The user does not have to be +granted any privileges (which is synonym to granting the C privilege). +Any existing MySQL user will do. =item B I @@ -2050,16 +2052,16 @@ user using (extended) regular expressions, as described in L. Instance "exim" - Regex "S=([1-9][0-9]*)" - DSType "CounterAdd" - Type "ipt_bytes" - Instance "total" + Regex "S=([1-9][0-9]*)" + DSType "CounterAdd" + Type "ipt_bytes" + Instance "total" - Regex "\\" - DSType "CounterInc" - Type "counter" - Instance "local_user" + Regex "\\" + DSType "CounterInc" + Type "counter" + Instance "local_user" @@ -2390,7 +2392,7 @@ information. Instance "cached" - WarningMin 100000000 + WarningMin 100000000 diff --git a/src/common.c b/src/common.c index 61a759b1..119d284f 100644 --- a/src/common.c +++ b/src/common.c @@ -537,12 +537,12 @@ long long get_kstat_value (kstat_t *ksp, char *name) #else if (ksp == NULL) { - fprintf (stderr, "ERROR: %s:%i: ksp == NULL\n", __FILE__, __LINE__); + ERROR ("ERROR: %s:%i: ksp == NULL\n", __FILE__, __LINE__); return (-1LL); } else if (ksp->ks_type != KSTAT_TYPE_NAMED) { - fprintf (stderr, "ERROR: %s:%i: ksp->ks_type != KSTAT_TYPE_NAMED\n", __FILE__, __LINE__); + ERROR ("ERROR: %s:%i: ksp->ks_type != KSTAT_TYPE_NAMED\n", __FILE__, __LINE__); return (-1LL); } #endif diff --git a/src/configfile.c b/src/configfile.c index bdb63a9a..f9ade29b 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -156,7 +156,8 @@ static int cf_dispatch (const char *type, const char *orig_key, for (i = 0; i < cf_cb->keys_num; i++) { - if (strcasecmp (cf_cb->keys[i], key) == 0) + if ((cf_cb->keys[i] != NULL) + && (strcasecmp (cf_cb->keys[i], key) == 0)) { ret = (*cf_cb->callback) (key, value); break; diff --git a/src/email.c b/src/email.c index e208f130..5e103ed7 100644 --- a/src/email.c +++ b/src/email.c @@ -187,12 +187,18 @@ static int email_config (const char *key, const char *value) fprintf (stderr, "email plugin: `MaxConns' was set to invalid " "value %li, will use default %i.\n", tmp, MAX_CONNS); + ERROR ("email plugin: `MaxConns' was set to invalid " + "value %li, will use default %i.\n", + tmp, MAX_CONNS); max_conns = MAX_CONNS; } else if (tmp > MAX_CONNS_LIMIT) { fprintf (stderr, "email plugin: `MaxConns' was set to invalid " "value %li, will use hardcoded limit %i.\n", tmp, MAX_CONNS_LIMIT); + ERROR ("email plugin: `MaxConns' was set to invalid " + "value %li, will use hardcoded limit %i.\n", + tmp, MAX_CONNS_LIMIT); max_conns = MAX_CONNS_LIMIT; } else { diff --git a/src/ipmi.c b/src/ipmi.c index e219e89c..f3ba95a8 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -494,7 +494,7 @@ static void domain_connection_change_handler (ipmi_domain_t *domain, { int status; - printf ("domain_connection_change_handler (domain = %p, err = %i, " + DEBUG ("domain_connection_change_handler (domain = %p, err = %i, " "conn_num = %u, port_num = %u, still_connected = %i, " "user_data = %p);\n", (void *) domain, err, conn_num, port_num, still_connected, user_data); @@ -561,7 +561,7 @@ static void *thread_main (void *user_data) status = thread_init (&os_handler); if (status != 0) { - fprintf (stderr, "ipmi plugin: thread_init failed.\n"); + ERROR ("ipmi plugin: thread_init failed.\n"); return ((void *) -1); } diff --git a/src/perl.c b/src/perl.c index cdfb8d5e..4a76c0aa 100644 --- a/src/perl.c +++ b/src/perl.c @@ -1092,7 +1092,7 @@ static XS (Collectd_plugin_log) XSRETURN_EMPTY; } - plugin_log (SvIV (ST (0)), SvPV_nolen (ST (1))); + plugin_log (SvIV (ST (0)), "%s", SvPV_nolen (ST (1))); XSRETURN_YES; } /* static XS (Collectd_plugin_log) */ diff --git a/src/processes.c b/src/processes.c index 4fb70ade..f4ffef8f 100644 --- a/src/processes.c +++ b/src/processes.c @@ -107,8 +107,7 @@ static const char *config_keys[] = { "Process", - "ProcessMatch", - NULL + "ProcessMatch" }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); diff --git a/src/rrdtool.c b/src/rrdtool.c index 9b236cb8..32655616 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -819,6 +819,8 @@ static int rrd_config (const char *key, const char *value) { fprintf (stderr, "rrdtool: `CacheTimeout' must " "be greater than 0.\n"); + ERROR ("rrdtool: `CacheTimeout' must " + "be greater than 0.\n"); return (1); } cache_timeout = tmp; @@ -830,6 +832,8 @@ static int rrd_config (const char *key, const char *value) { fprintf (stderr, "rrdtool: `CacheFlush' must " "be greater than 0.\n"); + ERROR ("rrdtool: `CacheFlush' must " + "be greater than 0.\n"); return (1); } cache_flush_timeout = tmp; @@ -873,6 +877,8 @@ static int rrd_config (const char *key, const char *value) { fprintf (stderr, "rrdtool: `RRARows' must " "be greater than 0.\n"); + ERROR ("rrdtool: `RRARows' must " + "be greater than 0.\n"); return (1); } rrdcreate_config.rrarows = tmp; @@ -899,6 +905,7 @@ static int rrd_config (const char *key, const char *value) if (tmp_alloc == NULL) { fprintf (stderr, "rrdtool: realloc failed.\n"); + ERROR ("rrdtool: realloc failed.\n"); free (value_copy); return (1); } @@ -922,6 +929,8 @@ static int rrd_config (const char *key, const char *value) { fprintf (stderr, "rrdtool: `XFF' must " "be in the range 0 to 1 (exclusive)."); + ERROR ("rrdtool: `XFF' must " + "be in the range 0 to 1 (exclusive)."); return (1); } rrdcreate_config.xff = tmp; diff --git a/src/unixsock.c b/src/unixsock.c index d800906e..3bdd8c27 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -383,8 +383,15 @@ static int us_config (const char *key, const char *val) static int us_init (void) { + static int have_init = 0; + int status; + /* Initialize only once. */ + if (have_init != 0) + return (0); + have_init = 1; + loop = 1; status = pthread_create (&listen_thread, NULL, us_server_thread, NULL); diff --git a/src/utils_complain.c b/src/utils_complain.c index d5c09964..9074b183 100644 --- a/src/utils_complain.c +++ b/src/utils_complain.c @@ -50,7 +50,7 @@ static int vcomplain (int level, c_complain_t *c, vsnprintf (message, sizeof (message), format, ap); message[sizeof (message) - 1] = '\0'; - plugin_log (level, message); + plugin_log (level, "%s", message); return 1; } /* vcomplain */ @@ -95,7 +95,7 @@ void c_do_release (int level, c_complain_t *c, const char *format, ...) message[sizeof (message) - 1] = '\0'; va_end (ap); - plugin_log (level, message); + plugin_log (level, "%s", message); } /* c_release */ /* vim: set sw=4 ts=4 tw=78 noexpandtab : */ diff --git a/src/utils_dns.c b/src/utils_dns.c index c16ca52c..c16b3c12 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -34,6 +34,7 @@ */ #include "collectd.h" +#include "plugin.h" #include "common.h" #if HAVE_NETINET_IN_SYSTM_H @@ -355,7 +356,6 @@ handle_dns(const char *buf, int len, memcpy(&us, buf + 2, 2); us = ntohs(us); - fprintf (stderr, "Bytes 0, 1: 0x%04hx\n", us); qh.qr = (us >> 15) & 0x01; qh.opcode = (us >> 11) & 0x0F; qh.aa = (us >> 10) & 0x01; @@ -649,7 +649,7 @@ void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt { int status; - fprintf (stderr, "handle_pcap (udata = %p, hdr = %p, pkt = %p): hdr->caplen = %i\n", + DEBUG ("handle_pcap (udata = %p, hdr = %p, pkt = %p): hdr->caplen = %i\n", (void *) udata, (void *) hdr, (void *) pkt, hdr->caplen); @@ -686,7 +686,7 @@ void handle_pcap(u_char *udata, const struct pcap_pkthdr *hdr, const u_char *pkt break; default: - fprintf (stderr, "unsupported data link type %d\n", + ERROR ("handle_pcap: unsupported data link type %d\n", pcap_datalink(pcap_obj)); status = 0; break;