1 #ifndef NETDATA_CONFIG_H
2 #define NETDATA_CONFIG_H 1
4 #define CONFIG_FILENAME "netdata.conf"
6 #define CONFIG_SECTION_GLOBAL "global"
7 #define CONFIG_SECTION_WEB "web"
8 #define CONFIG_SECTION_PLUGINS "plugins"
9 #define CONFIG_SECTION_REGISTRY "registry"
10 #define CONFIG_SECTION_HEALTH "health"
11 #define CONFIG_SECTION_BACKEND "backend"
12 #define CONFIG_SECTION_STREAM "stream"
14 // these are used to limit the configuration names and values lengths
15 // they are not enforced by config.c functions (they will strdup() all strings, no matter of their length)
16 #define CONFIG_MAX_NAME 1024
17 #define CONFIG_MAX_VALUE 2048
20 struct section *sections;
21 pthread_mutex_t mutex;
29 #define CONFIG_BOOLEAN_NO 0
30 #define CONFIG_BOOLEAN_YES 1
31 #define CONFIG_BOOLEAN_AUTO 2
33 extern int appconfig_load(struct config *root, char *filename, int overwrite_used);
35 extern char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value);
36 extern long long appconfig_get_number(struct config *root, const char *section, const char *name, long long value);
37 extern int appconfig_get_boolean(struct config *root, const char *section, const char *name, int value);
38 extern int appconfig_get_boolean_ondemand(struct config *root, const char *section, const char *name, int value);
40 extern const char *appconfig_set(struct config *root, const char *section, const char *name, const char *value);
41 extern const char *appconfig_set_default(struct config *root, const char *section, const char *name, const char *value);
42 extern long long appconfig_set_number(struct config *root, const char *section, const char *name, long long value);
43 extern int appconfig_set_boolean(struct config *root, const char *section, const char *name, int value);
45 extern int appconfig_exists(struct config *root, const char *section, const char *name);
46 extern int appconfig_move(struct config *root, const char *section_old, const char *name_old, const char *section_new, const char *name_new);
48 extern void appconfig_generate(struct config *root, BUFFER *wb, int only_changed);
50 // ----------------------------------------------------------------------------
51 // shortcuts for the default netdata configuration
53 #define config_load(filename, overwrite_used) appconfig_load(&netdata_config, filename, overwrite_used)
54 #define config_get(section, name, default_value) appconfig_get(&netdata_config, section, name, default_value)
55 #define config_get_number(section, name, value) appconfig_get_number(&netdata_config, section, name, value)
56 #define config_get_boolean(section, name, value) appconfig_get_boolean(&netdata_config, section, name, value)
57 #define config_get_boolean_ondemand(section, name, value) appconfig_get_boolean_ondemand(&netdata_config, section, name, value)
59 #define config_set(section, name, default_value) appconfig_get(&netdata_config, section, name, default_value)
60 #define config_set_default(section, name, value) appconfig_set_default(&netdata_config, section, name, value)
61 #define config_set_number(section, name, value) appconfig_set_number(&netdata_config, section, name, value)
62 #define config_set_boolean(section, name, value) appconfig_set_boolean(&netdata_config, section, name, value)
64 #define config_exists(section, name) appconfig_exists(&netdata_config, section, name)
65 #define config_move(section_old, name_old, section_new, name_new) appconfig_move(&netdata_config, section_old, name_old, section_new, name_new)
67 #define config_generate(buffer, only_changed) appconfig_generate(&netdata_config, buffer, only_changed)
69 #endif /* NETDATA_CONFIG_H */