From: Florian Forster Date: Wed, 22 Sep 2010 13:56:26 +0000 (+0200) Subject: src/graph_config.[ch]: Implement the "CacheFile" config option. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bb036145679e3e2db213fd12d46afe4aae31707a;p=collection4.git src/graph_config.[ch]: Implement the "CacheFile" config option. --- diff --git a/share/collection.conf b/share/collection.conf index 06387d3..855d15f 100644 --- a/share/collection.conf +++ b/share/collection.conf @@ -1,3 +1,5 @@ +CacheFile "/tmp/collection4.json" + DataDir "/var/lib/collectd/rrd" diff --git a/src/graph_config.c b/src/graph_config.c index 6d2402b..5d275f0 100644 --- a/src/graph_config.c +++ b/src/graph_config.c @@ -40,7 +40,13 @@ # define CONFIGFILE "/etc/collection.conf" #endif -time_t last_read_mtime = 0; +#ifndef CACHEFILE +# define CACHEFILE "/tmp/collection4.json" +#endif + +static time_t last_read_mtime = 0; + +static char *cache_file = NULL; static int dispatch_config (const oconfig_item_t *ci) /* {{{ */ { @@ -55,6 +61,8 @@ static int dispatch_config (const oconfig_item_t *ci) /* {{{ */ graph_config_add (child); else if (strcasecmp ("DataProvider", child->key) == 0) data_provider_config (child); + else if (strcasecmp ("CacheFile", child->key) == 0) + graph_config_get_string (child, &cache_file); else { DEBUG ("Unknown config option: %s", child->key); @@ -142,4 +150,11 @@ int graph_config_get_bool (const oconfig_item_t *ci, /* {{{ */ return (0); } /* }}} int graph_config_get_bool */ +const char *graph_config_get_cache_file (void) /* {{{ */ +{ + if (cache_file == NULL) + return (CACHEFILE); + return (cache_file); +} /* }}} char graph_config_get_cache_file */ + /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/graph_config.h b/src/graph_config.h index 5ccfadf..877bebc 100644 --- a/src/graph_config.h +++ b/src/graph_config.h @@ -31,5 +31,7 @@ int graph_read_config (void); int graph_config_get_string (const oconfig_item_t *ci, char **ret_str); int graph_config_get_bool (const oconfig_item_t *ci, _Bool *ret_bool); +const char *graph_config_get_cache_file (void); + /* vim: set sw=2 sts=2 et fdm=marker : */ #endif /* GRAPH_CONFIG_H */