X-Git-Url: https://git.octo.it/?p=collection4.git;a=blobdiff_plain;f=src%2Fgraph_config.c;h=5d275f0d6b4c4f5a1d8eee79796581078f038471;hp=2a2b59d7432648f429c552f3493748c127a7a20e;hb=e3fb09073a64cc051c11c4a1bdcec493f937b764;hpb=7b4281ec1965ba5f02b1094532636d89304bcdfa diff --git a/src/graph_config.c b/src/graph_config.c index 2a2b59d..5d275f0 100644 --- a/src/graph_config.c +++ b/src/graph_config.c @@ -1,3 +1,26 @@ +/** + * collection4 - graph_config.c + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + #include #include #include @@ -7,15 +30,23 @@ #include #include "graph_config.h" +#include "graph.h" #include "graph_list.h" #include "oconfig.h" #include "common.h" +#include "data_provider.h" #ifndef CONFIGFILE # 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) /* {{{ */ { @@ -28,6 +59,10 @@ static int dispatch_config (const oconfig_item_t *ci) /* {{{ */ child = ci->children + i; if (strcasecmp ("Graph", child->key) == 0) 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); @@ -115,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 : */