Merge branch 'collectd-4.5'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 20 Dec 2008 09:18:21 +0000 (10:18 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 20 Dec 2008 09:18:21 +0000 (10:18 +0100)
14 files changed:
src/Makefile.am
src/collectd.c
src/collectd.conf.in
src/collectd.conf.pod
src/common.c
src/configfile.c
src/email.c
src/ipmi.c
src/perl.c
src/processes.c
src/rrdtool.c
src/unixsock.c
src/utils_complain.c
src/utils_dns.c

index a631aa5..35747e7 100644 (file)
@@ -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 '\<POD ERRORS\>' $@ >/dev/null 2>&1; \
+       @if grep '\<POD ERRORS\>' $@ >/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 '\<POD ERRORS\>' $@ >/dev/null 2>&1; \
+       @if grep '\<POD ERRORS\>' $@ >/dev/null 2>&1; \
        then \
                echo "$@ has some POD errors!"; false; \
        fi
index 71eb940..9526ec9 100644 (file)
@@ -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 <octo@verplant.org>\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
index f6b75e7..a474fdc 100644 (file)
@@ -414,7 +414,7 @@ FQDNLookup   true
 #    <Match>
 #      Regex "\\<R=local_user\\>"
 #      DSType "CounterInc"
-#      Type "email_count"
+#      Type "counter"
 #      Instance "local_user"
 #    </Match>
 #  </File>
index 40bdf11..55aa69b 100644 (file)
@@ -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<SHOW STATUS> and evaluates C<Bytes_{received,sent}>,
-C<Com_*> and C<Handler_*> which correspond to F<mysql_octets.rrd>,
-F<mysql_commands-*.rrd> and F<mysql_handler-*.rrd>. Also, the values of
-C<Qcache_*> are put in F<mysql_qcache.rrd> and values of C<Threads_*> are put
-in F<mysql_threads.rrd>. Please refer to the B<MySQL reference manual>,
-I<5.2.4. Server Status Variables> for an explanation of these values.
+This plugin issues the MySQL C<SHOW STATUS> command and collects information
+about MySQL network traffic, executed statements, requests, the query cache
+and threads by evaluating the C<Bytes_{received,sent}>, C<Com_*>,
+C<Handler_*>, C<Qcache_*> and C<Threads_*> return values. Please refer to the
+B<MySQL reference manual>, 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<localhost>.
 
 =item B<User> I<Username>
 
-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<USAGE> privilege).
+Any existing MySQL user will do.
 
 =item B<Password> I<Password>
 
@@ -2050,16 +2052,16 @@ user using (extended) regular expressions, as described in L<regex(7)>.
     <File "/var/log/exim4/mainlog">
       Instance "exim"
       <Match>
-       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"
       </Match>
       <Match>
-       Regex "\\<R=local_user\\>"
-       DSType "CounterInc"
-       Type "counter"
-       Instance "local_user"
+        Regex "\\<R=local_user\\>"
+        DSType "CounterInc"
+        Type "counter"
+        Instance "local_user"
       </Match>
     </File>
   </Plugin>
@@ -2390,7 +2392,7 @@ information.
      <Plugin "memory">
        <Type "memory">
          Instance "cached"
-        WarningMin 100000000
+         WarningMin 100000000
        </Type>
      </Plugin>
    </Host>
index 61a759b..119d284 100644 (file)
@@ -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
index bdb63a9..f9ade29 100644 (file)
@@ -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;
index e208f13..5e103ed 100644 (file)
@@ -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 {
index e219e89..f3ba95a 100644 (file)
@@ -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);
   }
 
index cdfb8d5..4a76c0a 100644 (file)
@@ -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) */
 
index 4fb70ad..f4ffef8 100644 (file)
 static const char *config_keys[] =
 {
        "Process",
-       "ProcessMatch",
-       NULL
+       "ProcessMatch"
 };
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
 
index 9b236cb..3265561 100644 (file)
@@ -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;
index d800906..3bdd8c2 100644 (file)
@@ -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);
index d5c0996..9074b18 100644 (file)
@@ -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 : */
index c16ca52..c16b3c1 100644 (file)
@@ -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;