From d4e70c2b352c616bbfe1da195d6cbbacedcb7292 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 31 Oct 2010 13:09:51 +0100 Subject: [PATCH] =?utf8?q?Various=20plugins:=20Some=20more=20fixes=20with?= =?utf8?q?=20the=20time=5Ft=20=E2=86=92=20cdtime=5Ft=20change.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/rrdcached.c | 4 +++- src/target_notification.c | 2 +- src/utils_rrdcreate.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/rrdcached.c b/src/rrdcached.c index 34e860ba..fb7eb79e 100644 --- a/src/rrdcached.c +++ b/src/rrdcached.c @@ -64,12 +64,14 @@ static int value_list_to_string (char *buffer, int buffer_len, int offset; int status; int i; + time_t t; assert (0 == strcmp (ds->type, vl->type)); memset (buffer, '\0', buffer_len); - status = ssnprintf (buffer, buffer_len, "%u", (unsigned int) vl->time); + t = CDTIME_T_TO_TIME_T (vl->time); + status = ssnprintf (buffer, buffer_len, "%lu", (unsigned long) t); if ((status < 1) || (status >= buffer_len)) return (-1); offset = status; diff --git a/src/target_notification.c b/src/target_notification.c index 96598afd..cb68048b 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -209,7 +209,7 @@ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ /* Initialize the structure. */ memset (&n, 0, sizeof (n)); n.severity = data->severity; - n.time = time (NULL); + n.time = cdtime (); sstrncpy (n.message, data->message, sizeof (n.message)); sstrncpy (n.host, vl->host, sizeof (n.host)); sstrncpy (n.plugin, vl->plugin, sizeof (n.plugin)); diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c index 4ecec59d..5f21a17b 100644 --- a/src/utils_rrdcreate.c +++ b/src/utils_rrdcreate.c @@ -323,7 +323,7 @@ static int srrd_create (const char *filename, /* {{{ */ last_up = time (NULL) - 10; ssnprintf (pdp_step_str, sizeof (pdp_step_str), "%lu", pdp_step); - ssnprintf (last_up_str, sizeof (last_up_str), "%u", (unsigned int) last_up); + ssnprintf (last_up_str, sizeof (last_up_str), "%lu", (unsigned long) last_up); new_argv[0] = "create"; new_argv[1] = (void *) filename; @@ -368,6 +368,7 @@ int cu_rrd_create_file (const char *filename, /* {{{ */ char **ds_def; int ds_num; int status = 0; + time_t last_up; if (check_create_dir (filename)) return (-1); @@ -398,10 +399,15 @@ int cu_rrd_create_file (const char *filename, /* {{{ */ memcpy (argv + ds_num, rra_def, rra_num * sizeof (char *)); argv[ds_num + rra_num] = NULL; + if (vl->time == 0) + last_up = time (NULL) - 10; + else + last_up = CDTIME_T_TO_TIME_T (vl->time) - 10; + assert (vl->time > 10); status = srrd_create (filename, (cfg->stepsize > 0) ? cfg->stepsize : vl->interval, - vl->time - 10, + last_up, argc, (const char **) argv); free (argv); -- 2.11.0