#include "rrd_tool.h"
#include "rrd_rpncalc.h"
#include "rrd_hw.h"
+#include "rrd_client.h"
#include "rrd_is_thread_safe.h"
static int opt_no_overwrite = 0;
static void rrd_free2(
rrd_t *rrd); /* our onwn copy, immmune to mmap */
+void rrd_create_set_no_overwrite(
+ int opt )
+{
+ opt_no_overwrite = (opt?1:0);
+}
+
int rrd_create(
int argc,
char **argv)
struct option long_options[] = {
{"start", required_argument, 0, 'b'},
{"step", required_argument, 0, 's'},
+ {"daemon", required_argument, 0, 'd'},
{"no-overwrite", no_argument, 0, 'O'},
{0, 0, 0, 0}
};
char *parsetime_error = NULL;
long long_tmp;
int rc;
+ char * opt_daemon = NULL;
optind = 0;
opterr = 0; /* initialize getopt */
while (1) {
- opt = getopt_long(argc, argv, "Ob:s:", long_options, &option_index);
+ opt = getopt_long(argc, argv, "Ob:s:d:", long_options, &option_index);
if (opt == EOF)
break;
switch (opt) {
+ case 'd':
+ if (opt_daemon != NULL)
+ free (opt_daemon);
+ opt_daemon = strdup (optarg);
+ if (opt_daemon == NULL)
+ {
+ rrd_set_error ("strdup failed.");
+ return (-1);
+ }
+ break;
+
case 'b':
if ((parsetime_error = rrd_parsetime(optarg, &last_up_tv))) {
rrd_set_error("start time: %s", parsetime_error);
rrd_set_error("need name of an rrd file to create");
return -1;
}
+
+ rrdc_connect (opt_daemon);
+ if (rrdc_is_connected (opt_daemon)) {
+ rc = rrdc_create (argv[optind],
+ pdp_step, last_up, opt_no_overwrite,
+ argc - optind - 1, (const char **) (argv + optind + 1));
+ } else {
rc = rrd_create_r(argv[optind],
pdp_step, last_up,
argc - optind - 1, (const char **) (argv + optind + 1));
+ }
return rc;
}
unsigned short token_idx, error_flag, period = 0;
unsigned long hashed_name;
+ /* clear any previous errors */
+ rrd_clear_error();
+
/* init rrd clean */
rrd_init(&rrd);
/* static header */
dummychar2, &offset)) {
case 0:
case 1:
- rrd_set_error("Invalid DS name");
+ rrd_set_error("Invalid DS name in [%s]",&argv[i][3]);
break;
case 2:
case 3:
- rrd_set_error("Invalid DS type");
+ rrd_set_error("Invalid DS type in [%s]",&argv[i][3]);
break;
case 4: /* (%n may or may not be counted) */
case 5: /* check for duplicate datasource names */