src/daemon/logging.c \
src/daemon/logging.h \
src/daemon/main.c \
- src/daemon/module.c \
- src/daemon/module.h \
- src/daemon/modules.c \
- src/daemon/modules.h \
- src/daemon/modules/conntrack.c \
- src/daemon/modules/conntrack.h \
- src/daemon/modules/contextswitches.c \
- src/daemon/modules/contextswitches.h \
- src/daemon/modules/loadavg.c \
- src/daemon/modules/loadavg.h \
src/daemon/queue.c \
src/daemon/queue.h \
+ src/daemon/source.c \
+ src/daemon/source.h \
+ src/daemon/sources.c \
+ src/daemon/sources.h \
+ src/daemon/sources/conntrack.c \
+ src/daemon/sources/conntrack.h \
+ src/daemon/sources/contextswitches.c \
+ src/daemon/sources/contextswitches.h \
+ src/daemon/sources/loadavg.c \
+ src/daemon/sources/loadavg.h \
src/daemon/util.c \
src/daemon/util.h
#include "daemon.h"
#include "graphs.h"
#include "graph-bus.h"
-#include "module.h"
-#include "modules.h"
#include "queue.h"
+#include "source.h"
+#include "sources.h"
struct collecty_daemon {
collecty_ctx* ctx;
// Queue
collecty_queue* queue;
- // Modules
- collecty_modules* modules;
+ // Sources
+ collecty_sources* sources;
// Graphs
collecty_graphs* graphs;
DEBUG(self->ctx, "Initializing daemon...\n");
- // Initialize all modules
- r = collecty_modules_create(&self->modules, self->ctx, self);
+ // Initialize all sources
+ r = collecty_sources_create(&self->sources, self->ctx, self);
if (r < 0)
return r;
self->graphs = NULL;
}
- // Free all modules
- if (self->modules) {
- collecty_modules_unref(self->modules);
- self->modules = NULL;
+ // Free all sources
+ if (self->sources) {
+ collecty_sources_unref(self->sources);
+ self->sources = NULL;
}
return 0;
sd_event_source_unref(self->events.init);
if (self->events.exit)
sd_event_source_unref(self->events.exit);
- if (self->modules)
- collecty_modules_unref(self->modules);
+ if (self->sources)
+ collecty_sources_unref(self->sources);
if (self->graphs)
collecty_graphs_unref(self->graphs);
if (self->queue)
return sd_event_ref(self->loop);
}
-collecty_modules* collecty_daemon_get_modules(collecty_daemon* self) {
- if (self->modules)
- return collecty_modules_ref(self->modules);
+collecty_sources* collecty_daemon_get_sources(collecty_daemon* self) {
+ if (self->sources)
+ return collecty_sources_ref(self->sources);
return NULL;
}
}
int collecty_daemon_submit(collecty_daemon* self,
- collecty_module* module, const char* object, const char* value) {
+ collecty_source* source, const char* object, const char* value) {
// Log action
DEBUG(self->ctx, "%s(%s) submitted: %s\n",
- collecty_module_name(module), (object) ? object : "", value);
+ collecty_source_name(source), (object) ? object : "", value);
- return collecty_queue_submit(self->queue, module, object, value);
+ return collecty_queue_submit(self->queue, source, object, value);
}
static int collecty_daemon_bus_version(sd_bus* bus, const char* path, const char* interface,
#include "bus.h"
#include "ctx.h"
#include "graphs.h"
-#include "module.h"
-#include "modules.h"
+#include "source.h"
+#include "sources.h"
int collecty_daemon_create(collecty_daemon** daemon, collecty_ctx* ctx);
collecty_daemon* collecty_daemon_unref(collecty_daemon* daemon);
sd_event* collecty_daemon_loop(collecty_daemon* self);
-collecty_modules* collecty_daemon_get_modules(collecty_daemon* self);
+collecty_sources* collecty_daemon_get_sources(collecty_daemon* self);
collecty_graphs* collecty_daemon_get_graphs(collecty_daemon* self);
int collecty_daemon_run(collecty_daemon* self);
int collecty_daemon_submit(collecty_daemon* self,
- collecty_module* module, const char* object, const char* value);
+ collecty_source* source, const char* object, const char* value);
// Bus
extern const collecty_bus_implementation daemon_bus_impl;
return path;
}
-int collecty_graph_require_module(collecty_graph* self,
+int collecty_graph_require_source(collecty_graph* self,
collecty_args* args, const char* name, const char* object) {
- collecty_modules* modules = NULL;
- collecty_module* module = NULL;
+ collecty_sources* sources = NULL;
+ collecty_source* source = NULL;
int r;
- // Fetch all modules
- modules = collecty_daemon_get_modules(self->daemon);
- if (!modules) {
+ // Fetch all sources
+ sources = collecty_daemon_get_sources(self->daemon);
+ if (!sources) {
r = -ENOTSUP;
goto ERROR;
}
- // Fetch the module by its name
- module = collecty_modules_get_by_name(modules, name);
- if (!module) {
- ERROR(self->ctx, "Could not find module '%s'\n", name);
+ // Fetch the source by its name
+ source = collecty_sources_get_by_name(sources, name);
+ if (!source) {
+ ERROR(self->ctx, "Could not find source '%s'\n", name);
r = -ENOENT;
goto ERROR;
}
- // Add the data of the module
- r = collecty_module_render(module, args, object);
+ // Add the data of the source
+ r = collecty_source_render(source, args, object);
if (r < 0)
goto ERROR;
ERROR:
- if (modules)
- collecty_modules_unref(modules);
- if (module)
- collecty_module_unref(module);
+ if (sources)
+ collecty_sources_unref(sources);
+ if (source)
+ collecty_source_unref(source);
return r;
}
const char* collecty_graph_get_name(collecty_graph* self);
char* collecty_graph_get_bus_path(collecty_graph* self);
-int collecty_graph_require_module(collecty_graph* self,
+int collecty_graph_require_source(collecty_graph* self,
collecty_args* args, const char* name, const char* object);
typedef struct collecty_graph_render_options {
collecty_graph* graph, collecty_args* args, const char* object) {
int r;
- // This requires the loadavg module
- r = collecty_graph_require_module(graph, args, "loadavg", object);
+ // This requires the loadavg source
+ r = collecty_graph_require_source(graph, args, "loadavg", object);
if (r < 0)
return r;
struct collecty_queue_object {
STAILQ_ENTRY(collecty_queue_object) nodes;
- // Module
- collecty_module* module;
+ // Source
+ collecty_source* source;
// Object
char* object;
free(o->samples);
}
- if (o->module)
- collecty_module_unref(o->module);
+ if (o->source)
+ collecty_source_unref(o->source);
if (o->object)
free(o->object);
free(o);
}
static struct collecty_queue_object* collecty_queue_find_object(
- collecty_queue* self, collecty_module* module, const char* object) {
+ collecty_queue* self, collecty_source* source, const char* object) {
struct collecty_queue_object* o = NULL;
STAILQ_FOREACH(o, &self->queue, nodes) {
- // The module must match
- if (o->module != module)
+ // The source must match
+ if (o->source != source)
continue;
// If both objects are NULL we have a match
return NULL;
}
-static int collecty_queue_object_append_sample(collecty_queue* self, collecty_module* module,
+static int collecty_queue_object_append_sample(collecty_queue* self, collecty_source* source,
const char* object, struct collecty_queue_object* o, const char* sample) {
struct timeval t = {};
char** samples = NULL;
Submits a new reading into the queue
*/
int collecty_queue_submit(collecty_queue* self,
- collecty_module* module, const char* object, const char* sample) {
+ collecty_source* source, const char* object, const char* sample) {
struct collecty_queue_object* o = NULL;
int r;
return -EINVAL;
// Check if we can append the sample
- o = collecty_queue_find_object(self, module, object);
+ o = collecty_queue_find_object(self, source, object);
if (o)
- return collecty_queue_object_append_sample(self, module, object, o, sample);
+ return collecty_queue_object_append_sample(self, source, object, o, sample);
// Allocate some memory
o = calloc(1, sizeof(*o));
if (!o)
return -errno;
- // Reference the module
- o->module = collecty_module_ref(module);
+ // Reference the source
+ o->source = collecty_source_ref(source);
// Store the object
if (o->object) {
}
// Store the sample
- r = collecty_queue_object_append_sample(self, module, object, o, sample);
+ r = collecty_queue_object_append_sample(self, source, object, o, sample);
if (r < 0)
goto ERROR;
if (!o)
break;
- // Call the module to write its data
- r = collecty_module_commit(o->module, o->object, o->num_samples, (const char**)o->samples);
+ // Call the source to write its data
+ r = collecty_source_commit(o->source, o->object, o->num_samples, (const char**)o->samples);
if (r < 0) {
ERROR(self->ctx, "Failed to write samples for %s(%s): %s\n",
- collecty_module_name(o->module), (o->object) ? o->object : NULL, strerror(-r));
+ collecty_source_name(o->source), (o->object) ? o->object : NULL, strerror(-r));
}
// Remove the object from the queue
#include "ctx.h"
#include "daemon.h"
-#include "module.h"
+#include "source.h"
int collecty_queue_create(collecty_queue** queue,
collecty_ctx* ctx, collecty_daemon* daemon);
collecty_queue* collecty_queue_unref(collecty_queue* self);
int collecty_queue_submit(collecty_queue* self,
- collecty_module* module, const char* object, const char* sample);
+ collecty_source* source, const char* object, const char* sample);
int collecty_queue_flush(collecty_queue* self);
#include "args.h"
#include "ctx.h"
#include "daemon.h"
-#include "module.h"
+#include "source.h"
#include "util.h"
#define STEPSIZE 60 // seconds
{ NULL },
};
-struct collecty_module {
+struct collecty_source {
collecty_ctx* ctx;
int nrefs;
collecty_daemon* daemon;
// Implementation
- const collecty_module_impl* impl;
+ const collecty_source_impl* impl;
// Event Loop
sd_event* loop;
} events;
};
-static int collecty_module_heartbeat(sd_event_source* source, uint64_t usec, void* data) {
- collecty_module* self = data;
+static int collecty_source_heartbeat(sd_event_source* source, uint64_t usec, void* data) {
+ collecty_source* self = data;
int r;
- DEBUG(self->ctx, "Heartbeat called for %s\n", collecty_module_name(self));
+ DEBUG(self->ctx, "Heartbeat called for %s\n", collecty_source_name(self));
// Call the collect method
r = self->impl->collect(self->ctx, self);
if (r < 0) {
ERROR(self->ctx, "collect() failed for %s: %s\n",
- collecty_module_name(self), strerror(-r));
+ collecty_source_name(self), strerror(-r));
}
// Arm the timer again
return 0;
}
-static int collecty_module_register_heartbeat(collecty_module* self) {
+static int collecty_source_register_heartbeat(collecty_source* self) {
int r;
// No need to do this if we don't have a collect method
// Call the heartbeat function immediately
r = sd_event_add_time_relative(self->loop, &self->events.heartbeat,
- CLOCK_MONOTONIC, 0, 0, collecty_module_heartbeat, self);
+ CLOCK_MONOTONIC, 0, 0, collecty_source_heartbeat, self);
if (r < 0) {
ERROR(self->ctx, "Failed to register the heartbeat timer: %s\n", strerror(-r));
return r;
return 0;
}
-static int collecty_module_init(collecty_module* self) {
+static int collecty_source_init(collecty_source* self) {
int r;
// Do nothing if there is no init function
if (!self->impl->init)
return 0;
- // Initialize the module
+ // Initialize the source
r = self->impl->init(self->ctx);
if (r < 0) {
ERROR(self->ctx, "Failed to initialize %s: %s\n",
- collecty_module_name(self), strerror(-r));
+ collecty_source_name(self), strerror(-r));
}
return r;
}
-static void collecty_module_free(collecty_module* self) {
+static void collecty_source_free(collecty_source* self) {
if (self->impl->free)
self->impl->free(self->ctx);
if (self->events.heartbeat)
free(self);
}
-int collecty_module_create(collecty_module** module,
- collecty_ctx* ctx, collecty_daemon* daemon, const collecty_module_impl* impl) {
- collecty_module* self = NULL;
+int collecty_source_create(collecty_source** source,
+ collecty_ctx* ctx, collecty_daemon* daemon, const collecty_source_impl* impl) {
+ collecty_source* self = NULL;
int r;
// Allocate some memory
self->impl = impl;
// Register heartbeat
- r = collecty_module_register_heartbeat(self);
+ r = collecty_source_register_heartbeat(self);
if (r < 0)
goto ERROR;
- // Initialize the module
- r = collecty_module_init(self);
+ // Initialize the source
+ r = collecty_source_init(self);
if (r < 0)
goto ERROR;
// Return the pointer
- *module = self;
+ *source = self;
return 0;
ERROR:
if (self)
- collecty_module_unref(self);
+ collecty_source_unref(self);
return r;
}
-collecty_module* collecty_module_ref(collecty_module* self) {
+collecty_source* collecty_source_ref(collecty_source* self) {
++self->nrefs;
return self;
}
-collecty_module* collecty_module_unref(collecty_module* self) {
+collecty_source* collecty_source_unref(collecty_source* self) {
if (--self->nrefs > 0)
return self;
- collecty_module_free(self);
+ collecty_source_free(self);
return NULL;
}
-const char* collecty_module_name(collecty_module* self) {
+const char* collecty_source_name(collecty_source* self) {
return self->impl->name;
}
-#define collecty_module_path(module, object, path) \
- __collecty_module_path(module, object, path, sizeof(path))
+#define collecty_source_path(source, object, path) \
+ __collecty_source_path(source, object, path, sizeof(path))
-static int __collecty_module_path(collecty_module* self,
+static int __collecty_source_path(collecty_source* self,
const char* object, char* path, size_t length) {
int r;
- // Fetch the module name
- const char* name = collecty_module_name(self);
+ // Fetch the source name
+ const char* name = collecty_source_name(self);
if (object)
r = snprintf(path, length, "%s/%s-%s.rrd", DATABASE_PATH, name, object);
}
/*
- Called when a module has some data to submit
+ Called when a source has some data to submit
*/
-int collecty_module_submit(collecty_module* self,
+int collecty_source_submit(collecty_source* self,
const char* object, const char* format, ...) {
char value[2048];
va_list args;
return collecty_daemon_submit(self->daemon, self, object, value);
}
-static int collecty_module_create_database(collecty_module* self, const char* path) {
+static int collecty_source_create_database(collecty_source* self, const char* path) {
collecty_args* args = NULL;
char min[24];
char max[24];
int r;
- DEBUG(self->ctx, "Creating database for %s at %s\n", collecty_module_name(self), path);
+ DEBUG(self->ctx, "Creating database for %s at %s\n", collecty_source_name(self), path);
// Allocate a new argument array
r = collecty_args_create(&args, self->ctx);
/*
Called to write all collected samples to disk
*/
-int collecty_module_commit(collecty_module* self,
+int collecty_source_commit(collecty_source* self,
const char* object, unsigned int num_samples, const char** samples) {
struct stat st = {};
char path[PATH_MAX];
int r;
// Make the path
- r = collecty_module_path(self, object, path);
+ r = collecty_source_path(self, object, path);
if (r < 0)
return r;
if (r < 0) {
switch (errno) {
case ENOENT:
- r = collecty_module_create_database(self, path);
+ r = collecty_source_create_database(self, path);
if (r < 0)
return r;
break;
return 0;
}
-static int collecty_module_render_add_DEF(collecty_module* self,
+static int collecty_source_render_add_DEF(collecty_source* self,
collecty_args* args, const char* path, const collecty_rrd_ds* ds, const char* object) {
char field[NAME_MAX];
int r;
- // Append the object to the field name so that we can load multiple RRD of the same module
+ // Append the object to the field name so that we can load multiple RRD of the same source
if (object) {
r = snprintf(field, sizeof(field), "%s_%s", ds->field, object);
if (r < 0)
return 0;
}
-int collecty_module_render(collecty_module* self, collecty_args* args, const char* object) {
+int collecty_source_render(collecty_source* self, collecty_args* args, const char* object) {
char path[PATH_MAX];
int r;
// Determine the path to the RRD file
- r = collecty_module_path(self, object, path);
+ r = collecty_source_path(self, object, path);
if (r < 0)
return r;
// Add all data sources
for (const collecty_rrd_ds* ds = self->impl->rrd_dss; ds->field; ds++) {
- r = collecty_module_render_add_DEF(self, args, path, ds, object);
+ r = collecty_source_render_add_DEF(self, args, path, ds, object);
if (r < 0)
return r;
}
# #
#############################################################################*/
-#ifndef COLLECTY_MODULE_H
-#define COLLECTY_MODULE_H
+#ifndef COLLECTY_SOURCE_H
+#define COLLECTY_SOURCE_H
-typedef struct collecty_module collecty_module;
+typedef struct collecty_source collecty_source;
#include "args.h"
#include "ctx.h"
const char* rows;
} collecty_rrd_rra;
-typedef struct collecty_module_impl {
+typedef struct collecty_source_impl {
const char* name;
// RRD Schema
int (*free)(collecty_ctx* ctx);
// Collect
- int (*collect)(collecty_ctx* ctx, collecty_module* module);
-} collecty_module_impl;
+ int (*collect)(collecty_ctx* ctx, collecty_source* source);
+} collecty_source_impl;
-int collecty_module_create(collecty_module** module,
- collecty_ctx* ctx, collecty_daemon* daemon, const collecty_module_impl* impl);
+int collecty_source_create(collecty_source** source,
+ collecty_ctx* ctx, collecty_daemon* daemon, const collecty_source_impl* impl);
-collecty_module* collecty_module_ref(collecty_module* self);
-collecty_module* collecty_module_unref(collecty_module* self);
+collecty_source* collecty_source_ref(collecty_source* self);
+collecty_source* collecty_source_unref(collecty_source* self);
-const char* collecty_module_name(collecty_module* self);
+const char* collecty_source_name(collecty_source* self);
-int collecty_module_submit(collecty_module* self, const char* object,
+int collecty_source_submit(collecty_source* self, const char* object,
const char* format, ...) __attribute__((format(printf, 3, 4)));
-int collecty_module_commit(collecty_module* self,
+int collecty_source_commit(collecty_source* self,
const char* object, unsigned int num_samples, const char** samples);
-int collecty_module_render(collecty_module* self,
+int collecty_source_render(collecty_source* self,
collecty_args* args, const char* object);
-#endif /* COLLECTY_MODULE_H */
+#endif /* COLLECTY_SOURCE_H */
#include "ctx.h"
#include "daemon.h"
-#include "module.h"
-#include "modules.h"
-
-// Load all modules
-#include "modules/conntrack.h"
-#include "modules/contextswitches.h"
-#include "modules/loadavg.h"
-
-// Register all modules
-static const collecty_module_impl* module_impls[] = {
- &conntrack_module,
- &contextswitches_module,
- &loadavg_module,
+#include "source.h"
+#include "sources.h"
+
+// Load all sources
+#include "sources/conntrack.h"
+#include "sources/contextswitches.h"
+#include "sources/loadavg.h"
+
+// Register all sources
+static const collecty_source_impl* source_impls[] = {
+ &conntrack_source,
+ &contextswitches_source,
+ &loadavg_source,
NULL,
};
-struct collecty_modules {
+struct collecty_sources {
collecty_ctx* ctx;
int nrefs;
// Daemon
collecty_daemon* daemon;
- // Modules
- collecty_module** modules;
- unsigned int num_modules;
+ // Sources
+ collecty_source** sources;
+ unsigned int num_sources;
};
-static int collecty_modules_init(collecty_modules* self) {
- collecty_module** modules = NULL;
- collecty_module* module = NULL;
+static int collecty_sources_init(collecty_sources* self) {
+ collecty_source** sources = NULL;
+ collecty_source* source = NULL;
int r;
- // Initialize all modules
- for (const collecty_module_impl** impl = module_impls; *impl; impl++) {
- r = collecty_module_create(&module, self->ctx, self->daemon, *impl);
+ // Initialize all sources
+ for (const collecty_source_impl** impl = source_impls; *impl; impl++) {
+ r = collecty_source_create(&source, self->ctx, self->daemon, *impl);
if (r < 0)
return r;
- // Make space to store the module
- modules = reallocarray(self->modules, self->num_modules + 1, sizeof(*self->modules));
- if (!modules) {
+ // Make space to store the source
+ sources = reallocarray(self->sources, self->num_sources + 1, sizeof(*self->sources));
+ if (!sources) {
r = -errno;
goto ERROR;
}
- // Store a reference to the module in the array
- modules[self->num_modules++] = collecty_module_ref(module);
+ // Store a reference to the source in the array
+ sources[self->num_sources++] = collecty_source_ref(source);
// Replace the array
- self->modules = modules;
+ self->sources = sources;
- // Unref the module
- collecty_module_unref(module);
- module = NULL;
+ // Unref the source
+ collecty_source_unref(source);
+ source = NULL;
}
return 0;
ERROR:
- if (module)
- collecty_module_unref(module);
+ if (source)
+ collecty_source_unref(source);
return r;
}
-static void collecty_modules_free(collecty_modules* self) {
- if (self->modules) {
- for (unsigned int i = 0; i < self->num_modules; i++)
- collecty_module_unref(self->modules[i]);
- free(self->modules);
+static void collecty_sources_free(collecty_sources* self) {
+ if (self->sources) {
+ for (unsigned int i = 0; i < self->num_sources; i++)
+ collecty_source_unref(self->sources[i]);
+ free(self->sources);
}
if (self->daemon)
collecty_daemon_unref(self->daemon);
free(self);
}
-int collecty_modules_create(collecty_modules** modules,
+int collecty_sources_create(collecty_sources** sources,
collecty_ctx* ctx, collecty_daemon* daemon) {
- collecty_modules* self = NULL;
+ collecty_sources* self = NULL;
int r;
// Allocate some memory
// Store a reference to the daemon
self->daemon = collecty_daemon_ref(daemon);
- // Setup all modules
- r = collecty_modules_init(self);
+ // Setup all sources
+ r = collecty_sources_init(self);
if (r < 0)
goto ERROR;
// Return the pointer
- *modules = self;
+ *sources = self;
return 0;
ERROR:
if (self)
- collecty_modules_unref(self);
+ collecty_sources_unref(self);
return r;
}
-collecty_modules* collecty_modules_ref(collecty_modules* self) {
+collecty_sources* collecty_sources_ref(collecty_sources* self) {
++self->nrefs;
return self;
}
-collecty_modules* collecty_modules_unref(collecty_modules* self) {
+collecty_sources* collecty_sources_unref(collecty_sources* self) {
if (--self->nrefs > 0)
return self;
- collecty_modules_free(self);
+ collecty_sources_free(self);
return NULL;
}
-collecty_module* collecty_modules_get_by_name(collecty_modules* self, const char* name) {
+collecty_source* collecty_sources_get_by_name(collecty_sources* self, const char* name) {
const char* n = NULL;
- // Iterate over all modules to find a match
- for (unsigned int i = 0; i < self->num_modules; i++) {
+ // Iterate over all sources to find a match
+ for (unsigned int i = 0; i < self->num_sources; i++) {
// Fetch the name
- n = collecty_module_name(self->modules[i]);
+ n = collecty_source_name(self->sources[i]);
if (!n)
continue;
// Return the object if the name matches
if (strcmp(name, n) == 0)
- return collecty_module_ref(self->modules[i]);
+ return collecty_source_ref(self->sources[i]);
}
return NULL;
# #
#############################################################################*/
-#ifndef COLLECTY_MODULES_H
-#define COLLECTY_MODULES_H
+#ifndef COLLECTY_SOURCES_H
+#define COLLECTY_SOURCES_H
-typedef struct collecty_modules collecty_modules;
+typedef struct collecty_sources collecty_sources;
#include "ctx.h"
#include "daemon.h"
+#include "source.h"
-int collecty_modules_create(collecty_modules** modules,
+int collecty_sources_create(collecty_sources** sources,
collecty_ctx* ctx, collecty_daemon* daemon);
-collecty_modules* collecty_modules_ref(collecty_modules* self);
-collecty_modules* collecty_modules_unref(collecty_modules* self);
+collecty_sources* collecty_sources_ref(collecty_sources* self);
+collecty_sources* collecty_sources_unref(collecty_sources* self);
-collecty_module* collecty_modules_get_by_name(collecty_modules* self, const char* name);
+collecty_source* collecty_sources_get_by_name(collecty_sources* self, const char* name);
-#endif /* COLLECTY_MODULES_H */
+#endif /* COLLECTY_SOURCES_H */
#include <string.h>
#include "../ctx.h"
-#include "../module.h"
+#include "../source.h"
#include "../util.h"
#include "conntrack.h"
-static int conntrack_collect(collecty_ctx* ctx, collecty_module* module) {
+static int conntrack_collect(collecty_ctx* ctx, collecty_source* source) {
uint64_t count = 0;
uint64_t max = 0;
int r;
}
// Submit the values
- return collecty_module_submit(module, NULL, "%" PRIu64 ":%" PRIu64, count, max);
+ return collecty_source_submit(source, NULL, "%" PRIu64 ":%" PRIu64, count, max);
}
-const collecty_module_impl conntrack_module = {
+const collecty_source_impl conntrack_source = {
.name = "conntrack",
// RRD Data Sources
# #
#############################################################################*/
-#ifndef COLLECTY_MODULE_CONNTRACK_H
-#define COLLECTY_MODULE_CONNTRACK_H
+#ifndef COLLECTY_SOURCE_CONNTRACK_H
+#define COLLECTY_SOURCE_CONNTRACK_H
-#include "../module.h"
+#include "../source.h"
-extern const collecty_module_impl conntrack_module;
+extern const collecty_source_impl conntrack_source;
-#endif /* COLLECTY_MODULE_CONNTRACK_H */
+#endif /* COLLECTY_SOURCE_CONNTRACK_H */
#include <unistd.h>
#include "../ctx.h"
-#include "../module.h"
+#include "../source.h"
#include "contextswitches.h"
static int perf_event_open(struct perf_event_attr* hw_event,
return 0;
}
-static int contextswitches_collect(collecty_ctx* ctx, collecty_module* module) {
+static int contextswitches_collect(collecty_ctx* ctx, collecty_source* source) {
long long total = 0;
uint64_t count = 0;
int fd = -EBADF;
}
// Submit the values
- return collecty_module_submit(module, NULL, "%lld", total);
+ return collecty_source_submit(source, NULL, "%lld", total);
}
-const collecty_module_impl contextswitches_module = {
+const collecty_source_impl contextswitches_source = {
.name = "contextswitches",
// RRD Data Sources
# #
#############################################################################*/
-#ifndef COLLECTY_MODULE_CONTEXTSWITCHES_H
-#define COLLECTY_MODULE_CONTEXTSWITCHES_H
+#ifndef COLLECTY_SOURCE_CONTEXTSWITCHES_H
+#define COLLECTY_SOURCE_CONTEXTSWITCHES_H
-#include "../module.h"
+#include "../source.h"
-extern const collecty_module_impl contextswitches_module;
+extern const collecty_source_impl contextswitches_source;
-#endif /* COLLECTY_MODULE_CONTEXTSWITCHES_H */
+#endif /* COLLECTY_SOURCE_CONTEXTSWITCHES_H */
#include <stdlib.h>
#include "../ctx.h"
-#include "../module.h"
+#include "../source.h"
#include "loadavg.h"
-static int loadavg_collect(collecty_ctx* ctx, collecty_module* module) {
+static int loadavg_collect(collecty_ctx* ctx, collecty_source* source) {
double loadavg[3];
int r;
return r;
// Submit the values
- return collecty_module_submit(module, NULL,
+ return collecty_source_submit(source, NULL,
"%f:%f:%f", loadavg[0], loadavg[1], loadavg[2]);
}
-const collecty_module_impl loadavg_module = {
+const collecty_source_impl loadavg_source = {
.name = "loadavg",
// RRD Data Sources
# #
#############################################################################*/
-#ifndef COLLECTY_MODULE_LOADAVG_H
-#define COLLECTY_MODULE_LOADAVG_H
+#ifndef COLLECTY_SOURCE_LOADAVG_H
+#define COLLECTY_SOURCE_LOADAVG_H
-#include "../module.h"
+#include "../source.h"
-extern const collecty_module_impl loadavg_module;
+extern const collecty_source_impl loadavg_source;
-#endif /* COLLECTY_MODULE_LOADAVG_H */
+#endif /* COLLECTY_SOURCE_LOADAVG_H */