X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fplugin.h;h=6b3a030cb21ea46f11fe7a8a0e34be68e2d7e5d9;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hp=8bdb4c2b0a339d9758d5394954b75a18d6167998;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f;p=collectd.git diff --git a/src/daemon/plugin.h b/src/daemon/plugin.h index 8bdb4c2b..6b3a030c 100644 --- a/src/daemon/plugin.h +++ b/src/daemon/plugin.h @@ -31,30 +31,25 @@ #include "collectd.h" #include "configfile.h" -#include "meta_data.h" +#include "utils/metadata/meta_data.h" #include "utils_time.h" +#include #include -#define PLUGIN_FLAGS_GLOBAL 0x0001 - -#ifndef DATA_MAX_NAME_LEN -#define DATA_MAX_NAME_LEN 128 -#endif - #define DS_TYPE_COUNTER 0 #define DS_TYPE_GAUGE 1 #define DS_TYPE_DERIVE 2 #define DS_TYPE_ABSOLUTE 3 #define DS_TYPE_TO_STRING(t) \ - (t == DS_TYPE_COUNTER) ? "counter" : (t == DS_TYPE_GAUGE) \ - ? "gauge" \ - : (t == DS_TYPE_DERIVE) \ - ? "derive" \ - : (t == DS_TYPE_ABSOLUTE) \ - ? "absolute" \ - : "unknown" + (t == DS_TYPE_COUNTER) \ + ? "counter" \ + : (t == DS_TYPE_GAUGE) \ + ? "gauge" \ + : (t == DS_TYPE_DERIVE) \ + ? "derive" \ + : (t == DS_TYPE_ABSOLUTE) ? "absolute" : "unknown" #ifndef LOG_ERR #define LOG_ERR 3 @@ -83,6 +78,15 @@ /* * Public data types */ +struct identifier_s { + char *host; + char *plugin; + char *plugin_instance; + char *type; + char *type_instance; +}; +typedef struct identifier_s identifier_t; + typedef unsigned long long counter_t; typedef double gauge_t; typedef int64_t derive_t; @@ -111,9 +115,7 @@ struct value_list_s { typedef struct value_list_s value_list_t; #define VALUE_LIST_INIT \ - { NULL, 0, 0, plugin_get_interval(), "localhost", "", "", "", "", NULL } -#define VALUE_LIST_STATIC \ - { NULL, 0, 0, 0, "localhost", "", "", "", "", NULL } + { .values = NULL, .meta = NULL } struct data_source_s { char name[DATA_MAX_NAME_LEN]; @@ -146,7 +148,7 @@ typedef struct notification_meta_s { int64_t nm_signed_int; uint64_t nm_unsigned_int; double nm_double; - _Bool nm_boolean; + bool nm_boolean; } nm_value; struct notification_meta_s *next; } notification_meta_t; @@ -170,6 +172,7 @@ struct user_data_s { typedef struct user_data_s user_data_t; struct plugin_ctx_s { + char *name; cdtime_t interval; cdtime_t flush_interval; cdtime_t flush_timeout; @@ -219,7 +222,7 @@ void plugin_set_dir(const char *dir); * * ARGUMENTS * `name' Name of the plugin to load. - * `flags' Hints on how to handle this plugin. + * `global' Make this plugins symbols available for other shared libraries. * * RETURN VALUE * Returns zero upon success, a value greater than zero if no plugin was found @@ -229,7 +232,7 @@ void plugin_set_dir(const char *dir); * Re-loading an already loaded module is detected and zero is returned in * this case. */ -int plugin_load(const char *name, uint32_t flags); +int plugin_load(const char *name, bool global); int plugin_init_all(void); void plugin_read_all(void); @@ -242,7 +245,7 @@ int plugin_shutdown_all(void); * * DESCRIPTION * Calls the write function of the given plugin with the provided data set and - * value list. It differs from `plugin_dispatch_value' in that it does not + * value list. It differs from `plugin_dispatch_values' in that it does not * update the cache, does not do threshold checking, call the chain subsystem * and so on. It looks up the requested plugin and invokes the function, end * of story. @@ -345,7 +348,7 @@ int plugin_dispatch_values(value_list_t const *vl); * plugin_dispatch_multivalue * * SYNOPSIS - * plugin_dispatch_multivalue (vl, 1, DS_TYPE_GAUGE, + * plugin_dispatch_multivalue (vl, true, DS_TYPE_GAUGE, * "free", 42.0, * "used", 58.0, * NULL); @@ -373,7 +376,7 @@ int plugin_dispatch_values(value_list_t const *vl); * The number of values it failed to dispatch (zero on success). */ __attribute__((sentinel)) int plugin_dispatch_multivalue(value_list_t const *vl, - _Bool store_percentage, + bool store_percentage, int store_type, ...); int plugin_dispatch_missing(const value_list_t *vl); @@ -397,6 +400,15 @@ int parse_notif_severity(const char *severity); #define DEBUG(...) /* noop */ #endif /* ! COLLECT_DEBUG */ +/* This will log messages, prefixed by plugin name */ +void daemon_log(int level, const char *format, ...) + __attribute__((format(printf, 2, 3))); + +#define P_ERROR(...) daemon_log(LOG_ERR, __VA_ARGS__) +#define P_WARNING(...) daemon_log(LOG_WARNING, __VA_ARGS__) +#define P_NOTICE(...) daemon_log(LOG_NOTICE, __VA_ARGS__) +#define P_INFO(...) daemon_log(LOG_INFO, __VA_ARGS__) + const data_set_t *plugin_get_ds(const char *name); int plugin_notification_meta_add_string(notification_t *n, const char *name, @@ -408,7 +420,7 @@ int plugin_notification_meta_add_unsigned_int(notification_t *n, int plugin_notification_meta_add_double(notification_t *n, const char *name, double value); int plugin_notification_meta_add_boolean(notification_t *n, const char *name, - _Bool value); + bool value); int plugin_notification_meta_copy(notification_t *dst, const notification_t *src); @@ -440,7 +452,8 @@ cdtime_t plugin_get_interval(void); */ int plugin_thread_create(pthread_t *thread, const pthread_attr_t *attr, - void *(*start_routine)(void *), void *arg); + void *(*start_routine)(void *), void *arg, + char const *name); /* * Plugins need to implement this