X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fplugin.c;h=23ea9017cce27aa71370c32b41d7496b0944c837;hb=51ed8fc1a698fbfd1d557d7615228c32dcbc2105;hp=64dbf7805c92cccef4113bdadac24e928b332b45;hpb=348fa70f34d7e32fafebb82053e0c84625c2ba67;p=collectd.git diff --git a/src/plugin.c b/src/plugin.c index 64dbf780..23ea9017 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -133,7 +133,7 @@ static int plugin_load_file (char *file) const char *error = lt_dlerror (); ERROR ("lt_dlopen failed: %s", error); - DEBUG ("lt_dlopen failed: %s", error); + fprintf (stderr, "lt_dlopen failed: %s\n", error); return (1); } @@ -194,7 +194,7 @@ static void *plugin_read_thread (void *args) rf->wait_time = 86400; NOTICE ("read-function of plugin `%s' " - "failed. Will syspend it for %i " + "failed. Will suspend it for %i " "seconds.", le->key, rf->wait_left); } else @@ -356,6 +356,10 @@ int plugin_load (const char *type) ret = 0; break; } + else + { + fprintf (stderr, "Unable to load plugin %s.\n", type); + } } closedir (dh); @@ -374,6 +378,12 @@ int plugin_register_config (const char *name, return (0); } /* int plugin_register_config */ +int plugin_register_complex_config (const char *type, + int (*callback) (oconfig_item_t *)) +{ + return (cf_register_complex (type, callback)); +} /* int plugin_register_complex_config */ + int plugin_register_init (const char *name, int (*callback) (void)) { @@ -458,6 +468,12 @@ int plugin_unregister_config (const char *name) return (0); } /* int plugin_unregister_config */ +int plugin_unregister_complex_config (const char *name) +{ + cf_unregister_complex (name); + return (0); +} /* int plugin_unregister_complex_config */ + int plugin_unregister_init (const char *name) { return (plugin_unregister (list_init, name)); @@ -607,13 +623,18 @@ void plugin_shutdown_all (void) while (le != NULL) { callback = (int (*) (void)) le->value; - (*callback) (); + /* Advance the pointer before calling the callback allows + * shutdown functions to unregister themselves. If done the + * other way around the memory `le' points to will be freed + * after callback returns. */ le = le->next; + + (*callback) (); } } /* void plugin_shutdown_all */ -int plugin_dispatch_values (const char *name, const value_list_t *vl) +int plugin_dispatch_values (const char *name, value_list_t *vl) { int (*callback) (const data_set_t *, const value_list_t *); data_set_t *ds; @@ -631,10 +652,12 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl) ds = (data_set_t *) le->value; - DEBUG ("plugin: plugin_dispatch_values: time = %u; host = %s; " - "plugin = %s; plugin_instance = %s; type = %s; " - "type_instance = %s;", - (unsigned int) vl->time, vl->host, + DEBUG ("plugin: plugin_dispatch_values: time = %u; interval = %i; " + "host = %s; " + "plugin = %s; plugin_instance = %s; " + "type = %s; type_instance = %s;", + (unsigned int) vl->time, vl->interval, + vl->host, vl->plugin, vl->plugin_instance, ds->type, vl->type_instance); @@ -650,6 +673,11 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl) } #endif + escape_slashes (vl->host, sizeof (vl->host)); + escape_slashes (vl->plugin, sizeof (vl->plugin)); + escape_slashes (vl->plugin_instance, sizeof (vl->plugin_instance)); + escape_slashes (vl->type_instance, sizeof (vl->type_instance)); + le = llist_head (list_write); while (le != NULL) { @@ -660,7 +688,7 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl) } return (0); -} +} /* int plugin_dispatch_values */ void plugin_log (int level, const char *format, ...) {