From: Peter A. Bigot Date: Mon, 19 May 2014 18:10:30 +0000 (-0500) Subject: rrdcached: support duration specifiers in command-line arguments X-Git-Tag: v1.5.0-rc1~83^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ce13947f6aa1364493654fe131c2f3a56acb647;p=thirdparty%2Frrdtool-1.x.git rrdcached: support duration specifiers in command-line arguments Signed-off-by: Peter A. Bigot --- diff --git a/doc/rrdcached.pod b/doc/rrdcached.pod index 21c3b8f5..04b075e8 100644 --- a/doc/rrdcached.pod +++ b/doc/rrdcached.pod @@ -143,7 +143,10 @@ Please also read L below. =item B<-w> I -Data is written to disk every I seconds. If this option is not +Data is written to disk every I seconds. +An L may be used +(e.g. C<5m> instead of C<300> seconds). +If this option is not specified the default interval of 300Eseconds will be used. =item B<-z> I @@ -151,14 +154,20 @@ specified the default interval of 300Eseconds will be used. If specified, rrdcached will delay writing of each RRD for a random number of seconds in the rangeE[0,I). This will avoid too many writes being queued simultaneously. This value should be no greater than -the value specified in B<-w>. By default, there is no delay. +the value specified in B<-w>. +An L may be used +(e.g. C<3m> instead of C<180> seconds). +By default, there is no delay. =item B<-f> I Every I seconds the entire cache is searched for old values which are written to disk. This only concerns files to which updates have stopped, so setting this to a high value, such as 3600Eseconds, is acceptable in most -cases. This timeout defaults to 3600Eseconds. +cases. +An L may be used +(e.g. C<1h> instead of C<3600> seconds). +This timeout defaults to 3600Eseconds. =item B<-p> I diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 8e46558c..2e8e0489 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3413,6 +3413,7 @@ static int read_options (int argc, char **argv) /* {{{ */ { int option; int status = 0; + const char *parsetime_error = NULL; socket_permission_clear (&default_socket); @@ -3548,47 +3549,40 @@ static int read_options (int argc, char **argv) /* {{{ */ case 'f': { - int temp; + unsigned long temp; - temp = atoi (optarg); - if (temp > 0) - config_flush_interval = temp; - else - { - fprintf (stderr, "Invalid flush interval: %s\n", optarg); + if ((parsetime_error = rrd_scaled_duration(optarg, 1, &temp))) { + fprintf(stderr, "Invalid flush interval %s: %s\n", optarg, parsetime_error); status = 3; + } else { + config_flush_interval = temp; } } break; case 'w': { - int temp; + unsigned long temp; - temp = atoi (optarg); - if (temp > 0) - config_write_interval = temp; - else - { - fprintf (stderr, "Invalid write interval: %s\n", optarg); + if ((parsetime_error = rrd_scaled_duration(optarg, 1, &temp))) { + fprintf(stderr, "Invalid write interval %s: %s\n", optarg, parsetime_error); status = 2; + } else { + config_write_interval = temp; } } break; case 'z': { - int temp; + unsigned long temp; - temp = atoi(optarg); - if (temp > 0) - config_write_jitter = temp; - else - { - fprintf (stderr, "Invalid write jitter: -z %s\n", optarg); + if ((parsetime_error = rrd_scaled_duration(optarg, 1, &temp))) { + fprintf(stderr, "Invalid write jitter %s: %s\n", optarg, parsetime_error); status = 2; + } else { + config_write_jitter = temp; } - break; }