]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Allow date setting in files generated by the CSV plugin
authorFrancisco Jose Alvarez <francisco.alvarez@galgus.net>
Mon, 29 Aug 2022 11:15:06 +0000 (13:15 +0200)
committerMatthias Runge <mrunge@matthias-runge.de>
Mon, 12 Sep 2022 14:36:42 +0000 (16:36 +0200)
src/collectd.conf.in
src/collectd.conf.pod
src/csv.c

index 0e0aaa74db5801cfb26d08a025651887f68ce6d6..89faefa85414948ae95375fa0b9140578cea50b9 100644 (file)
 #<Plugin csv>
 #      DataDir "@localstatedir@/lib/@PACKAGE_NAME@/csv"
 #      StoreRates false
+#      FileDate true
 #</Plugin>
 
 #<Plugin curl>
index 38519e8d200bb5e70bbdf111ce2e023e201988bc..6fc29ef0bc0db0f501e93acd7e7d4bfb0bc5df0f 100644 (file)
@@ -1875,6 +1875,11 @@ If set to B<true>, convert counter values to rates. If set to B<false> (the
 default) counter values are stored as is, i.E<nbsp>e. as an increasing integer
 number.
 
+=item B<FileDate> B<true|false>
+
+If set to B<true> (the default value), the generated files will include the date.
+If set to B<false> the date will not be included in the generated files.
+
 =back
 
 =head2 cURL Statistics
index 953473fce56a2e6a43ad2d5fa882f212556d2a2c..992a3033f5b4232e05e84897f0d05837bc6a188b 100644 (file)
--- a/src/csv.c
+++ b/src/csv.c
 /*
  * Private variables
  */
-static const char *config_keys[] = {"DataDir", "StoreRates"};
+static const char *config_keys[] = {"DataDir", "StoreRates", "FileDate"};
 static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
 
 static char *datadir;
 static int store_rates;
 static int use_stdio;
+static int file_date = 1;
 
 static int value_list_to_string(char *buffer, int buffer_len,
                                 const data_set_t *ds, const value_list_t *vl) {
@@ -126,6 +127,9 @@ static int value_list_to_filename(char *buffer, size_t buffer_size,
   if (use_stdio)
     return 0;
 
+  if (!file_date)
+    return 0;
+
   ptr_size -= strlen(ptr);
   ptr += strlen(ptr);
 
@@ -205,6 +209,11 @@ static int csv_config(const char *key, const char *value) {
       store_rates = 1;
     else
       store_rates = 0;
+  } else if (strcasecmp("FileDate", key) == 0) {
+    if (IS_TRUE(value))
+      file_date = 1;
+    else
+      file_date = 0;
   } else {
     return -1;
   }