Merge branch 'collectd-4.6' into collectd-4.7
[collectd.git] / src / plugin.c
index 14126cd..6139baf 100644 (file)
@@ -573,6 +573,7 @@ int plugin_load (const char *type)
                else if (!S_ISREG (statbuf.st_mode))
                {
                        /* don't follow symlinks */
+                       WARNING ("stat %s: not a regular file", filename);
                        continue;
                }
 
@@ -650,7 +651,7 @@ int plugin_register_read (const char *name,
                read_heap = c_heap_create (plugin_compare_read_func);
                if (read_heap == NULL)
                {
-                       ERROR ("plugin_register_complex_read: "
+                       ERROR ("plugin_register_read: "
                                        "c_heap_create failed.");
                        return (-1);
                }
@@ -679,7 +680,9 @@ int plugin_register_read (const char *name,
 } /* int plugin_register_read */
 
 int plugin_register_complex_read (const char *name,
-               plugin_read_cb callback, user_data_t *user_data)
+               plugin_read_cb callback,
+               const struct timespec *interval,
+               user_data_t *user_data)
 {
        read_func_t *rf;
 
@@ -688,8 +691,7 @@ int plugin_register_complex_read (const char *name,
                read_heap = c_heap_create (plugin_compare_read_func);
                if (read_heap == NULL)
                {
-                       ERROR ("plugin_register_complex_read: "
-                                       "c_heap_create failed.");
+                       ERROR ("plugin_register_read: c_heap_create failed.");
                        return (-1);
                }
        }
@@ -705,8 +707,10 @@ int plugin_register_complex_read (const char *name,
        rf->rf_callback = (void *) callback;
        sstrncpy (rf->rf_name, name, sizeof (rf->rf_name));
        rf->rf_type = RF_COMPLEX;
-       rf->rf_interval.tv_sec = 0;
-       rf->rf_interval.tv_nsec = 0;
+       if (interval != NULL)
+       {
+               rf->rf_interval = *interval;
+       }
        rf->rf_effective_interval = rf->rf_interval;
 
        /* Set user data */
@@ -931,7 +935,6 @@ void plugin_read_all (void)
 /* Read function called when the `-T' command line argument is given. */
 int plugin_read_all_once (void)
 {
-       llentry_t   *le;
        int status;
        int return_status = 0;
 
@@ -967,7 +970,7 @@ int plugin_read_all_once (void)
                if (status != 0)
                {
                        NOTICE ("read-function of plugin `%s' failed.",
-                               le->key);
+                                       rf->rf_name);
                        return_status = -1;
                }
 
@@ -1163,6 +1166,9 @@ int plugin_dispatch_values (value_list_t *vl)
        if (vl->time == 0)
                vl->time = time (NULL);
 
+       if (vl->interval <= 0)
+               vl->interval = interval_g;
+
        DEBUG ("plugin_dispatch_values: time = %u; interval = %i; "
                        "host = %s; "
                        "plugin = %s; plugin_instance = %s; "
@@ -1251,6 +1257,9 @@ int plugin_dispatch_values (value_list_t *vl)
        /* Update the value cache */
        uc_update (ds, vl);
 
+       /* Initiate threshold checking */
+       ut_check_threshold (ds, vl);
+
        if (post_cache_chain != NULL)
        {
                status = fc_process_chain (ds, vl, post_cache_chain);