/**
- * collectd - src/plugin.h
+ * collectd - src/daemon/plugin.h
* Copyright (C) 2005-2014 Florian octo Forster
*
* Permission is hereby granted, free of charge, to any person obtaining a
#define PLUGIN_H
#include "collectd.h"
+
#include "configfile.h"
#include "meta_data.h"
#include "utils_time.h"
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
+#include <pthread.h>
#define PLUGIN_FLAGS_GLOBAL 0x0001
-#define DATA_MAX_NAME_LEN 64
+#ifndef DATA_MAX_NAME_LEN
+# define DATA_MAX_NAME_LEN 128
+#endif
#define DS_TYPE_COUNTER 0
#define DS_TYPE_GAUGE 1
/*
* 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;
struct value_list_s
{
value_t *values;
- int values_len;
+ size_t values_len;
cdtime_t time;
cdtime_t interval;
char host[DATA_MAX_NAME_LEN];
};
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 }
+#define VALUE_LIST_INIT { .values = NULL, .meta = NULL }
struct data_source_s
{
struct data_set_s
{
char type[DATA_MAX_NAME_LEN];
- int ds_num;
+ size_t ds_num;
data_source_t *ds;
};
typedef struct data_set_s data_set_t;
struct plugin_ctx_s
{
cdtime_t interval;
+ cdtime_t flush_interval;
+ cdtime_t flush_timeout;
};
typedef struct plugin_ctx_s plugin_ctx_t;
typedef int (*plugin_shutdown_cb) (void);
typedef int (*plugin_notification_cb) (const notification_t *,
user_data_t *);
-
/*
* NAME
* plugin_set_dir
*/
int plugin_load (const char *name, uint32_t flags);
-void plugin_init_all (void);
+int plugin_init_all (void);
void plugin_read_all (void);
int plugin_read_all_once (void);
-void plugin_shutdown_all (void);
+int plugin_shutdown_all (void);
/*
* NAME
* "plugin_register_complex_read" returns an error (non-zero). */
int plugin_register_complex_read (const char *group, const char *name,
plugin_read_cb callback,
- const struct timespec *interval,
- user_data_t *user_data);
+ cdtime_t interval,
+ user_data_t const *user_data);
int plugin_register_write (const char *name,
- plugin_write_cb callback, user_data_t *user_data);
+ plugin_write_cb callback, user_data_t const *user_data);
int plugin_register_flush (const char *name,
- plugin_flush_cb callback, user_data_t *user_data);
+ plugin_flush_cb callback, user_data_t const *user_data);
int plugin_register_missing (const char *name,
- plugin_missing_cb callback, user_data_t *user_data);
+ plugin_missing_cb callback, user_data_t const *user_data);
int plugin_register_shutdown (const char *name,
plugin_shutdown_cb callback);
int plugin_register_data_set (const data_set_t *ds);
int plugin_register_log (const char *name,
- plugin_log_cb callback, user_data_t *user_data);
+ plugin_log_cb callback, user_data_t const *user_data);
int plugin_register_notification (const char *name,
- plugin_notification_cb callback, user_data_t *user_data);
+ plugin_notification_cb callback, user_data_t const *user_data);
int plugin_unregister_config (const char *name);
int plugin_unregister_complex_config (const char *name);
* Since some writers dynamically build their name it can be hard for
* the configuring person to know it. This function will fill this gap.
*/
-void plugin_log_available_writers ();
+void plugin_log_available_writers (void);
/*
* NAME
*/
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
+ */
+
+void module_register (void);
#endif /* PLUGIN_H */