summaryrefslogtreecommitdiffstats
path: root/libnetdata/config
diff options
context:
space:
mode:
Diffstat (limited to 'libnetdata/config')
-rw-r--r--libnetdata/config/appconfig.c59
-rw-r--r--libnetdata/config/appconfig.h6
2 files changed, 40 insertions, 25 deletions
diff --git a/libnetdata/config/appconfig.c b/libnetdata/config/appconfig.c
index 0272877bf..1288366da 100644
--- a/libnetdata/config/appconfig.c
+++ b/libnetdata/config/appconfig.c
@@ -462,15 +462,15 @@ long long appconfig_get_number(struct config *root, const char *section, const c
return strtoll(s, NULL, 0);
}
-LONG_DOUBLE appconfig_get_float(struct config *root, const char *section, const char *name, LONG_DOUBLE value)
+NETDATA_DOUBLE appconfig_get_float(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value)
{
char buffer[100], *s;
- sprintf(buffer, "%0.5" LONG_DOUBLE_MODIFIER, value);
+ sprintf(buffer, "%0.5" NETDATA_DOUBLE_MODIFIER, value);
s = appconfig_get(root, section, name, buffer);
if(!s) return value;
- return str2ld(s, NULL);
+ return str2ndd(s, NULL);
}
static inline int appconfig_test_boolean_value(char *s) {
@@ -588,10 +588,10 @@ long long appconfig_set_number(struct config *root, const char *section, const c
return value;
}
-LONG_DOUBLE appconfig_set_float(struct config *root, const char *section, const char *name, LONG_DOUBLE value)
+NETDATA_DOUBLE appconfig_set_float(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value)
{
char buffer[100];
- sprintf(buffer, "%0.5" LONG_DOUBLE_MODIFIER, value);
+ sprintf(buffer, "%0.5" NETDATA_DOUBLE_MODIFIER, value);
appconfig_set(root, section, name, buffer);
@@ -805,6 +805,18 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
struct section *co;
struct config_option *cv;
+ {
+ int found_host_labels = 0;
+ for (co = root->first_section; co; co = co->next)
+ if(!strcmp(co->name, CONFIG_SECTION_HOST_LABEL))
+ found_host_labels = 1;
+
+ if(!found_host_labels) {
+ appconfig_section_create(root, CONFIG_SECTION_HOST_LABEL);
+ appconfig_get(root, CONFIG_SECTION_HOST_LABEL, "name", "value");
+ }
+ }
+
buffer_strcat(wb,
"# netdata configuration\n"
"#\n"
@@ -819,26 +831,27 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
"#\n"
"\n# global netdata configuration\n");
- for(i = 0; i <= 15 ;i++) {
+ for(i = 0; i <= 16 ;i++) {
appconfig_wrlock(root);
for(co = root->first_section; co ; co = co->next) {
if(!strcmp(co->name, CONFIG_SECTION_GLOBAL)) pri = 0;
- else if(!strcmp(co->name, CONFIG_SECTION_DIRECTORIES)) pri = 1;
- else if(!strcmp(co->name, CONFIG_SECTION_LOGS)) pri = 2;
- else if(!strcmp(co->name, CONFIG_SECTION_ENV_VARS)) pri = 3;
- else if(!strcmp(co->name, CONFIG_SECTION_HOST_LABEL)) pri = 4;
- else if(!strcmp(co->name, CONFIG_SECTION_SQLITE)) pri = 5;
- else if(!strcmp(co->name, CONFIG_SECTION_CLOUD)) pri = 6;
- else if(!strcmp(co->name, CONFIG_SECTION_ML)) pri = 7;
- else if(!strcmp(co->name, CONFIG_SECTION_HEALTH)) pri = 8;
- else if(!strcmp(co->name, CONFIG_SECTION_WEB)) pri = 9;
- // by default, new sections will get pri = 10 (set at the end, below)
- else if(!strcmp(co->name, CONFIG_SECTION_REGISTRY)) pri = 11;
- else if(!strcmp(co->name, CONFIG_SECTION_GLOBAL_STATISTICS)) pri = 12;
- else if(!strcmp(co->name, CONFIG_SECTION_PLUGINS)) pri = 13;
- else if(!strcmp(co->name, CONFIG_SECTION_STATSD)) pri = 14;
- else if(!strncmp(co->name, "plugin:", 7)) pri = 15; // << change the loop too if you change this
- else pri = 10; // this is used for any new (currently unknown) sections
+ else if(!strcmp(co->name, CONFIG_SECTION_DB)) pri = 1;
+ else if(!strcmp(co->name, CONFIG_SECTION_DIRECTORIES)) pri = 2;
+ else if(!strcmp(co->name, CONFIG_SECTION_LOGS)) pri = 3;
+ else if(!strcmp(co->name, CONFIG_SECTION_ENV_VARS)) pri = 4;
+ else if(!strcmp(co->name, CONFIG_SECTION_HOST_LABEL)) pri = 5;
+ else if(!strcmp(co->name, CONFIG_SECTION_SQLITE)) pri = 6;
+ else if(!strcmp(co->name, CONFIG_SECTION_CLOUD)) pri = 7;
+ else if(!strcmp(co->name, CONFIG_SECTION_ML)) pri = 8;
+ else if(!strcmp(co->name, CONFIG_SECTION_HEALTH)) pri = 9;
+ else if(!strcmp(co->name, CONFIG_SECTION_WEB)) pri = 10;
+ // by default, new sections will get pri = 11 (set at the end, below)
+ else if(!strcmp(co->name, CONFIG_SECTION_REGISTRY)) pri = 12;
+ else if(!strcmp(co->name, CONFIG_SECTION_GLOBAL_STATISTICS)) pri = 13;
+ else if(!strcmp(co->name, CONFIG_SECTION_PLUGINS)) pri = 14;
+ else if(!strcmp(co->name, CONFIG_SECTION_STATSD)) pri = 15;
+ else if(!strncmp(co->name, "plugin:", 7)) pri = 16; // << change the loop too if you change this
+ else pri = 11; // this is used for any new (currently unknown) sections
if(i == pri) {
int loaded = 0;
@@ -904,7 +917,7 @@ int config_parse_duration(const char* string, int* result) {
if(!(isdigit(*string) || *string == '+' || *string == '-')) goto fallback;
char *e = NULL;
- calculated_number n = str2ld(string, &e);
+ NETDATA_DOUBLE n = str2ndd(string, &e);
if(e && *e) {
switch (*e) {
case 'Y':
diff --git a/libnetdata/config/appconfig.h b/libnetdata/config/appconfig.h
index f1f61e31d..d72a3140e 100644
--- a/libnetdata/config/appconfig.h
+++ b/libnetdata/config/appconfig.h
@@ -100,6 +100,8 @@
#define CONFIG_SECTION_HOST_LABEL "host labels"
#define EXPORTING_CONF "exporting.conf"
#define CONFIG_SECTION_GLOBAL_STATISTICS "global statistics"
+#define CONFIG_SECTION_DB "db"
+
// these are used to limit the configuration names and values lengths
// they are not enforced by config.c functions (they will strdup() all strings, no matter of their length)
@@ -168,7 +170,7 @@ extern void config_section_unlock(struct section *co);
extern char *appconfig_get_by_section(struct section *co, const char *name, const char *default_value);
extern char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value);
extern long long appconfig_get_number(struct config *root, const char *section, const char *name, long long value);
-extern LONG_DOUBLE appconfig_get_float(struct config *root, const char *section, const char *name, LONG_DOUBLE value);
+extern NETDATA_DOUBLE appconfig_get_float(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value);
extern int appconfig_get_boolean_by_section(struct section *co, const char *name, int value);
extern int appconfig_get_boolean(struct config *root, const char *section, const char *name, int value);
extern int appconfig_get_boolean_ondemand(struct config *root, const char *section, const char *name, int value);
@@ -177,7 +179,7 @@ extern int appconfig_get_duration(struct config *root, const char *section, cons
extern const char *appconfig_set(struct config *root, const char *section, const char *name, const char *value);
extern const char *appconfig_set_default(struct config *root, const char *section, const char *name, const char *value);
extern long long appconfig_set_number(struct config *root, const char *section, const char *name, long long value);
-extern LONG_DOUBLE appconfig_set_float(struct config *root, const char *section, const char *name, LONG_DOUBLE value);
+extern NETDATA_DOUBLE appconfig_set_float(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value);
extern int appconfig_set_boolean(struct config *root, const char *section, const char *name, int value);
extern int appconfig_exists(struct config *root, const char *section, const char *name);