From: Francisco Jose Alvarez Date: Mon, 29 Aug 2022 11:15:06 +0000 (+0200) Subject: Allow date setting in files generated by the CSV plugin X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb5627458dff208ca091ce69cda8fa1037ab9623;p=thirdparty%2Fcollectd.git Allow date setting in files generated by the CSV plugin --- diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 0e0aaa74d..89faefa85 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -432,6 +432,7 @@ # # DataDir "@localstatedir@/lib/@PACKAGE_NAME@/csv" # StoreRates false +# FileDate true # # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 38519e8d2..6fc29ef0b 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1875,6 +1875,11 @@ If set to B, convert counter values to rates. If set to B (the default) counter values are stored as is, i.Ee. as an increasing integer number. +=item B B + +If set to B (the default value), the generated files will include the date. +If set to B the date will not be included in the generated files. + =back =head2 cURL Statistics diff --git a/src/csv.c b/src/csv.c index 953473fce..992a3033f 100644 --- a/src/csv.c +++ b/src/csv.c @@ -30,12 +30,13 @@ /* * 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; }