X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Frrdtool.c;h=024b04e5e928a11daaeb6edb31d0a985a8c1af4d;hb=89783745dc59079eab34e0c52de6e5e972f50eb2;hp=79331bf73dce12a6660c29f032af29f283463b79;hpb=20a7434400053998709109592ef17aa8c87a35ab;p=collectd.git diff --git a/src/rrdtool.c b/src/rrdtool.c index 79331bf7..024b04e5 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -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); + DEBUG ("rrdtool plugin: queue thread: Wrote %i values to %s", + values_num, queue_entry->filename); for (i = 0; i < values_num; i++) { @@ -891,6 +893,19 @@ static int rrd_cache_insert (const char *filename, 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; @@ -1029,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) */ + + 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)