]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
rrdcached: support duration specifiers in command-line arguments
authorPeter A. Bigot <pab@pabigot.com>
Mon, 19 May 2014 18:10:30 +0000 (13:10 -0500)
committerPeter A. Bigot <pab@pabigot.com>
Tue, 20 May 2014 15:11:18 +0000 (10:11 -0500)
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
doc/rrdcached.pod
src/rrd_daemon.c

index 21c3b8f5734345541f1e9c83978515dcd5a12941..04b075e8df1a81a2ab0751012ac4451e5e313065 100644 (file)
@@ -143,7 +143,10 @@ Please also read L</"SECURITY CONSIDERATIONS"> below.
 
 =item B<-w> I<timeout>
 
-Data is written to disk every I<timeout> seconds. If this option is not
+Data is written to disk every I<timeout> seconds.
+An L<optional suffix|librrd/rrd_scaled_duration> may be used
+(e.g. C<5m> instead of C<300> seconds).
+If this option is not
 specified the default interval of 300E<nbsp>seconds will be used.
 
 =item B<-z> I<delay>
@@ -151,14 +154,20 @@ specified the default interval of 300E<nbsp>seconds will be used.
 If specified, rrdcached will delay writing of each RRD for a random number
 of seconds in the rangeE<nbsp>[0,I<delay>).  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<optional suffix|librrd/rrd_scaled_duration> may be used
+(e.g. C<3m> instead of C<180> seconds).
+By default, there is no delay.
 
 =item B<-f> I<timeout>
 
 Every I<timeout> 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 3600E<nbsp>seconds, is acceptable in most
-cases. This timeout defaults to 3600E<nbsp>seconds.
+cases.
+An L<optional suffix|librrd/rrd_scaled_duration> may be used
+(e.g. C<1h> instead of C<3600> seconds).
+This timeout defaults to 3600E<nbsp>seconds.
 
 =item B<-p> I<file>
 
index 8e46558c42c51218617c40f3f6e83101727b140b..2e8e0489b070bcbea20b074e5d01ca09c72b44e1 100644 (file)
@@ -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;
       }