9 #include "graph_config.h"
11 #include "graph_list.h"
16 # define CONFIGFILE "/etc/collection.conf"
19 time_t last_read_mtime = 0;
21 static int dispatch_config (const oconfig_item_t *ci) /* {{{ */
25 for (i = 0; i < ci->children_num; i++)
27 oconfig_item_t *child;
29 child = ci->children + i;
30 if (strcasecmp ("Graph", child->key) == 0)
31 graph_config_add (child);
34 DEBUG ("Unknown config option: %s", child->key);
39 } /* }}} int dispatch_config */
41 static int internal_read_config (void) /* {{{ */
45 ci = oconfig_parse_file (CONFIGFILE);
56 } /* }}} int internal_read_config */
58 static time_t get_config_mtime (void) /* {{{ */
63 memset (&statbuf, 0, sizeof (statbuf));
64 status = stat (CONFIGFILE, &statbuf);
68 return (statbuf.st_mtime);
69 } /* }}} time_t get_config_mtime */
71 int graph_read_config (void) /* {{{ */
75 mtime = get_config_mtime ();
77 if (mtime <= last_read_mtime)
80 internal_read_config ();
82 last_read_mtime = mtime;
85 } /* }}} int graph_read_config */
87 int graph_config_get_string (const oconfig_item_t *ci, /* {{{ */
92 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
95 tmp = strdup (ci->values[0].value.string);
103 } /* }}} int graph_config_get_string */
105 int graph_config_get_bool (const oconfig_item_t *ci, /* {{{ */
108 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
111 if (ci->values[0].value.boolean)
117 } /* }}} int graph_config_get_bool */
119 /* vim: set sw=2 sts=2 et fdm=marker : */