summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 12a27ed)
raw | patch | inline | side by side (parent: 12a27ed)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 8 Mar 2010 17:10:02 +0000 (17:10 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 8 Mar 2010 17:10:02 +0000 (17:10 +0000) |
index a4d9651aee1fadd2a13a9a5a2090fe8813c4e67b..b321de6329bd8509d373196c92c0a28f07853dbc 100644 (file)
B<rrdtool> B<create> I<filename>
S<[B<--start>|B<-b> I<start time>]>
S<[B<--step>|B<-s> I<step>]>
+S<[B<--no-overwrite>]>
S<[B<DS:>I<ds-name>B<:>I<DST>B<:>I<dst arguments>]>
S<[B<RRA:>I<CF>B<:>I<cf arguments>]>
Specifies the base interval in seconds with which data will be fed
into the B<RRD>.
+=head2 B<--no-overwrite>
+
+Do not clobber an existing file of the same name.
+
=head2 B<DS:>I<ds-name>B<:>I<DST>B<:>I<dst arguments>
A single B<RRD> can accept input from several data sources (B<DS>),
index 9a971cc4777560024b65558f916188b296df579c..a1b4e5a4efc4bec8ee77dc1ad3b037c41076056a 100644 (file)
--- a/program/src/rrd_create.c
+++ b/program/src/rrd_create.c
#include "rrd_hw.h"
#include "rrd_is_thread_safe.h"
+static int opt_no_overwrite = 0;
#ifdef WIN32
# include <process.h>
struct option long_options[] = {
{"start", required_argument, 0, 'b'},
{"step", required_argument, 0, 's'},
+ {"no-overwrite", no_argument, 0, 'O'},
{0, 0, 0, 0}
};
int option_index = 0;
opterr = 0; /* initialize getopt */
while (1) {
- opt = getopt_long(argc, argv, "b:s:", long_options, &option_index);
+ opt = getopt_long(argc, argv, "Ob:s:", long_options, &option_index);
if (opt == EOF)
break;
pdp_step = long_tmp;
break;
+ case 'O':
+ opt_no_overwrite = 1;
+ break;
+
case '?':
if (optopt != 0)
rrd_set_error("unknown option '%c'", optopt);
rrd_t rrd_dn;
unsigned rrd_flags = RRD_READWRITE | RRD_CREAT;
+ if (opt_no_overwrite) {
+ rrd_flags |= RRD_EXCL ;
+ }
+
unkn_cnt = 0;
for (i = 0; i < rrd->stat_head->rra_cnt; i++)
unkn_cnt += rrd->stat_head->ds_cnt * rrd->rra_def[i].row_cnt;
diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c
index 7d6ddc9b90fec151fb37c266289b52b5cda20745..0939e7c2d50164a1d5175a92b9d7edb44459c1c4 100644 (file)
--- a/program/src/rrd_open.c
+++ b/program/src/rrd_open.c
if (rdwr & RRD_CREAT) {
flags |= (O_CREAT | O_TRUNC);
}
+ if (rdwr & RRD_EXCL) {
+ flags |= O_EXCL;
+ }
}
if (rdwr & RRD_READAHEAD) {
#ifdef MAP_POPULATE
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index 5a56a96d41281a6aa95d09bb71e62615194cb932..1b32396b2bcd2c56ef142d33c1c2bd68175d0f14 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
N_("* create - create a new RRD\n\n"
"\trrdtool create filename [--start|-b start time]\n"
"\t\t[--step|-s step]\n"
+ "\t\t[--no-overwrite|-O]\n"
"\t\t[DS:ds-name:DST:dst arguments]\n"
"\t\t[RRA:CF:cf arguments]\n");
diff --git a/program/src/rrd_tool.h b/program/src/rrd_tool.h
index ef327586bddc81cf4b3073198731e57895fbe7a8..86c4aa8ce22271053c3afcef5f0c297e8851c318 100644 (file)
--- a/program/src/rrd_tool.h
+++ b/program/src/rrd_tool.h
#define RRD_CREAT (1<<2)
#define RRD_READAHEAD (1<<3)
#define RRD_COPY (1<<4)
+#define RRD_EXCL (1<<5)
enum cf_en cf_conv(
const char *string);