From: Peter Stamfest Date: Wed, 13 Aug 2014 18:26:55 +0000 (+0200) Subject: add new rrdc_create_r2 function to support new sources syntax X-Git-Tag: v1.5.0-rc1~42^2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=237fba5694afc7d03dfb706d6687422e27aaf53a;p=thirdparty%2Frrdtool-1.x.git add new rrdc_create_r2 function to support new sources syntax --- diff --git a/src/rrd_client.c b/src/rrd_client.c index dc59d389..9c1ae3d3 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -1202,6 +1202,17 @@ int rrdc_create (const char *filename, /* {{{ */ int no_overwrite, int argc, const char **argv) +{ + return rrdc_create_r2(filename, pdp_step, last_up, no_overwrite, NULL, argc, argv); +} + +int rrdc_create_r2(const char *filename, /* {{{ */ + unsigned long pdp_step, + time_t last_up, + int no_overwrite, + const char **sources, + int argc, + const char **argv) { char buffer[RRD_CMD_MAX]; char *buffer_ptr; @@ -1243,6 +1254,14 @@ int rrdc_create (const char *filename, /* {{{ */ if(no_overwrite) { status = buffer_add_string ("-O", &buffer_ptr, &buffer_free); } + + if (sources != NULL) { + for (const char **p = sources ; *p ; p++) { + buffer_add_string ("-r", &buffer_ptr, &buffer_free); + buffer_add_string (*p, &buffer_ptr, &buffer_free); + } + } + if (status != 0) { mutex_unlock (&lock); diff --git a/src/rrd_client.h b/src/rrd_client.h index 873f5b90..4984bc59 100644 --- a/src/rrd_client.h +++ b/src/rrd_client.h @@ -60,6 +60,13 @@ int rrdc_create (const char *filename, int argc, const char **argv); +int rrdc_create_r2 (const char *filename, + unsigned long pdp_step, + time_t last_up, + int no_overwrite, + const char **sources, + int argc, + const char **argv); int rrdc_flush (const char *filename); int rrdc_forget (const char *filename); diff --git a/src/rrd_create.c b/src/rrd_create.c index 7170326c..a4a3f3ff 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -180,8 +180,9 @@ int rrd_create( } rrdc_connect (opt_daemon); if (rrdc_is_connected (opt_daemon)) { - rc = rrdc_create (argv[optind], - pdp_step, last_up, opt_no_overwrite, + rc = rrdc_create_r2(argv[optind], + pdp_step, last_up, opt_no_overwrite, + sources_array, argc - optind - 1, (const char **) (argv + optind + 1)); } else { rc = rrd_create_r2(argv[optind],