#include <systemd/sd-event.h>
+#include "args.h"
#include "ctx.h"
#include "daemon.h"
#include "module.h"
+#include "util.h"
// Interval after which the heartbeat function is being called again
#define HEARTBEAT 60000000 // 60s
}
static int collecty_module_create_database(collecty_module* 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);
- // XXX TODO
+ // Allocate a new argument array
+ r = collecty_args_create(&args, self->ctx);
+ if (r < 0)
+ goto ERROR;
- return 0;
+ // Add all data sources
+ for (const collecty_rrd_ds* ds = self->methods->rrd_dss; ds->field; ds++) {
+ // Format the minimum value
+ r = collecty_format_number(min, ds->min);
+ if (r < 0)
+ goto ERROR;
+
+ // Format the maximum value
+ r = collecty_format_number(max, ds->max);
+ if (r < 0)
+ goto ERROR;
+
+ // Add the DS line
+ r = collecty_args_push(args, "DS:%s:%s:%d:%s:%s",
+ ds->field, ds->type, HEARTBEAT * 2, min, max);
+ if (r < 0)
+ goto ERROR;
+ }
+
+ // Dump all arguments
+ r = collecty_args_dump(args);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (args)
+ collecty_args_unref(args);
+
+ return r;
}
/*