9 #include "graph_config.h"
10 #include "graph_list.h"
15 # define CONFIGFILE "/etc/collection.conf"
18 time_t last_read_mtime = 0;
20 static int dispatch_config (const oconfig_item_t *ci) /* {{{ */
24 for (i = 0; i < ci->children_num; i++)
26 oconfig_item_t *child;
28 child = ci->children + i;
29 if (strcasecmp ("Graph", child->key) == 0)
30 graph_config_add (child);
33 DEBUG ("Unknown config option: %s", child->key);
38 } /* }}} int dispatch_config */
40 static int internal_read_config (void) /* {{{ */
44 ci = oconfig_parse_file (CONFIGFILE);
55 } /* }}} int internal_read_config */
57 static time_t get_config_mtime (void) /* {{{ */
62 memset (&statbuf, 0, sizeof (statbuf));
63 status = stat (CONFIGFILE, &statbuf);
67 return (statbuf.st_mtime);
68 } /* }}} time_t get_config_mtime */
70 int graph_read_config (void) /* {{{ */
74 mtime = get_config_mtime ();
76 if (mtime <= last_read_mtime)
79 internal_read_config ();
81 last_read_mtime = mtime;
84 } /* }}} int graph_read_config */
86 int graph_config_get_string (const oconfig_item_t *ci, /* {{{ */
91 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
94 tmp = strdup (ci->values[0].value.string);
102 } /* }}} int graph_config_get_string */
104 int graph_config_get_bool (const oconfig_item_t *ci, /* {{{ */
107 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
110 if (ci->values[0].value.boolean)
116 } /* }}} int graph_config_get_bool */
118 /* vim: set sw=2 sts=2 et fdm=marker : */