Merge branch 'collectd-4.3' into collectd-4.4
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 6 Jul 2008 13:04:41 +0000 (15:04 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 6 Jul 2008 13:04:41 +0000 (15:04 +0200)
contrib/examples/MyPlugin.pm
contrib/examples/myplugin.c
src/collectd.conf.in
src/common.c
src/email.c
src/plugin.c
src/rrdtool.c
src/utils_dns.c

index 1a0247f..13806ee 100644 (file)
@@ -21,7 +21,12 @@ use Collectd qw( :all );
 
 # data set definition:
 # see section "DATA TYPES" in collectd-perl(5) for details
-# (take a look at the types.db file for a large list of predefined data-sets)
+#
+# NOTE: If you're defining a custom data-set, you have to make that known to
+# any servers as well. Else, the server is not able to store values using the
+# type defined by that data-set.
+# It is strongly recommended to use one of the types and data-sets pre-defined
+# in the types.db file.
 my $dataset =
 [
        {
@@ -70,7 +75,8 @@ sub my_read
 
        # dispatch the values to collectd which passes them on to all registered
        # write functions - the first argument is used to lookup the data set
-       # definition
+       # definition (it is strongly recommended to use a type defined in the
+       # types.db file)
        plugin_dispatch_values ('myplugin', $vl);
 
        # A false return value indicates an error and the plugin will be skipped
index cdd537a..240c6c3 100644 (file)
@@ -59,6 +59,12 @@ static data_source_t dsrc[1] =
  * - name of the data set
  * - number of data sources
  * - list of data sources
+ *
+ * NOTE: If you're defining a custom data-set, you have to make that known to
+ * any servers as well. Else, the server is not able to store values using the
+ * type defined by that data-set.
+ * It is strongly recommended to use one of the types and data-sets
+ * pre-defined in the types.db file.
  */
 static data_set_t ds =
 {
@@ -99,7 +105,8 @@ static int my_read (void)
 
        /* dispatch the values to collectd which passes them on to all registered
         * write functions - the first argument is used to lookup the data set
-        * definition */
+        * definition (it is strongly recommended to use a type defined in the
+        * types.db file) */
        plugin_dispatch_values ("myplugin", &vl);
 
        /* A return value != 0 indicates an error and the plugin will be skipped
index ad0628a..f4e04d3 100644 (file)
@@ -120,7 +120,7 @@ FQDNLookup   true
 
 #<Plugin exec>
 #      Exec "user:group" "/path/to/exec"
-#      NotificationExec "/path/to/exec"
+#      NotificationExec "user:group" "/path/to/exec"
 #</Plugin>
 
 @BUILD_PLUGIN_HDDTEMP_TRUE@<Plugin hddtemp>
index 5c3db5d..82b4aaa 100644 (file)
@@ -70,12 +70,12 @@ char *sstrdup (const char *s)
 
        if((r = strdup (s)) == NULL)
        {
-               DEBUG ("Not enough memory.");
-               exit(3);
+               ERROR ("Not enough memory.");
+               exit (3);
        }
 
        return (r);
-}
+} /* char *sstrdup */
 
 /* Even though Posix requires "strerror_r" to return an "int",
  * some systems (e.g. the GNU libc) return a "char *" _and_
@@ -131,12 +131,12 @@ void *smalloc (size_t size)
 
        if ((r = malloc (size)) == NULL)
        {
-               DEBUG("Not enough memory.");
-               exit(3);
+               ERROR ("Not enough memory.");
+               exit (3);
        }
 
-       return r;
-}
+       return (r);
+} /* void *smalloc */
 
 #if 0
 void sfree (void **ptr)
@@ -224,7 +224,7 @@ int strsplit (char *string, char **fields, size_t size)
        i = 0;
        ptr = string;
        saveptr = NULL;
-       while ((fields[i] = strtok_r (ptr, " \t", &saveptr)) != NULL)
+       while ((fields[i] = strtok_r (ptr, " \t\r\n", &saveptr)) != NULL)
        {
                ptr = NULL;
                i++;
index 510a664..9a93405 100644 (file)
@@ -396,7 +396,6 @@ static void *open_connection (void *arg)
 
        strncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
        addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
-       unlink (addr.sun_path);
 
        errno = 0;
        if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
index 1aad97c..e611b8c 100644 (file)
@@ -580,22 +580,15 @@ void plugin_init_all (void)
        llentry_t *le;
        int status;
 
-       /* Start read-threads */
-       if (list_read != NULL)
-       {
-               const char *rt;
-               int num;
-               rt = global_option_get ("ReadThreads");
-               num = atoi (rt);
-               start_threads ((num > 0) ? num : 5);
-       }
-
        /* Init the value cache */
        uc_init ();
 
-       if (list_init == NULL)
+       if ((list_init == NULL) && (list_read == NULL))
                return;
 
+       /* Calling all init callbacks before checking if read callbacks
+        * are available allows the init callbacks to register the read
+        * callback. */
        le = llist_head (list_init);
        while (le != NULL)
        {
@@ -608,12 +601,25 @@ void plugin_init_all (void)
                                        "failed with status %i. "
                                        "Plugin will be unloaded.",
                                        le->key, status);
+                       /* Plugins that register read callbacks from the init
+                        * callback should take care of appropriate error
+                        * handling themselves. */
                        /* FIXME: Unload _all_ functions */
                        plugin_unregister_read (le->key);
                }
 
                le = le->next;
        }
+
+       /* Start read-threads */
+       if (list_read != NULL)
+       {
+               const char *rt;
+               int num;
+               rt = global_option_get ("ReadThreads");
+               num = atoi (rt);
+               start_threads ((num > 0) ? num : 5);
+       }
 } /* void plugin_init_all */
 
 void plugin_read_all (void)
index 653995d..3b2c54f 100644 (file)
@@ -342,7 +342,7 @@ static int srrd_create (char *filename, unsigned long pdp_step, time_t last_up,
        optind = 0; /* bug in librrd? */
        rrd_clear_error ();
 
-       status = rrd_create_r (filename, pdp_step, last_up, argc, argv);
+       status = rrd_create_r (filename, pdp_step, last_up, argc, (void *) argv);
 
        if (status != 0)
        {
@@ -360,7 +360,7 @@ static int srrd_update (char *filename, char *template, int argc, char **argv)
        optind = 0; /* bug in librrd? */
        rrd_clear_error ();
 
-       status = rrd_update_r (filename, template, argc, argv);
+       status = rrd_update_r (filename, template, argc, (void *) argv);
 
        if (status != 0)
        {
index 3f5d4fb..9b00151 100644 (file)
@@ -704,7 +704,7 @@ const char *qtype_str(int t)
 {
     static char buf[32];
     switch (t) {
-#if (defined (__NAMESER)) && (__NAMESER >= 19991006)
+#if (defined (__NAMESER)) && (__NAMESER >= 19991001)
            case ns_t_a:        return ("A");
            case ns_t_ns:       return ("NS");
            case ns_t_md:       return ("MD");
@@ -746,7 +746,9 @@ const char *qtype_str(int t)
            case ns_t_dname:    return ("DNAME");
            case ns_t_sink:     return ("SINK");
            case ns_t_opt:      return ("OPT");
+# if __NAMESER >= 19991006
            case ns_t_tsig:     return ("TSIG");
+# endif
            case ns_t_ixfr:     return ("IXFR");
            case ns_t_axfr:     return ("AXFR");
            case ns_t_mailb:    return ("MAILB");