2 * collectd - src/plugin.c
3 * Copyright (C) 2005-2009 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
20 * Sebastian Harl <sh at tokkee.org>
24 #include "utils_complain.h"
34 #include "configfile.h"
35 #include "utils_avltree.h"
36 #include "utils_llist.h"
37 #include "utils_cache.h"
38 #include "utils_threshold.h"
39 #include "filter_chain.h"
53 int (*cb_simple) (void);
54 plugin_read_cb cb_complex;
56 enum { DONE = 0, TODO = 1, ACTIVE = 2 } needs_read;
59 typedef struct read_func_s read_func_t;
64 static llist_t *list_init;
65 static llist_t *list_read;
66 static llist_t *list_write;
67 static llist_t *list_flush;
68 static llist_t *list_shutdown;
69 static llist_t *list_log;
70 static llist_t *list_notification;
72 static fc_chain_t *pre_cache_chain = NULL;
73 static fc_chain_t *post_cache_chain = NULL;
75 static c_avl_tree_t *data_sets;
77 static char *plugindir = NULL;
79 static int read_loop = 1;
80 static pthread_mutex_t read_lock = PTHREAD_MUTEX_INITIALIZER;
81 static pthread_cond_t read_cond = PTHREAD_COND_INITIALIZER;
82 static pthread_t *read_threads = NULL;
83 static int read_threads_num = 0;
88 static const char *plugin_get_dir (void)
90 if (plugindir == NULL)
96 static int register_callback (llist_t **list, const char *name, void *callback)
102 && ((*list = llist_create ()) == NULL))
105 le = llist_search (*list, name);
112 le = llentry_create (key, callback);
119 llist_append (*list, le);
123 le->value = callback;
127 } /* int register_callback */
129 static void plugin_user_data_destroy (user_data_t *ud)
131 if ((ud != NULL) && (ud->data != NULL) && (ud->free_func != NULL))
133 ud->free_func (ud->data);
135 ud->free_func = NULL;
137 } /* void plugin_user_data_destroy */
139 static int plugin_unregister (llist_t *list, const char *name)
143 e = llist_search (list, name);
148 llist_remove (list, e);
153 } /* int plugin_unregister */
156 * (Try to) load the shared object `file'. Won't complain if it isn't a shared
157 * object, but it will bitch about a shared object not having a
158 * ``module_register'' symbol..
160 static int plugin_load_file (char *file)
163 void (*reg_handle) (void);
165 DEBUG ("file = %s", file);
168 lt_dlerror (); /* clear errors */
170 if ((dlh = lt_dlopen (file)) == NULL)
172 const char *error = lt_dlerror ();
174 ERROR ("lt_dlopen (%s) failed: %s", file, error);
175 fprintf (stderr, "lt_dlopen (%s) failed: %s\n", file, error);
179 if ((reg_handle = (void (*) (void)) lt_dlsym (dlh, "module_register")) == NULL)
181 WARNING ("Couldn't find symbol `module_register' in `%s': %s\n",
182 file, lt_dlerror ());
192 static void *plugin_read_thread (void __attribute__((unused)) *args)
199 pthread_mutex_lock (&read_lock);
201 while (read_loop != 0)
203 le = llist_head (list_read);
206 while ((read_loop != 0) && (le != NULL))
208 rf = (read_func_t *) le->value;
210 if (rf->needs_read != TODO)
216 /* We will do this read function */
217 rf->needs_read = ACTIVE;
219 DEBUG ("[thread #%5lu] plugin: plugin_read_thread: Handling %s",
220 (unsigned long int) pthread_self (), le->key);
221 pthread_mutex_unlock (&read_lock);
223 if (rf->type == RF_SIMPLE)
225 status = rf->callback.cb_simple ();
229 assert (rf->type == RF_COMPLEX);
230 status = rf->callback.cb_complex (&rf->udata);
236 if (rf->wait_time < interval_g)
237 rf->wait_time = interval_g;
238 rf->wait_left = rf->wait_time;
239 rf->wait_time = rf->wait_time * 2;
240 if (rf->wait_time > 86400)
241 rf->wait_time = 86400;
243 NOTICE ("read-function of plugin `%s' "
244 "failed. Will suspend it for %i "
245 "seconds.", le->key, rf->wait_left);
250 rf->wait_time = interval_g;
253 pthread_mutex_lock (&read_lock);
255 rf->needs_read = DONE;
257 } /* while (le != NULL) */
259 if ((read_loop != 0) && (done == 0))
261 DEBUG ("[thread #%5lu] plugin: plugin_read_thread: Waiting on read_cond.",
262 (unsigned long int) pthread_self ());
263 pthread_cond_wait (&read_cond, &read_lock);
265 } /* while (read_loop) */
267 pthread_mutex_unlock (&read_lock);
271 } /* void *plugin_read_thread */
273 static void start_threads (int num)
277 if (read_threads != NULL)
280 read_threads = (pthread_t *) calloc (num, sizeof (pthread_t));
281 if (read_threads == NULL)
283 ERROR ("plugin: start_threads: calloc failed.");
287 read_threads_num = 0;
288 for (i = 0; i < num; i++)
290 if (pthread_create (read_threads + read_threads_num, NULL,
291 plugin_read_thread, NULL) == 0)
297 ERROR ("plugin: start_threads: pthread_create failed.");
301 } /* void start_threads */
303 static void stop_threads (void)
307 if (read_threads == NULL)
310 pthread_mutex_lock (&read_lock);
312 DEBUG ("plugin: stop_threads: Signalling `read_cond'");
313 pthread_cond_broadcast (&read_cond);
314 pthread_mutex_unlock (&read_lock);
316 for (i = 0; i < read_threads_num; i++)
318 if (pthread_join (read_threads[i], NULL) != 0)
320 ERROR ("plugin: stop_threads: pthread_join failed.");
322 read_threads[i] = (pthread_t) 0;
324 sfree (read_threads);
325 read_threads_num = 0;
326 } /* void stop_threads */
331 void plugin_set_dir (const char *dir)
333 if (plugindir != NULL)
338 else if ((plugindir = strdup (dir)) == NULL)
341 ERROR ("strdup failed: %s",
342 sstrerror (errno, errbuf, sizeof (errbuf)));
347 int plugin_load (const char *type)
351 char filename[BUFSIZE] = "";
352 char typename[BUFSIZE];
359 DEBUG ("type = %s", type);
361 dir = plugin_get_dir ();
364 /* `cpu' should not match `cpufreq'. To solve this we add `.so' to the
365 * type when matching the filename */
366 status = ssnprintf (typename, sizeof (typename), "%s.so", type);
367 if ((status < 0) || ((size_t) status >= sizeof (typename)))
369 WARNING ("snprintf: truncated: `%s.so'", type);
372 typename_len = strlen (typename);
374 if ((dh = opendir (dir)) == NULL)
377 ERROR ("opendir (%s): %s", dir,
378 sstrerror (errno, errbuf, sizeof (errbuf)));
382 while ((de = readdir (dh)) != NULL)
384 if (strncasecmp (de->d_name, typename, typename_len))
387 status = ssnprintf (filename, sizeof (filename),
388 "%s/%s", dir, de->d_name);
389 if ((status < 0) || ((size_t) status >= sizeof (filename)))
391 WARNING ("snprintf: truncated: `%s/%s'", dir, de->d_name);
395 if (lstat (filename, &statbuf) == -1)
398 WARNING ("stat %s: %s", filename,
399 sstrerror (errno, errbuf, sizeof (errbuf)));
402 else if (!S_ISREG (statbuf.st_mode))
404 /* don't follow symlinks */
408 if (plugin_load_file (filename) == 0)
416 fprintf (stderr, "Unable to load plugin %s.\n", type);
422 if (filename[0] == '\0')
423 fprintf (stderr, "Could not find plugin %s.\n", type);
429 * The `register_*' functions follow
431 int plugin_register_config (const char *name,
432 int (*callback) (const char *key, const char *val),
433 const char **keys, int keys_num)
435 cf_register (name, callback, keys, keys_num);
437 } /* int plugin_register_config */
439 int plugin_register_complex_config (const char *type,
440 int (*callback) (oconfig_item_t *))
442 return (cf_register_complex (type, callback));
443 } /* int plugin_register_complex_config */
445 int plugin_register_init (const char *name,
446 int (*callback) (void))
448 return (register_callback (&list_init, name, (void *) callback));
449 } /* plugin_register_init */
451 int plugin_register_read (const char *name,
452 int (*callback) (void))
456 rf = (read_func_t *) malloc (sizeof (read_func_t));
460 ERROR ("plugin_register_read: malloc failed: %s",
461 sstrerror (errno, errbuf, sizeof (errbuf)));
465 memset (rf, 0, sizeof (read_func_t));
466 rf->wait_time = interval_g;
468 rf->type = RF_SIMPLE;
469 rf->callback.cb_simple = callback;
470 rf->needs_read = DONE;
471 rf->udata.data = NULL;
472 rf->udata.free_func = NULL;
474 return (register_callback (&list_read, name, (void *) rf));
475 } /* int plugin_register_read */
477 int plugin_register_complex_read (const char *name,
478 plugin_read_cb callback, user_data_t *user_data)
482 rf = (read_func_t *) malloc (sizeof (read_func_t));
485 ERROR ("plugin_register_complex_read: malloc failed.");
489 memset (rf, 0, sizeof (read_func_t));
490 rf->wait_time = interval_g;
492 rf->type = RF_COMPLEX;
493 rf->callback.cb_complex = callback;
494 rf->needs_read = DONE;
497 if (user_data == NULL)
499 rf->udata.data = NULL;
500 rf->udata.free_func = NULL;
504 rf->udata = *user_data;
507 return (register_callback (&list_read, name, (void *) rf));
508 } /* int plugin_register_complex_read */
510 int plugin_register_write (const char *name,
511 plugin_write_cb callback, user_data_t *user_data)
515 wr = (write_func_t *) malloc (sizeof (*wr));
518 ERROR ("plugin_register_write: malloc failed.");
521 memset (wr, 0, sizeof (*wr));
523 wr->callback = callback;
524 if (user_data == NULL)
526 wr->udata.data = NULL;
527 wr->udata.free_func = NULL;
531 wr->udata = *user_data;
534 return (register_callback (&list_write, name, (void *) wr));
535 } /* int plugin_register_write */
537 int plugin_register_flush (const char *name,
538 int (*callback) (const int timeout, const char *identifier))
540 return (register_callback (&list_flush, name, (void *) callback));
541 } /* int plugin_register_flush */
543 int plugin_register_shutdown (char *name,
544 int (*callback) (void))
546 return (register_callback (&list_shutdown, name, (void *) callback));
547 } /* int plugin_register_shutdown */
549 int plugin_register_data_set (const data_set_t *ds)
554 if ((data_sets != NULL)
555 && (c_avl_get (data_sets, ds->type, NULL) == 0))
557 NOTICE ("Replacing DS `%s' with another version.", ds->type);
558 plugin_unregister_data_set (ds->type);
560 else if (data_sets == NULL)
562 data_sets = c_avl_create ((int (*) (const void *, const void *)) strcmp);
563 if (data_sets == NULL)
567 ds_copy = (data_set_t *) malloc (sizeof (data_set_t));
570 memcpy(ds_copy, ds, sizeof (data_set_t));
572 ds_copy->ds = (data_source_t *) malloc (sizeof (data_source_t)
574 if (ds_copy->ds == NULL)
580 for (i = 0; i < ds->ds_num; i++)
581 memcpy (ds_copy->ds + i, ds->ds + i, sizeof (data_source_t));
583 return (c_avl_insert (data_sets, (void *) ds_copy->type, (void *) ds_copy));
584 } /* int plugin_register_data_set */
586 int plugin_register_log (char *name,
587 void (*callback) (int priority, const char *msg))
589 return (register_callback (&list_log, name, (void *) callback));
590 } /* int plugin_register_log */
592 int plugin_register_notification (const char *name,
593 int (*callback) (const notification_t *notif))
595 return (register_callback (&list_notification, name, (void *) callback));
596 } /* int plugin_register_log */
598 int plugin_unregister_config (const char *name)
600 cf_unregister (name);
602 } /* int plugin_unregister_config */
604 int plugin_unregister_complex_config (const char *name)
606 cf_unregister_complex (name);
608 } /* int plugin_unregister_complex_config */
610 int plugin_unregister_init (const char *name)
612 return (plugin_unregister (list_init, name));
615 int plugin_unregister_read (const char *name)
620 e = llist_search (list_read, name);
625 llist_remove (list_read, e);
627 rf = (read_func_t *) e->value;
628 plugin_user_data_destroy (&rf->udata);
637 int plugin_unregister_write (const char *name)
639 return (plugin_unregister (list_write, name));
642 int plugin_unregister_flush (const char *name)
644 return (plugin_unregister (list_flush, name));
647 int plugin_unregister_shutdown (const char *name)
649 return (plugin_unregister (list_shutdown, name));
652 int plugin_unregister_data_set (const char *name)
656 if (data_sets == NULL)
659 if (c_avl_remove (data_sets, name, NULL, (void *) &ds) != 0)
666 } /* int plugin_unregister_data_set */
668 int plugin_unregister_log (const char *name)
670 return (plugin_unregister (list_log, name));
673 int plugin_unregister_notification (const char *name)
675 return (plugin_unregister (list_notification, name));
678 void plugin_init_all (void)
680 const char *chain_name;
681 int (*callback) (void);
685 /* Init the value cache */
688 chain_name = global_option_get ("PreCacheChain");
689 pre_cache_chain = fc_chain_get_by_name (chain_name);
691 chain_name = global_option_get ("PostCacheChain");
692 post_cache_chain = fc_chain_get_by_name (chain_name);
695 if ((list_init == NULL) && (list_read == NULL))
698 /* Calling all init callbacks before checking if read callbacks
699 * are available allows the init callbacks to register the read
701 le = llist_head (list_init);
704 callback = (int (*) (void)) le->value;
705 status = (*callback) ();
709 ERROR ("Initialization of plugin `%s' "
710 "failed with status %i. "
711 "Plugin will be unloaded.",
713 /* Plugins that register read callbacks from the init
714 * callback should take care of appropriate error
715 * handling themselves. */
716 /* FIXME: Unload _all_ functions */
717 plugin_unregister_read (le->key);
723 /* Start read-threads */
724 if (list_read != NULL)
728 rt = global_option_get ("ReadThreads");
731 start_threads ((num > 0) ? num : 5);
733 } /* void plugin_init_all */
735 void plugin_read_all (void)
742 if (list_read == NULL)
745 pthread_mutex_lock (&read_lock);
747 le = llist_head (list_read);
750 rf = (read_func_t *) le->value;
752 if (rf->needs_read != DONE)
758 if (rf->wait_left > 0)
759 rf->wait_left -= interval_g;
761 if (rf->wait_left <= 0)
763 rf->needs_read = TODO;
769 DEBUG ("plugin: plugin_read_all: Signalling `read_cond'");
770 pthread_cond_broadcast (&read_cond);
771 pthread_mutex_unlock (&read_lock);
772 } /* void plugin_read_all */
774 /* Read function called when the `-T' command line argument is given. */
775 int plugin_read_all_once (void)
780 int return_status = 0;
782 if (list_read == NULL)
784 NOTICE ("No read-functions are registered.");
788 for (le = llist_head (list_read);
792 rf = (read_func_t *) le->value;
794 if (rf->type == RF_SIMPLE)
796 status = rf->callback.cb_simple ();
800 assert (rf->type == RF_COMPLEX);
801 status = rf->callback.cb_complex (&rf->udata);
806 NOTICE ("read-function of plugin `%s' failed.",
812 return (return_status);
813 } /* int plugin_read_all_once */
815 int plugin_write (const char *plugin, /* {{{ */
816 const data_set_t *ds, const value_list_t *vl)
818 int (*callback) (const data_set_t *ds, const value_list_t *vl);
825 if (list_write == NULL)
830 ds = plugin_get_ds (vl->type);
833 ERROR ("plugin_write: Unable to lookup type `%s'.", vl->type);
843 le = llist_head (list_write);
846 callback = le->value;
847 status = (*callback) (ds, vl);
856 if ((success == 0) && (failure != 0))
861 else /* plugin != NULL */
863 le = llist_head (list_write);
866 if (strcasecmp (plugin, le->key) == 0)
875 callback = le->value;
876 status = (*callback) (ds, vl);
880 } /* }}} int plugin_write */
882 int plugin_flush (const char *plugin, int timeout, const char *identifier)
884 int (*callback) (int timeout, const char *identifier);
887 if (list_flush == NULL)
890 le = llist_head (list_flush);
894 && (strcmp (plugin, le->key) != 0))
900 callback = (int (*) (int, const char *)) le->value;
901 (*callback) (timeout, identifier);
906 } /* int plugin_flush */
908 void plugin_shutdown_all (void)
910 int (*callback) (void);
915 if (list_shutdown == NULL)
918 le = llist_head (list_shutdown);
921 callback = (int (*) (void)) le->value;
923 /* Advance the pointer before calling the callback allows
924 * shutdown functions to unregister themselves. If done the
925 * other way around the memory `le' points to will be freed
926 * after callback returns. */
931 } /* void plugin_shutdown_all */
933 int plugin_dispatch_values (value_list_t *vl)
936 static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
940 if ((vl == NULL) || (*vl->type == '\0')) {
941 ERROR ("plugin_dispatch_values: Invalid value list.");
945 if (list_write == NULL)
946 c_complain_once (LOG_WARNING, &no_write_complaint,
947 "plugin_dispatch_values: No write callback has been "
948 "registered. Please load at least one output plugin, "
949 "if you want the collected data to be stored.");
951 if (data_sets == NULL)
953 ERROR ("plugin_dispatch_values: No data sets registered. "
954 "Could the types database be read? Check "
955 "your `TypesDB' setting!");
959 if (c_avl_get (data_sets, vl->type, (void *) &ds) != 0)
961 INFO ("plugin_dispatch_values: Dataset not found: %s", vl->type);
966 vl->time = time (NULL);
968 DEBUG ("plugin_dispatch_values: time = %u; interval = %i; "
970 "plugin = %s; plugin_instance = %s; "
971 "type = %s; type_instance = %s;",
972 (unsigned int) vl->time, vl->interval,
974 vl->plugin, vl->plugin_instance,
975 vl->type, vl->type_instance);
978 assert (0 == strcmp (ds->type, vl->type));
980 if (0 != strcmp (ds->type, vl->type))
981 WARNING ("plugin_dispatch_values: (ds->type = %s) != (vl->type = %s)",
986 assert (ds->ds_num == vl->values_len);
988 if (ds->ds_num != vl->values_len)
990 ERROR ("plugin_dispatch_values: ds->type = %s: "
991 "(ds->ds_num = %i) != "
992 "(vl->values_len = %i)",
993 ds->type, ds->ds_num, vl->values_len);
998 escape_slashes (vl->host, sizeof (vl->host));
999 escape_slashes (vl->plugin, sizeof (vl->plugin));
1000 escape_slashes (vl->plugin_instance, sizeof (vl->plugin_instance));
1001 escape_slashes (vl->type, sizeof (vl->type));
1002 escape_slashes (vl->type_instance, sizeof (vl->type_instance));
1004 if (pre_cache_chain != NULL)
1006 status = fc_process_chain (ds, vl, pre_cache_chain);
1009 WARNING ("plugin_dispatch_values: Running the "
1010 "pre-cache chain failed with "
1014 else if (status == FC_TARGET_STOP)
1018 /* Update the value cache */
1021 if (post_cache_chain != NULL)
1023 status = fc_process_chain (ds, vl, post_cache_chain);
1026 WARNING ("plugin_dispatch_values: Running the "
1027 "post-cache chain failed with "
1033 fc_default_action (ds, vl);
1036 } /* int plugin_dispatch_values */
1038 int plugin_dispatch_notification (const notification_t *notif)
1040 int (*callback) (const notification_t *);
1042 /* Possible TODO: Add flap detection here */
1044 DEBUG ("plugin_dispatch_notification: severity = %i; message = %s; "
1045 "time = %u; host = %s;",
1046 notif->severity, notif->message,
1047 (unsigned int) notif->time, notif->host);
1049 /* Nobody cares for notifications */
1050 if (list_notification == NULL)
1053 le = llist_head (list_notification);
1056 callback = (int (*) (const notification_t *)) le->value;
1057 (*callback) (notif);
1063 } /* int plugin_dispatch_notification */
1065 void plugin_log (int level, const char *format, ...)
1070 void (*callback) (int, const char *);
1073 if (list_log == NULL)
1077 if (level >= LOG_DEBUG)
1081 va_start (ap, format);
1082 vsnprintf (msg, sizeof (msg), format, ap);
1083 msg[sizeof (msg) - 1] = '\0';
1086 le = llist_head (list_log);
1089 callback = (void (*) (int, const char *)) le->value;
1090 (*callback) (level, msg);
1094 } /* void plugin_log */
1096 const data_set_t *plugin_get_ds (const char *name)
1100 if (c_avl_get (data_sets, name, (void *) &ds) != 0)
1102 DEBUG ("No such dataset registered: %s", name);
1107 } /* data_set_t *plugin_get_ds */
1109 static int plugin_notification_meta_add (notification_t *n,
1111 enum notification_meta_type_e type,
1114 notification_meta_t *meta;
1115 notification_meta_t *tail;
1117 if ((n == NULL) || (name == NULL) || (value == NULL))
1119 ERROR ("plugin_notification_meta_add: A pointer is NULL!");
1123 meta = (notification_meta_t *) malloc (sizeof (notification_meta_t));
1126 ERROR ("plugin_notification_meta_add: malloc failed.");
1129 memset (meta, 0, sizeof (notification_meta_t));
1131 sstrncpy (meta->name, name, sizeof (meta->name));
1136 case NM_TYPE_STRING:
1138 meta->nm_value.nm_string = strdup ((const char *) value);
1139 if (meta->nm_value.nm_string == NULL)
1141 ERROR ("plugin_notification_meta_add: strdup failed.");
1147 case NM_TYPE_SIGNED_INT:
1149 meta->nm_value.nm_signed_int = *((int64_t *) value);
1152 case NM_TYPE_UNSIGNED_INT:
1154 meta->nm_value.nm_unsigned_int = *((uint64_t *) value);
1157 case NM_TYPE_DOUBLE:
1159 meta->nm_value.nm_double = *((double *) value);
1162 case NM_TYPE_BOOLEAN:
1164 meta->nm_value.nm_boolean = *((bool *) value);
1169 ERROR ("plugin_notification_meta_add: Unknown type: %i", type);
1173 } /* switch (type) */
1177 while ((tail != NULL) && (tail->next != NULL))
1186 } /* int plugin_notification_meta_add */
1188 int plugin_notification_meta_add_string (notification_t *n,
1192 return (plugin_notification_meta_add (n, name, NM_TYPE_STRING, value));
1195 int plugin_notification_meta_add_signed_int (notification_t *n,
1199 return (plugin_notification_meta_add (n, name, NM_TYPE_SIGNED_INT, &value));
1202 int plugin_notification_meta_add_unsigned_int (notification_t *n,
1206 return (plugin_notification_meta_add (n, name, NM_TYPE_UNSIGNED_INT, &value));
1209 int plugin_notification_meta_add_double (notification_t *n,
1213 return (plugin_notification_meta_add (n, name, NM_TYPE_DOUBLE, &value));
1216 int plugin_notification_meta_add_boolean (notification_t *n,
1220 return (plugin_notification_meta_add (n, name, NM_TYPE_BOOLEAN, &value));
1223 int plugin_notification_meta_copy (notification_t *dst,
1224 const notification_t *src)
1226 notification_meta_t *meta;
1228 assert (dst != NULL);
1229 assert (src != NULL);
1230 assert (dst != src);
1231 assert ((src->meta == NULL) || (src->meta != dst->meta));
1233 for (meta = src->meta; meta != NULL; meta = meta->next)
1235 if (meta->type == NM_TYPE_STRING)
1236 plugin_notification_meta_add_string (dst, meta->name,
1237 meta->nm_value.nm_string);
1238 else if (meta->type == NM_TYPE_SIGNED_INT)
1239 plugin_notification_meta_add_signed_int (dst, meta->name,
1240 meta->nm_value.nm_signed_int);
1241 else if (meta->type == NM_TYPE_UNSIGNED_INT)
1242 plugin_notification_meta_add_unsigned_int (dst, meta->name,
1243 meta->nm_value.nm_unsigned_int);
1244 else if (meta->type == NM_TYPE_DOUBLE)
1245 plugin_notification_meta_add_double (dst, meta->name,
1246 meta->nm_value.nm_double);
1247 else if (meta->type == NM_TYPE_BOOLEAN)
1248 plugin_notification_meta_add_boolean (dst, meta->name,
1249 meta->nm_value.nm_boolean);
1253 } /* int plugin_notification_meta_copy */
1255 int plugin_notification_meta_free (notification_meta_t *n)
1257 notification_meta_t *this;
1258 notification_meta_t *next;
1262 ERROR ("plugin_notification_meta_free: n == NULL!");
1267 while (this != NULL)
1271 if (this->type == NM_TYPE_STRING)
1273 free ((char *)this->nm_value.nm_string);
1274 this->nm_value.nm_string = NULL;
1282 } /* int plugin_notification_meta_free */