projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ntpd plugin: Fix two format strings.
[collectd.git]
/
src
/
rrdtool.c
diff --git
a/src/rrdtool.c
b/src/rrdtool.c
index
fbd8360
..
161037c
100644
(file)
--- a/
src/rrdtool.c
+++ b/
src/rrdtool.c
@@
-285,7
+285,7
@@
static int ds_get (char ***ret, const data_set_t *ds, const value_list_t *vl)
if (isnan (d->min))
{
if (isnan (d->min))
{
- s
trcpy (min, "U"
);
+ s
strncpy (min, "U", sizeof (min)
);
}
else
{
}
else
{
@@
-295,7
+295,7
@@
static int ds_get (char ***ret, const data_set_t *ds, const value_list_t *vl)
if (isnan (d->max))
{
if (isnan (d->max))
{
- s
trcpy (max, "U"
);
+ s
strncpy (max, "U", sizeof (max)
);
}
else
{
}
else
{
@@
-342,7
+342,7
@@
static int srrd_create (char *filename, unsigned long pdp_step, time_t last_up,
optind = 0; /* bug in librrd? */
rrd_clear_error ();
optind = 0; /* bug in librrd? */
rrd_clear_error ();
- status = rrd_create_r (filename, pdp_step, last_up, argc, argv);
+ status = rrd_create_r (filename, pdp_step, last_up, argc,
(void *)
argv);
if (status != 0)
{
if (status != 0)
{
@@
-360,7
+360,7
@@
static int srrd_update (char *filename, char *template, int argc, char **argv)
optind = 0; /* bug in librrd? */
rrd_clear_error ();
optind = 0; /* bug in librrd? */
rrd_clear_error ();
- status = rrd_update_r (filename, template, argc, argv);
+ status = rrd_update_r (filename, template, argc,
(void *)
argv);
if (status != 0)
{
if (status != 0)
{
@@
-654,6
+654,8
@@
static void *rrd_queue_thread (void *data)
/* Write the values to the RRD-file */
srrd_update (queue_entry->filename, NULL, values_num, values);
/* Write the values to the RRD-file */
srrd_update (queue_entry->filename, NULL, values_num, values);
+ DEBUG ("rrdtool plugin: queue thread: Wrote %i values to %s",
+ values_num, queue_entry->filename);
for (i = 0; i < values_num; i++)
{
for (i = 0; i < values_num; i++)
{
@@
-735,9
+737,9
@@
static void rrd_cache_flush (int timeout)
}
else /* ancient and no values -> waste of memory */
{
}
else /* ancient and no values -> waste of memory */
{
-
keys
= (char **) realloc ((void *) keys,
+
char **tmp
= (char **) realloc ((void *) keys,
(keys_num + 1) * sizeof (char *));
(keys_num + 1) * sizeof (char *));
- if (
keys
== NULL)
+ if (
tmp
== NULL)
{
char errbuf[1024];
ERROR ("rrdtool plugin: "
{
char errbuf[1024];
ERROR ("rrdtool plugin: "
@@
-745,8
+747,10
@@
static void rrd_cache_flush (int timeout)
sstrerror (errno, errbuf,
sizeof (errbuf)));
c_avl_iterator_destroy (iter);
sstrerror (errno, errbuf,
sizeof (errbuf)));
c_avl_iterator_destroy (iter);
+ sfree (keys);
return;
}
return;
}
+ keys = tmp;
keys[keys_num] = key;
keys_num++;
}
keys[keys_num] = key;
keys_num++;
}
@@
-769,7
+773,7
@@
static void rrd_cache_flush (int timeout)
keys[i] = NULL;
} /* for (i = 0..keys_num) */
keys[i] = NULL;
} /* for (i = 0..keys_num) */
- free (keys);
+
s
free (keys);
cache_flush_last = now;
} /* void rrd_cache_flush */
cache_flush_last = now;
} /* void rrd_cache_flush */
@@
-889,6
+893,19
@@
static int rrd_cache_insert (const char *filename,
return (0);
} /* int rrd_cache_insert */
return (0);
} /* int rrd_cache_insert */
+static int rrd_compare_numeric (const void *a_ptr, const void *b_ptr)
+{
+ int a = *((int *) a_ptr);
+ int b = *((int *) b_ptr);
+
+ if (a < b)
+ return (-1);
+ else if (a > b)
+ return (1);
+ else
+ return (0);
+} /* int rrd_compare_numeric */
+
static int rrd_write (const data_set_t *ds, const value_list_t *vl)
{
struct stat statbuf;
static int rrd_write (const data_set_t *ds, const value_list_t *vl)
{
struct stat statbuf;
@@
-1027,6
+1044,12
@@
static int rrd_config (const char *key, const char *value)
if (rra_timespans_custom[rra_timespans_custom_num] != 0)
rra_timespans_custom_num++;
} /* while (strtok_r) */
if (rra_timespans_custom[rra_timespans_custom_num] != 0)
rra_timespans_custom_num++;
} /* while (strtok_r) */
+
+ qsort (/* base = */ rra_timespans_custom,
+ /* nmemb = */ rra_timespans_custom_num,
+ /* size = */ sizeof (rra_timespans_custom[0]),
+ /* compar = */ rrd_compare_numeric);
+
free (value_copy);
}
else if (strcasecmp ("XFF", key) == 0)
free (value_copy);
}
else if (strcasecmp ("XFF", key) == 0)
@@
-1076,12
+1099,7
@@
static int rrd_init (void)
if (stepsize < 0)
stepsize = 0;
if (heartbeat <= 0)
if (stepsize < 0)
stepsize = 0;
if (heartbeat <= 0)
- {
- if (stepsize > 0)
- heartbeat = 2 * stepsize;
- else
- heartbeat = 0;
- }
+ heartbeat = 2 * stepsize;
if ((heartbeat > 0) && (heartbeat < interval_g))
WARNING ("rrdtool plugin: Your `heartbeat' is "
if ((heartbeat > 0) && (heartbeat < interval_g))
WARNING ("rrdtool plugin: Your `heartbeat' is "