/* RRD collector */
if (ctx->cfg->rrd_file && worker->index == 0) {
- ctx->rrd = rspamd_rrd_file_default (ctx->cfg->rrd_file, NULL);
+ GError *rrd_err = NULL;
+
+ ctx->rrd = rspamd_rrd_file_default (ctx->cfg->rrd_file, &rrd_err);
if (ctx->rrd) {
ctx->rrd_event = g_slice_alloc0 (sizeof (*ctx->rrd_event));
event_base_set (ctx->ev_base, ctx->rrd_event);
event_add (ctx->rrd_event, &rrd_update_time);
}
+ else if (rrd_err) {
+ msg_err ("cannot load rrd from %s: %e", ctx->cfg->rrd_file,
+ rrd_err);
+ g_error_free (rrd_err);
+ }
+ else {
+ msg_err ("cannot load rrd from %s: unknown error", ctx->cfg->rrd_file);
+ }
}
else {
ctx->rrd = NULL;
return FALSE;
}
/* Check magic */
- if (memcmp (head.cookie, RRD_COOKIE, sizeof (head.cookie)) != 0 ||
- memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0 ||
- head.float_cookie != RRD_FLOAT_COOKIE) {
+ if (memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0) {
g_set_error (err,
- rrd_error_quark (), EINVAL, "rrd head cookies error: %s",
- strerror (errno));
+ rrd_error_quark (), EINVAL, "rrd head error: bad cookie");
+ close (fd);
+ return FALSE;
+ }
+ if (memcmp (head.version, RRD_VERSION, sizeof (head.version)) != 0) {
+ g_set_error (err,
+ rrd_error_quark (), EINVAL, "rrd head error: invalid version");
+ close (fd);
+ return FALSE;
+ }
+ if (head.float_cookie != RRD_FLOAT_COOKIE) {
+ g_set_error (err,
+ rrd_error_quark (), EINVAL, "rrd head error: another architecture "
+ "(file cookie %g != our cookie %g)",
+ head.float_cookie, RRD_FLOAT_COOKIE);
close (fd);
return FALSE;
}
/* Check for other params */
if (head.ds_cnt <= 0 || head.rra_cnt <= 0) {
g_set_error (err,
- rrd_error_quark (), EINVAL, "rrd head cookies error: %s",
- strerror (errno));
+ rrd_error_quark (), EINVAL, "rrd head cookies error: bad rra or ds count");
close (fd);
return FALSE;
}