Rename appconfig to inicfg and drop config_* function-like macros. (#19552)
vkalintiris committed
Feb 2, 2025 at 13:17 UTC
9eaccc08cdf7dd7516233a4a3206441015d2ec23
131 files changed
+1627
-1699
CMakeLists.txt
+23
-22
@@ -717,12 +717,30 @@ set(LIBJUDY_SOURCES
717
${LIBJUDY_NEXT_FILES}
718
)
719
720
+set(INICFG_FILES
721
+ src/libnetdata/inicfg/inicfg.c
722
+ src/libnetdata/inicfg/inicfg.h
723
+ src/libnetdata/inicfg/inicfg_internals.h
724
+ src/libnetdata/inicfg/inicfg_exporters.c
725
+ src/libnetdata/inicfg/inicfg_conf_file.c
726
+ src/libnetdata/inicfg/inicfg_cleanup.c
727
+ src/libnetdata/inicfg/inicfg_sections.c
728
+ src/libnetdata/inicfg/inicfg_options.c
729
+ src/libnetdata/inicfg/inicfg_migrate.c
730
+ src/libnetdata/inicfg/inicfg_traversal.c
731
+ src/libnetdata/inicfg/inicfg_api.c
732
+ src/libnetdata/inicfg/dyncfg.c
733
+ src/libnetdata/inicfg/dyncfg.h
734
+)
735
+
736
+set(CONFIG_FILES
737
+ src/libnetdata/config/config.h
738
+)
739
+
740
set(LIBNETDATA_FILES
741
${CONFIG_H}
742
src/libnetdata/adaptive_resortable_list/adaptive_resortable_list.c
743
src/libnetdata/adaptive_resortable_list/adaptive_resortable_list.h
724
- src/libnetdata/config/appconfig.c
725
- src/libnetdata/config/appconfig.h
744
src/libnetdata/aral/aral.c
745
src/libnetdata/aral/aral.h
746
src/libnetdata/avl/avl.c
@@ -810,8 +828,6 @@ set(LIBNETDATA_FILES
828
src/libnetdata/http/http_defs.h
829
src/libnetdata/http/content_type.c
830
src/libnetdata/http/content_type.h
813
- src/libnetdata/config/dyncfg.c
814
- src/libnetdata/config/dyncfg.h
831
src/libnetdata/json/json-c-parser-inline.h
832
src/libnetdata/template-enum.h
833
src/libnetdata/dictionary/dictionary-internals.h
@@ -896,24 +912,6 @@ set(LIBNETDATA_FILES
912
src/libnetdata/parsers/size.h
913
src/libnetdata/libjudy/judy-malloc.c
914
src/libnetdata/libjudy/judy-malloc.h
899
- src/libnetdata/config/appconfig_internals.h
900
- src/libnetdata/config/appconfig_exporters.c
901
- src/libnetdata/config/appconfig_conf_file.c
902
- src/libnetdata/config/appconfig_cleanup.c
903
- src/libnetdata/config/appconfig_sections.c
904
- src/libnetdata/config/appconfig_options.c
905
- src/libnetdata/config/appconfig_migrate.c
906
- src/libnetdata/config/appconfig_traversal.c
907
- src/libnetdata/config/appconfig_api_sizes.c
908
- src/libnetdata/config/appconfig_api_sizes.h
909
- src/libnetdata/config/appconfig_api_durations.c
910
- src/libnetdata/config/appconfig_api_durations.h
911
- src/libnetdata/config/appconfig_api_numbers.c
912
- src/libnetdata/config/appconfig_api_numbers.h
913
- src/libnetdata/config/appconfig_api_text.c
914
- src/libnetdata/config/appconfig_api_text.h
915
- src/libnetdata/config/appconfig_api_boolean.c
916
- src/libnetdata/config/appconfig_api_boolean.h
915
src/libnetdata/facets/logs_query_status.h
916
src/libnetdata/os/timestamps.c
917
src/libnetdata/os/timestamps.h
@@ -998,6 +996,9 @@ set(LIBNETDATA_FILES
996
src/libnetdata/os/hostname.h
997
)
998
999
+list(APPEND LIBNETDATA_FILES ${INICFG_FILES})
1000
+list(APPEND LIBNETDATA_FILES ${CONFIG_FILES})
1001
+
1002
set(LIBH2O_FILES
1003
src/web/server/h2o/libh2o/deps/cloexec/cloexec.c
1004
src/web/server/h2o/libh2o/deps/libgkc/gkc.c
src/aclk/aclk.c
+1
-1
@@ -851,7 +851,7 @@ void *aclk_main(void *ptr)
851
size_t default_ssl_log_filename_size = strlen(netdata_configured_log_dir) + strlen(DEFAULT_SSKEYLOGFILE_NAME) + 2;
852
char *default_ssl_log_filename = mallocz(default_ssl_log_filename_size);
853
snprintfz(default_ssl_log_filename, default_ssl_log_filename_size, "%s/%s", netdata_configured_log_dir, DEFAULT_SSKEYLOGFILE_NAME);
854
- ssl_log_filename = config_get(CONFIG_SECTION_CLOUD, "aclk ssl keylog file", default_ssl_log_filename);
854
+ ssl_log_filename = inicfg_get(&netdata_config, CONFIG_SECTION_CLOUD, "aclk ssl keylog file", default_ssl_log_filename);
855
freez(default_ssl_log_filename);
856
if (ssl_log_filename) {
857
error_report("SSLKEYLOGFILE active (path:\"%s\")!", ssl_log_filename);
src/aclk/aclk_query.c
+1
-1
@@ -19,7 +19,7 @@ static struct pending_req_list *pending_req_list_head = NULL;
19
static SPINLOCK pending_req_list_lock = SPINLOCK_INITIALIZER;
20
21
void aclk_config_get_query_scope(void) {
22
- const char *s = config_get(CONFIG_SECTION_CLOUD, "scope", "full");
22
+ const char *s = inicfg_get(&netdata_config, CONFIG_SECTION_CLOUD, "scope", "full");
23
if(strcmp(s, "license manager") == 0)
24
default_aclk_http_acl = HTTP_ACL_ACLK_LICENSE_MANAGER;
25
}
src/claim/claim-with-api.c
+7
-7
@@ -385,7 +385,7 @@ bool claim_agent(const char *url, const char *token, const char *rooms, const ch
385
bool claim_agent_from_environment(void) {
386
const char *url = getenv("NETDATA_CLAIM_URL");
387
if(!url || !*url) {
388
- url = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
388
+ url = inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
389
if(!url || !*url) return false;
390
}
391
@@ -418,15 +418,15 @@ bool claim_agent_from_claim_conf(void) {
418
419
errno_clear();
420
char *filename = filename_from_path_entry_strdupz(netdata_configured_user_config_dir, "claim.conf");
421
- bool loaded = appconfig_load(&claim_config, filename, 1, NULL);
421
+ bool loaded = inicfg_load(&claim_config, filename, 1, NULL);
422
freez(filename);
423
424
if(loaded) {
425
- const char *url = appconfig_get(&claim_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
426
- const char *token = appconfig_get(&claim_config, CONFIG_SECTION_GLOBAL, "token", "");
427
- const char *rooms = appconfig_get(&claim_config, CONFIG_SECTION_GLOBAL, "rooms", "");
428
- const char *proxy = appconfig_get(&claim_config, CONFIG_SECTION_GLOBAL, "proxy", "env");
429
- bool insecure = appconfig_get_boolean(&claim_config, CONFIG_SECTION_GLOBAL, "insecure", CONFIG_BOOLEAN_NO);
425
+ const char *url = inicfg_get(&claim_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
426
+ const char *token = inicfg_get(&claim_config, CONFIG_SECTION_GLOBAL, "token", "");
427
+ const char *rooms = inicfg_get(&claim_config, CONFIG_SECTION_GLOBAL, "rooms", "");
428
+ const char *proxy = inicfg_get(&claim_config, CONFIG_SECTION_GLOBAL, "proxy", "env");
429
+ bool insecure = inicfg_get_boolean(&claim_config, CONFIG_SECTION_GLOBAL, "insecure", CONFIG_BOOLEAN_NO);
430
431
if(token && *token && url && *url)
432
ret = claim_agent(url, token, rooms, proxy, insecure);
src/claim/claim.c
+2
-2
@@ -82,8 +82,8 @@ static ND_UUID claimed_id_load_from_file(void) {
82
}
83
84
static ND_UUID claimed_id_get_from_cloud_conf(void) {
85
- if(appconfig_exists(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id")) {
86
- const char *claimed_id = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id", "");
85
+ if(inicfg_exists(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id")) {
86
+ const char *claimed_id = inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id", "");
87
if(claimed_id && *claimed_id)
88
return claimed_id_parse(claimed_id, "cloud.conf");
89
}
src/claim/cloud-conf.c
+32
-32
@@ -5,7 +5,7 @@
5
struct config cloud_config = APPCONFIG_INITIALIZER;
6
7
const char *cloud_config_url_get(void) {
8
- return appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
8
+ return inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
9
}
10
11
void cloud_config_url_set(const char *url) {
@@ -13,25 +13,25 @@ void cloud_config_url_set(const char *url) {
13
14
const char *existing = cloud_config_url_get();
15
if(strcmp(existing, url) != 0)
16
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "url", url);
16
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "url", url);
17
}
18
19
const char *cloud_config_proxy_get(void) {
20
// load cloud.conf or internal default
21
- const char *proxy = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", "env");
21
+ const char *proxy = inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", "env");
22
23
// backwards compatibility, from when proxy was in netdata.conf
24
// netdata.conf has bigger priority
25
- if (config_exists(CONFIG_SECTION_CLOUD, "proxy")) {
25
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_CLOUD, "proxy")) {
26
// get it from netdata.conf
27
- proxy = config_get(CONFIG_SECTION_CLOUD, "proxy", proxy);
27
+ proxy = inicfg_get(&netdata_config, CONFIG_SECTION_CLOUD, "proxy", proxy);
28
29
// update cloud.conf
30
- proxy = appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", proxy);
30
+ proxy = inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", proxy);
31
}
32
else {
33
// set in netdata.conf the proxy of cloud.conf
34
- config_set(CONFIG_SECTION_CLOUD, "proxy", proxy);
34
+ inicfg_set(&netdata_config, CONFIG_SECTION_CLOUD, "proxy", proxy);
35
}
36
37
return proxy;
@@ -39,24 +39,24 @@ const char *cloud_config_proxy_get(void) {
39
40
bool cloud_config_insecure_get(void) {
41
// load it from cloud.conf or use internal default
42
- return appconfig_get_boolean(&cloud_config, CONFIG_SECTION_GLOBAL, "insecure", CONFIG_BOOLEAN_NO);
42
+ return inicfg_get_boolean(&cloud_config, CONFIG_SECTION_GLOBAL, "insecure", CONFIG_BOOLEAN_NO);
43
}
44
45
static void cloud_conf_load_defaults(void) {
46
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
47
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", "env");
48
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "token", "");
49
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "rooms", "");
50
- appconfig_get_boolean(&cloud_config, CONFIG_SECTION_GLOBAL, "insecure", CONFIG_BOOLEAN_NO);
51
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", "");
52
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id", "");
53
- appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", "");
46
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "url", DEFAULT_CLOUD_BASE_URL);
47
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", "env");
48
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "token", "");
49
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "rooms", "");
50
+ inicfg_get_boolean(&cloud_config, CONFIG_SECTION_GLOBAL, "insecure", CONFIG_BOOLEAN_NO);
51
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", "");
52
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id", "");
53
+ inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", "");
54
}
55
56
void cloud_conf_load(int silent) {
57
errno_clear();
58
char *filename = filename_from_path_entry_strdupz(netdata_configured_cloud_dir, "cloud.conf");
59
- int ret = appconfig_load(&cloud_config, filename, 1, NULL);
59
+ int ret = inicfg_load(&cloud_config, filename, 1, NULL);
60
61
if(!ret && !silent)
62
nd_log(NDLS_DAEMON, NDLP_ERR,
@@ -64,7 +64,7 @@ void cloud_conf_load(int silent) {
64
65
freez(filename);
66
67
- appconfig_move(&cloud_config,
67
+ inicfg_move(&cloud_config,
68
CONFIG_SECTION_GLOBAL, "cloud base url",
69
CONFIG_SECTION_GLOBAL, "url");
70
@@ -72,22 +72,22 @@ void cloud_conf_load(int silent) {
72
}
73
74
void cloud_conf_init_after_registry(void) {
75
- const char *machine_guid = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", "");
76
- const char *hostname = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", "");
75
+ const char *machine_guid = inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", "");
76
+ const char *hostname = inicfg_get(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", "");
77
78
- // for machine guid and hostname we have to use appconfig_set() for that they will be saved uncommented
78
+ // for machine guid and hostname we have to use inicfg_set() for that they will be saved uncommented
79
if(!machine_guid || !*machine_guid)
80
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", registry_get_this_machine_guid());
80
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", registry_get_this_machine_guid());
81
82
if(!hostname || !*hostname)
83
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", registry_get_this_machine_hostname());
83
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", registry_get_this_machine_hostname());
84
}
85
86
bool cloud_conf_save(void) {
87
char filename[FILENAME_MAX + 1];
88
89
CLEAN_BUFFER *wb = buffer_create(0, NULL);
90
- appconfig_generate(&cloud_config, wb, false, false);
90
+ inicfg_generate(&cloud_config, wb, false, false);
91
snprintfz(filename, sizeof(filename), "%s/cloud.conf", netdata_configured_cloud_dir);
92
FILE *fp = fopen(filename, "w");
93
if(!fp) {
@@ -104,14 +104,14 @@ bool cloud_conf_regenerate(const char *claimed_id_str, const char *machine_guid,
104
// for backwards compatibility (older agents), save the claimed_id to its file
105
claimed_id_save_to_file(claimed_id_str);
106
107
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "url", url);
108
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", proxy ? proxy : "");
109
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "token", token ? token : "");
110
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "rooms", rooms ? rooms : "");
111
- appconfig_set_boolean(&cloud_config, CONFIG_SECTION_GLOBAL, "insecure", insecure);
112
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", machine_guid ? machine_guid : "");
113
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id", claimed_id_str ? claimed_id_str : "");
114
- appconfig_set(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", hostname ? hostname : "");
107
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "url", url);
108
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "proxy", proxy ? proxy : "");
109
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "token", token ? token : "");
110
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "rooms", rooms ? rooms : "");
111
+ inicfg_set_boolean(&cloud_config, CONFIG_SECTION_GLOBAL, "insecure", insecure);
112
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "machine_guid", machine_guid ? machine_guid : "");
113
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "claimed_id", claimed_id_str ? claimed_id_str : "");
114
+ inicfg_set(&cloud_config, CONFIG_SECTION_GLOBAL, "hostname", hostname ? hostname : "");
115
116
return cloud_conf_save();
117
}
src/collectors/cgroups.plugin/sys_fs_cgroup.c
+14
-14
@@ -229,19 +229,19 @@ void read_cgroup_plugin_configuration() {
229
throttled_time_hash = simple_hash("throttled_time");
230
throttled_usec_hash = simple_hash("throttled_usec");
231
232
- cgroup_update_every = (int)config_get_duration_seconds("plugin:cgroups", "update every", localhost->rrd_update_every);
232
+ cgroup_update_every = (int)inicfg_get_duration_seconds(&netdata_config, "plugin:cgroups", "update every", localhost->rrd_update_every);
233
if(cgroup_update_every < localhost->rrd_update_every) {
234
cgroup_update_every = localhost->rrd_update_every;
235
- config_set_duration_seconds("plugin:cgroups", "update every", localhost->rrd_update_every);
235
+ inicfg_set_duration_seconds(&netdata_config, "plugin:cgroups", "update every", localhost->rrd_update_every);
236
}
237
238
- cgroup_check_for_new_every = (int)config_get_duration_seconds("plugin:cgroups", "check for new cgroups every", cgroup_check_for_new_every);
238
+ cgroup_check_for_new_every = (int)inicfg_get_duration_seconds(&netdata_config, "plugin:cgroups", "check for new cgroups every", cgroup_check_for_new_every);
239
if(cgroup_check_for_new_every < cgroup_update_every) {
240
cgroup_check_for_new_every = cgroup_update_every;
241
- config_set_duration_seconds("plugin:cgroups", "check for new cgroups every", cgroup_check_for_new_every);
241
+ inicfg_set_duration_seconds(&netdata_config, "plugin:cgroups", "check for new cgroups every", cgroup_check_for_new_every);
242
}
243
244
- cgroup_use_unified_cgroups = config_get_boolean_ondemand("plugin:cgroups", "use unified cgroups", CONFIG_BOOLEAN_AUTO);
244
+ cgroup_use_unified_cgroups = inicfg_get_boolean_ondemand(&netdata_config, "plugin:cgroups", "use unified cgroups", CONFIG_BOOLEAN_AUTO);
245
if (cgroup_use_unified_cgroups == CONFIG_BOOLEAN_AUTO)
246
cgroup_use_unified_cgroups = (cgroups_try_detect_version() == CGROUPS_V2);
247
collector_info("use unified cgroups %s", cgroup_use_unified_cgroups ? "true" : "false");
@@ -323,11 +323,11 @@ void read_cgroup_plugin_configuration() {
323
cgroup_unified_base = strdupz(filename);
324
}
325
326
- cgroup_root_max = (int)config_get_number("plugin:cgroups", "max cgroups to allow", cgroup_root_max);
327
- cgroup_max_depth = (int)config_get_number("plugin:cgroups", "max cgroups depth to monitor", cgroup_max_depth);
326
+ cgroup_root_max = (int)inicfg_get_number(&netdata_config, "plugin:cgroups", "max cgroups to allow", cgroup_root_max);
327
+ cgroup_max_depth = (int)inicfg_get_number(&netdata_config, "plugin:cgroups", "max cgroups depth to monitor", cgroup_max_depth);
328
329
enabled_cgroup_paths = simple_pattern_create(
330
- config_get("plugin:cgroups", "enable by default cgroups matching",
330
+ inicfg_get(&netdata_config, "plugin:cgroups", "enable by default cgroups matching",
331
// ----------------------------------------------------------------
332
333
" !*/init.scope " // ignore init.scope
@@ -378,12 +378,12 @@ void read_cgroup_plugin_configuration() {
378
), NULL, SIMPLE_PATTERN_EXACT, true);
379
380
enabled_cgroup_names = simple_pattern_create(
381
- config_get("plugin:cgroups", "enable by default cgroups names matching",
381
+ inicfg_get(&netdata_config, "plugin:cgroups", "enable by default cgroups names matching",
382
" * "
383
), NULL, SIMPLE_PATTERN_EXACT, true);
384
385
search_cgroup_paths = simple_pattern_create(
386
- config_get("plugin:cgroups", "search for cgroups in subpaths matching",
386
+ inicfg_get(&netdata_config, "plugin:cgroups", "search for cgroups in subpaths matching",
387
" !*/init.scope " // ignore init.scope
388
" !*-qemu " // #345
389
" !*.libvirt-qemu " // #3010
@@ -399,13 +399,13 @@ void read_cgroup_plugin_configuration() {
399
), NULL, SIMPLE_PATTERN_EXACT, true);
400
401
snprintfz(filename, FILENAME_MAX, "%s/cgroup-name.sh", netdata_configured_primary_plugins_dir);
402
- cgroups_rename_script = config_get("plugin:cgroups", "script to get cgroup names", filename);
402
+ cgroups_rename_script = inicfg_get(&netdata_config, "plugin:cgroups", "script to get cgroup names", filename);
403
404
snprintfz(filename, FILENAME_MAX, "%s/cgroup-network", netdata_configured_primary_plugins_dir);
405
- cgroups_network_interface_script = config_get("plugin:cgroups", "script to get cgroup network interfaces", filename);
405
+ cgroups_network_interface_script = inicfg_get(&netdata_config, "plugin:cgroups", "script to get cgroup network interfaces", filename);
406
407
enabled_cgroup_renames = simple_pattern_create(
408
- config_get("plugin:cgroups", "run script to rename cgroups matching",
408
+ inicfg_get(&netdata_config, "plugin:cgroups", "run script to rename cgroups matching",
409
" !/ "
410
" !*.mount "
411
" !*.socket "
@@ -432,7 +432,7 @@ void read_cgroup_plugin_configuration() {
432
), NULL, SIMPLE_PATTERN_EXACT, true);
433
434
systemd_services_cgroups = simple_pattern_create(
435
- config_get(
435
+ inicfg_get(&netdata_config,
436
"plugin:cgroups",
437
"cgroups to match as systemd services",
438
" !/system.slice/*/*.service "
src/collectors/diskspace.plugin/plugin_diskspace.c
+14
-14
@@ -309,25 +309,25 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
309
if(unlikely(!dict_mountpoints)) {
310
SIMPLE_PREFIX_MODE mode = SIMPLE_PATTERN_EXACT;
311
312
- if(config_move("plugin:proc:/proc/diskstats", "exclude space metrics on paths", CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths") != -1) {
312
+ if(inicfg_move(&netdata_config, "plugin:proc:/proc/diskstats", "exclude space metrics on paths", CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths") != -1) {
313
// old configuration, enable backwards compatibility
314
mode = SIMPLE_PATTERN_PREFIX;
315
}
316
317
excluded_mountpoints = simple_pattern_create(
318
- config_get(CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths", DEFAULT_EXCLUDED_PATHS),
318
+ inicfg_get(&netdata_config, CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths", DEFAULT_EXCLUDED_PATHS),
319
NULL,
320
mode,
321
true);
322
323
excluded_filesystems = simple_pattern_create(
324
- config_get(CONFIG_SECTION_DISKSPACE, "exclude space metrics on filesystems", DEFAULT_EXCLUDED_FILESYSTEMS),
324
+ inicfg_get(&netdata_config, CONFIG_SECTION_DISKSPACE, "exclude space metrics on filesystems", DEFAULT_EXCLUDED_FILESYSTEMS),
325
NULL,
326
SIMPLE_PATTERN_EXACT,
327
true);
328
329
excluded_filesystems_inodes = simple_pattern_create(
330
- config_get(CONFIG_SECTION_DISKSPACE, "exclude inode metrics on filesystems", DEFAULT_EXCLUDED_FILESYSTEMS_INODES),
330
+ inicfg_get(&netdata_config, CONFIG_SECTION_DISKSPACE, "exclude inode metrics on filesystems", DEFAULT_EXCLUDED_FILESYSTEMS_INODES),
331
NULL,
332
SIMPLE_PATTERN_EXACT,
333
true);
@@ -340,8 +340,8 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
340
if(unlikely(!item)) {
341
bool slow = false;
342
343
- int def_space = config_get_boolean_ondemand(CONFIG_SECTION_DISKSPACE, "space usage for all disks", CONFIG_BOOLEAN_AUTO);
344
- int def_inodes = config_get_boolean_ondemand(CONFIG_SECTION_DISKSPACE, "inodes usage for all disks", CONFIG_BOOLEAN_AUTO);
343
+ int def_space = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_DISKSPACE, "space usage for all disks", CONFIG_BOOLEAN_AUTO);
344
+ int def_inodes = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_DISKSPACE, "inodes usage for all disks", CONFIG_BOOLEAN_AUTO);
345
346
if(unlikely(simple_pattern_matches(excluded_mountpoints, mi->mount_point))) {
347
def_space = CONFIG_BOOLEAN_NO;
@@ -395,10 +395,10 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
395
do_space = def_space;
396
do_inodes = def_inodes;
397
398
- if (config_exists(var_name, "space usage"))
399
- do_space = config_get_boolean_ondemand(var_name, "space usage", def_space);
400
- if (config_exists(var_name, "inodes usage"))
401
- do_inodes = config_get_boolean_ondemand(var_name, "inodes usage", def_inodes);
398
+ if (inicfg_exists(&netdata_config, var_name, "space usage"))
399
+ do_space = inicfg_get_boolean_ondemand(&netdata_config, var_name, "space usage", def_space);
400
+ if (inicfg_exists(&netdata_config, var_name, "inodes usage"))
401
+ do_inodes = inicfg_get_boolean_ondemand(&netdata_config, var_name, "inodes usage", def_inodes);
402
403
struct mount_point_metadata mp = {
404
.do_space = do_space,
@@ -852,15 +852,15 @@ void *diskspace_main(void *ptr) {
852
"top", HTTP_ACCESS_ANONYMOUS_DATA,
853
diskspace_function_mount_points);
854
855
- cleanup_mount_points = config_get_boolean(CONFIG_SECTION_DISKSPACE, "remove charts of unmounted disks" , cleanup_mount_points);
855
+ cleanup_mount_points = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_DISKSPACE, "remove charts of unmounted disks" , cleanup_mount_points);
856
857
- int update_every = (int)config_get_duration_seconds(CONFIG_SECTION_DISKSPACE, "update every", localhost->rrd_update_every);
857
+ int update_every = (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DISKSPACE, "update every", localhost->rrd_update_every);
858
if(update_every < localhost->rrd_update_every) {
859
update_every = localhost->rrd_update_every;
860
- config_set_duration_seconds(CONFIG_SECTION_DISKSPACE, "update every", update_every);
860
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_DISKSPACE, "update every", update_every);
861
}
862
863
- check_for_new_mountpoints_every = (int)config_get_duration_seconds(CONFIG_SECTION_DISKSPACE, "check for new mount points every", check_for_new_mountpoints_every);
863
+ check_for_new_mountpoints_every = (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DISKSPACE, "check for new mount points every", check_for_new_mountpoints_every);
864
if(check_for_new_mountpoints_every < update_every)
865
check_for_new_mountpoints_every = update_every;
866
src/collectors/ebpf.plugin/ebpf.c
+83
-64
@@ -2757,23 +2757,30 @@ static void ebpf_link_hostnames(const char *parse)
2757
*/
2758
void parse_network_viewer_section(struct config *cfg)
2759
{
2760
- network_viewer_opt.hostname_resolution_enabled =
2761
- appconfig_get_boolean(cfg, EBPF_NETWORK_VIEWER_SECTION, EBPF_CONFIG_RESOLVE_HOSTNAME, CONFIG_BOOLEAN_NO);
2760
+ network_viewer_opt.hostname_resolution_enabled = inicfg_get_boolean(cfg,
2761
+ EBPF_NETWORK_VIEWER_SECTION,
2762
+ EBPF_CONFIG_RESOLVE_HOSTNAME,
2763
+ CONFIG_BOOLEAN_NO);
2764
2763
- network_viewer_opt.service_resolution_enabled =
2764
- appconfig_get_boolean(cfg, EBPF_NETWORK_VIEWER_SECTION, EBPF_CONFIG_RESOLVE_SERVICE, CONFIG_BOOLEAN_YES);
2765
+ network_viewer_opt.service_resolution_enabled = inicfg_get_boolean(cfg,
2766
+ EBPF_NETWORK_VIEWER_SECTION,
2767
+ EBPF_CONFIG_RESOLVE_SERVICE,
2768
+ CONFIG_BOOLEAN_YES);
2769
2766
- const char *value = appconfig_get(cfg, EBPF_NETWORK_VIEWER_SECTION, EBPF_CONFIG_PORTS, NULL);
2770
+ const char *value = inicfg_get(cfg, EBPF_NETWORK_VIEWER_SECTION, EBPF_CONFIG_PORTS, NULL);
2771
ebpf_parse_ports(value);
2772
2773
if (network_viewer_opt.hostname_resolution_enabled) {
2770
- value = appconfig_get(cfg, EBPF_NETWORK_VIEWER_SECTION, EBPF_CONFIG_HOSTNAMES, NULL);
2774
+ value = inicfg_get(cfg, EBPF_NETWORK_VIEWER_SECTION, EBPF_CONFIG_HOSTNAMES, NULL);
2775
ebpf_link_hostnames(value);
2776
} else {
2777
netdata_log_info("Name resolution is disabled, collector will not parse \"hostnames\" list.");
2778
}
2779
2776
- value = appconfig_get(cfg, EBPF_NETWORK_VIEWER_SECTION, "ips", NULL);
2780
+ value = inicfg_get(cfg,
2781
+ EBPF_NETWORK_VIEWER_SECTION,
2782
+ "ips",
2783
+ NULL);
2784
//"ips", "!127.0.0.1/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 fc00::/7 !::1/128");
2785
ebpf_parse_ips_unsafe(value);
2786
}
@@ -2942,7 +2949,10 @@ static inline void ebpf_set_apps_mode(netdata_apps_integration_flags_t value)
2949
static void ebpf_update_interval(int update_every)
2950
{
2951
int i;
2945
- int value = (int)appconfig_get_number(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_UPDATE_EVERY, update_every);
2952
+
2953
+ int value = (int) inicfg_get_number(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_UPDATE_EVERY,
2954
+ update_every);
2955
+
2956
for (i = 0; ebpf_modules[i].info.thread_name; i++) {
2957
ebpf_modules[i].update_every = value;
2958
}
@@ -2955,10 +2965,9 @@ static void ebpf_update_interval(int update_every)
2965
*/
2966
static void ebpf_update_table_size()
2967
{
2958
- int i;
2959
- uint32_t value = (uint32_t)appconfig_get_number(
2960
- &collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_PID_SIZE, ND_EBPF_DEFAULT_PID_SIZE);
2961
- for (i = 0; ebpf_modules[i].info.thread_name; i++) {
2968
+ uint32_t value = (uint32_t) inicfg_get_number(&collector_config, EBPF_GLOBAL_SECTION,
2969
+ EBPF_CFG_PID_SIZE, ND_EBPF_DEFAULT_PID_SIZE);
2970
+ for (int i = 0; ebpf_modules[i].info.thread_name; i++) {
2971
ebpf_modules[i].pid_map_size = value;
2972
}
2973
}
@@ -2970,10 +2979,10 @@ static void ebpf_update_table_size()
2979
*/
2980
static void ebpf_update_lifetime()
2981
{
2973
- int i;
2974
- uint32_t value = (uint32_t)appconfig_get_number(
2975
- &collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_LIFETIME, EBPF_DEFAULT_LIFETIME);
2976
- for (i = 0; ebpf_modules[i].info.thread_name; i++) {
2982
+ uint32_t value = (uint32_t) inicfg_get_number(&collector_config, EBPF_GLOBAL_SECTION,
2983
+ EBPF_CFG_LIFETIME, EBPF_DEFAULT_LIFETIME);
2984
+
2985
+ for (int i = 0; ebpf_modules[i].info.thread_name; i++) {
2986
ebpf_modules[i].lifetime = value;
2987
}
2988
}
@@ -3012,10 +3021,10 @@ static inline void epbf_update_load_mode(const char *str, netdata_ebpf_load_mode
3021
*/
3022
static void ebpf_update_map_per_core()
3023
{
3015
- int i;
3016
- int value =
3017
- appconfig_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_MAPS_PER_CORE, CONFIG_BOOLEAN_YES);
3018
- for (i = 0; ebpf_modules[i].info.thread_name; i++) {
3024
+ int value = inicfg_get_boolean(&collector_config, EBPF_GLOBAL_SECTION,
3025
+ EBPF_CFG_MAPS_PER_CORE, CONFIG_BOOLEAN_YES);
3026
+
3027
+ for (int i = 0; ebpf_modules[i].info.thread_name; i++) {
3028
ebpf_modules[i].maps_per_core = value;
3029
}
3030
}
@@ -3031,20 +3040,21 @@ static void read_collector_values(int *disable_cgroups, int update_every, netdat
3040
{
3041
// Read global section
3042
const char *value;
3034
- if (appconfig_exists(&collector_config, EBPF_GLOBAL_SECTION, "load")) // Backward compatibility
3035
- value = appconfig_get(&collector_config, EBPF_GLOBAL_SECTION, "load", EBPF_CFG_LOAD_MODE_DEFAULT);
3043
+ if (inicfg_exists(&collector_config, EBPF_GLOBAL_SECTION, "load")) // Backward compatibility
3044
+ value = inicfg_get(&collector_config, EBPF_GLOBAL_SECTION, "load", EBPF_CFG_LOAD_MODE_DEFAULT);
3045
else
3037
- value = appconfig_get(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, EBPF_CFG_LOAD_MODE_DEFAULT);
3046
+ value = inicfg_get(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, EBPF_CFG_LOAD_MODE_DEFAULT);
3047
3048
ebpf_how_to_load(value);
3049
3041
- btf_path = appconfig_get(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_PROGRAM_PATH, EBPF_DEFAULT_BTF_PATH);
3050
+ btf_path = inicfg_get(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_PROGRAM_PATH,
3051
+ EBPF_DEFAULT_BTF_PATH);
3052
3053
#ifdef LIBBPF_MAJOR_VERSION
3054
default_btf = ebpf_load_btf_file(btf_path, EBPF_DEFAULT_BTF_FILE);
3055
#endif
3056
3047
- value = appconfig_get(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, EBPF_CFG_DEFAULT_PROGRAM);
3057
+ value = inicfg_get(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, EBPF_CFG_DEFAULT_PROGRAM);
3058
3059
epbf_update_load_mode(value, origin);
3060
@@ -3055,51 +3065,48 @@ static void read_collector_values(int *disable_cgroups, int update_every, netdat
3065
ebpf_update_lifetime();
3066
3067
// This is kept to keep compatibility
3058
- uint32_t enabled = appconfig_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, "disable apps", CONFIG_BOOLEAN_NO);
3068
+ uint32_t enabled = inicfg_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, "disable apps",
3069
+ CONFIG_BOOLEAN_NO);
3070
if (!enabled) {
3071
// Apps is a positive sentence, so we need to invert the values to disable apps.
3061
- enabled =
3062
- appconfig_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_APPLICATION, CONFIG_BOOLEAN_YES);
3063
- enabled = (enabled == CONFIG_BOOLEAN_NO) ? CONFIG_BOOLEAN_YES : CONFIG_BOOLEAN_NO;
3072
+ enabled = inicfg_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_APPLICATION,
3073
+ CONFIG_BOOLEAN_YES);
3074
+ enabled = (enabled == CONFIG_BOOLEAN_NO)?CONFIG_BOOLEAN_YES:CONFIG_BOOLEAN_NO;
3075
}
3076
3077
ebpf_set_apps_mode(!enabled);
3078
3079
// Cgroup is a positive sentence, so we need to invert the values to disable apps.
3080
// We are using the same pattern for cgroup and apps
3070
- enabled = appconfig_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_CGROUP, CONFIG_BOOLEAN_NO);
3071
- *disable_cgroups = (enabled == CONFIG_BOOLEAN_NO) ? CONFIG_BOOLEAN_YES : CONFIG_BOOLEAN_NO;
3081
+ enabled = inicfg_get_boolean(&collector_config, EBPF_GLOBAL_SECTION, EBPF_CFG_CGROUP, CONFIG_BOOLEAN_NO);
3082
+ *disable_cgroups = (enabled == CONFIG_BOOLEAN_NO)?CONFIG_BOOLEAN_YES:CONFIG_BOOLEAN_NO;
3083
3084
ebpf_update_map_per_core();
3085
3086
// Read ebpf programs section
3076
- enabled = appconfig_get_boolean(
3077
- &collector_config,
3078
- EBPF_PROGRAMS_SECTION,
3079
- ebpf_modules[EBPF_MODULE_PROCESS_IDX].info.config_name,
3080
- CONFIG_BOOLEAN_YES);
3087
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION,
3088
+ ebpf_modules[EBPF_MODULE_PROCESS_IDX].info.config_name, CONFIG_BOOLEAN_YES);
3089
if (enabled) {
3090
ebpf_enable_chart(EBPF_MODULE_PROCESS_IDX, *disable_cgroups);
3091
}
3092
3093
// This is kept to keep compatibility
3086
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "network viewer", CONFIG_BOOLEAN_NO);
3094
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "network viewer",
3095
+ CONFIG_BOOLEAN_NO);
3096
if (!enabled)
3088
- enabled = appconfig_get_boolean(
3089
- &collector_config,
3090
- EBPF_PROGRAMS_SECTION,
3091
- ebpf_modules[EBPF_MODULE_SOCKET_IDX].info.config_name,
3092
- CONFIG_BOOLEAN_NO);
3097
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION,
3098
+ ebpf_modules[EBPF_MODULE_SOCKET_IDX].info.config_name,
3099
+ CONFIG_BOOLEAN_NO);
3100
if (enabled) {
3101
ebpf_enable_chart(EBPF_MODULE_SOCKET_IDX, *disable_cgroups);
3102
}
3103
3104
// This is kept to keep compatibility
3098
- enabled = appconfig_get_boolean(
3099
- &collector_config, EBPF_PROGRAMS_SECTION, "network connection monitoring", CONFIG_BOOLEAN_YES);
3105
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "network connection monitoring",
3106
+ CONFIG_BOOLEAN_YES);
3107
if (!enabled)
3101
- enabled =
3102
- appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "network connections", CONFIG_BOOLEAN_YES);
3108
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "network connections",
3109
+ CONFIG_BOOLEAN_YES);
3110
3111
network_viewer_opt.enabled = enabled;
3112
if (enabled) {
@@ -3112,74 +3119,86 @@ static void read_collector_values(int *disable_cgroups, int update_every, netdat
3119
ebpf_parse_service_name_section(&collector_config);
3120
}
3121
3115
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "cachestat", CONFIG_BOOLEAN_NO);
3116
-
3122
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "cachestat",
3123
+ CONFIG_BOOLEAN_NO);
3124
if (enabled) {
3125
ebpf_enable_chart(EBPF_MODULE_CACHESTAT_IDX, *disable_cgroups);
3126
}
3127
3121
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "sync", CONFIG_BOOLEAN_YES);
3122
-
3128
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "sync",
3129
+ CONFIG_BOOLEAN_YES);
3130
if (enabled) {
3131
ebpf_enable_chart(EBPF_MODULE_SYNC_IDX, *disable_cgroups);
3132
}
3133
3127
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "dcstat", CONFIG_BOOLEAN_NO);
3134
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "dcstat",
3135
+ CONFIG_BOOLEAN_NO);
3136
if (enabled) {
3137
ebpf_enable_chart(EBPF_MODULE_DCSTAT_IDX, *disable_cgroups);
3138
}
3139
3132
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "swap", CONFIG_BOOLEAN_NO);
3140
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "swap",
3141
+ CONFIG_BOOLEAN_NO);
3142
if (enabled) {
3143
ebpf_enable_chart(EBPF_MODULE_SWAP_IDX, *disable_cgroups);
3144
}
3145
3137
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "vfs", CONFIG_BOOLEAN_NO);
3146
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "vfs",
3147
+ CONFIG_BOOLEAN_NO);
3148
if (enabled) {
3149
ebpf_enable_chart(EBPF_MODULE_VFS_IDX, *disable_cgroups);
3150
}
3151
3142
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "filesystem", CONFIG_BOOLEAN_NO);
3152
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "filesystem",
3153
+ CONFIG_BOOLEAN_NO);
3154
if (enabled) {
3155
ebpf_enable_chart(EBPF_MODULE_FILESYSTEM_IDX, *disable_cgroups);
3156
}
3157
3147
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "disk", CONFIG_BOOLEAN_NO);
3158
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "disk",
3159
+ CONFIG_BOOLEAN_NO);
3160
if (enabled) {
3161
ebpf_enable_chart(EBPF_MODULE_DISK_IDX, *disable_cgroups);
3162
}
3163
3152
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "mount", CONFIG_BOOLEAN_YES);
3164
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "mount",
3165
+ CONFIG_BOOLEAN_YES);
3166
if (enabled) {
3167
ebpf_enable_chart(EBPF_MODULE_MOUNT_IDX, *disable_cgroups);
3168
}
3169
3157
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "fd", CONFIG_BOOLEAN_YES);
3170
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "fd",
3171
+ CONFIG_BOOLEAN_YES);
3172
if (enabled) {
3173
ebpf_enable_chart(EBPF_MODULE_FD_IDX, *disable_cgroups);
3174
}
3175
3162
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "hardirq", CONFIG_BOOLEAN_YES);
3176
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "hardirq",
3177
+ CONFIG_BOOLEAN_YES);
3178
if (enabled) {
3179
ebpf_enable_chart(EBPF_MODULE_HARDIRQ_IDX, *disable_cgroups);
3180
}
3181
3167
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "softirq", CONFIG_BOOLEAN_YES);
3182
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "softirq",
3183
+ CONFIG_BOOLEAN_YES);
3184
if (enabled) {
3185
ebpf_enable_chart(EBPF_MODULE_SOFTIRQ_IDX, *disable_cgroups);
3186
}
3187
3172
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "oomkill", CONFIG_BOOLEAN_YES);
3188
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "oomkill",
3189
+ CONFIG_BOOLEAN_YES);
3190
if (enabled) {
3191
ebpf_enable_chart(EBPF_MODULE_OOMKILL_IDX, *disable_cgroups);
3192
}
3193
3177
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "shm", CONFIG_BOOLEAN_YES);
3194
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "shm",
3195
+ CONFIG_BOOLEAN_YES);
3196
if (enabled) {
3197
ebpf_enable_chart(EBPF_MODULE_SHM_IDX, *disable_cgroups);
3198
}
3199
3182
- enabled = appconfig_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "mdflush", CONFIG_BOOLEAN_NO);
3200
+ enabled = inicfg_get_boolean(&collector_config, EBPF_PROGRAMS_SECTION, "mdflush",
3201
+ CONFIG_BOOLEAN_NO);
3202
if (enabled) {
3203
ebpf_enable_chart(EBPF_MODULE_MDFLUSH_IDX, *disable_cgroups);
3204
}
@@ -3200,9 +3219,9 @@ static int ebpf_load_collector_config(char *path, int *disable_cgroups, int upda
3219
netdata_ebpf_load_mode_t origin;
3220
3221
snprintf(lpath, 4095, "%s/%s", path, NETDATA_EBPF_CONFIG_FILE);
3203
- if (!appconfig_load(&collector_config, lpath, 0, NULL)) {
3222
+ if (!inicfg_load(&collector_config, lpath, 0, NULL)) {
3223
snprintf(lpath, 4095, "%s/%s", path, NETDATA_EBPF_OLD_CONFIG_FILE);
3205
- if (!appconfig_load(&collector_config, lpath, 0, NULL)) {
3224
+ if (!inicfg_load(&collector_config, lpath, 0, NULL)) {
3225
return -1;
3226
}
3227
origin = EBPF_LOADED_FROM_STOCK;
src/collectors/ebpf.plugin/ebpf_apps.h
+1
-4
@@ -3,11 +3,8 @@
3
#ifndef NETDATA_EBPF_APPS_H
4
#define NETDATA_EBPF_APPS_H 1
5
6
+#include "libnetdata/libnetdata.h"
7
#include "collectors/collectors-ipc/collectors-ipc.h"
7
-#include "libnetdata/locks/locks.h"
8
-#include "libnetdata/avl/avl.h"
9
-#include "libnetdata/clocks/clocks.h"
10
-#include "libnetdata/config/appconfig.h"
8
#include "libbpf_api/ebpf.h"
9
10
#define NETDATA_APPS_FAMILY "apps"
src/collectors/ebpf.plugin/ebpf_filesystem.c
+2
-2
@@ -1135,8 +1135,8 @@ static void ebpf_update_filesystem()
1135
for (i = 0; localfs[i].filesystem; i++) {
1136
snprintfz(dist, NETDATA_FS_MAX_DIST_NAME, "%sdist", localfs[i].filesystem);
1137
1138
- localfs[i].enabled =
1139
- appconfig_get_boolean(&fs_config, NETDATA_FILESYSTEM_CONFIG_NAME, dist, CONFIG_BOOLEAN_YES);
1138
+ localfs[i].enabled = inicfg_get_boolean(&fs_config, NETDATA_FILESYSTEM_CONFIG_NAME, dist,
1139
+ CONFIG_BOOLEAN_YES);
1140
}
1141
}
1142
src/collectors/ebpf.plugin/ebpf_socket.c
+12
-8
@@ -2901,7 +2901,7 @@ static bool config_service_value_cb(void *data __maybe_unused, const char *name,
2901
2902
void ebpf_parse_service_name_section(struct config *cfg)
2903
{
2904
- appconfig_foreach_value_in_section(cfg, EBPF_SERVICE_NAME_SECTION, config_service_value_cb, NULL);
2904
+ inicfg_foreach_value_in_section(cfg, EBPF_SERVICE_NAME_SECTION, config_service_value_cb, NULL);
2905
2906
// Always associated the default port to Netdata
2907
ebpf_network_viewer_dim_name_t *names = network_viewer_opt.names;
@@ -2931,11 +2931,14 @@ void ebpf_parse_service_name_section(struct config *cfg)
2931
*/
2932
void parse_table_size_options(struct config *cfg)
2933
{
2934
- socket_maps[NETDATA_SOCKET_OPEN_SOCKET].user_input = (uint32_t)appconfig_get_number(
2935
- cfg, EBPF_GLOBAL_SECTION, EBPF_CONFIG_SOCKET_MONITORING_SIZE, NETDATA_MAXIMUM_CONNECTIONS_ALLOWED);
2936
-
2937
- socket_maps[NETDATA_SOCKET_TABLE_UDP].user_input = (uint32_t)appconfig_get_number(
2938
- cfg, EBPF_GLOBAL_SECTION, EBPF_CONFIG_UDP_SIZE, NETDATA_MAXIMUM_UDP_CONNECTIONS_ALLOWED);
2934
+ socket_maps[NETDATA_SOCKET_OPEN_SOCKET].user_input = (uint32_t) inicfg_get_number(cfg,
2935
+ EBPF_GLOBAL_SECTION,
2936
+ EBPF_CONFIG_SOCKET_MONITORING_SIZE,
2937
+ NETDATA_MAXIMUM_CONNECTIONS_ALLOWED);
2938
+
2939
+ socket_maps[NETDATA_SOCKET_TABLE_UDP].user_input = (uint32_t) inicfg_get_number(cfg,
2940
+ EBPF_GLOBAL_SECTION,
2941
+ EBPF_CONFIG_UDP_SIZE, NETDATA_MAXIMUM_UDP_CONNECTIONS_ALLOWED);
2942
}
2943
2944
/*
@@ -3002,8 +3005,9 @@ void *ebpf_socket_thread(void *ptr)
3005
rw_spinlock_write_lock(&network_viewer_opt.rw_spinlock);
3006
// It was not enabled from main config file (ebpf.d.conf)
3007
if (!network_viewer_opt.enabled)
3005
- network_viewer_opt.enabled =
3006
- appconfig_get_boolean(&socket_config, EBPF_NETWORK_VIEWER_SECTION, "enabled", CONFIG_BOOLEAN_YES);
3008
+ network_viewer_opt.enabled = inicfg_get_boolean(&socket_config, EBPF_NETWORK_VIEWER_SECTION, "enabled",
3009
+ CONFIG_BOOLEAN_YES);
3010
+
3011
rw_spinlock_write_unlock(&network_viewer_opt.rw_spinlock);
3012
3013
parse_table_size_options(&socket_config);
src/collectors/ebpf.plugin/ebpf_sync.c
+3
-4
@@ -724,10 +724,9 @@ static void ebpf_create_sync_charts(int update_every)
724
*/
725
static void ebpf_sync_parse_syscalls()
726
{
727
- int i;
728
- for (i = 0; local_syscalls[i].syscall; i++) {
729
- local_syscalls[i].enabled = appconfig_get_boolean(
730
- &sync_config, NETDATA_SYNC_CONFIG_NAME, local_syscalls[i].syscall, CONFIG_BOOLEAN_YES);
727
+ for (int i = 0; local_syscalls[i].syscall; i++) {
728
+ local_syscalls[i].enabled = inicfg_get_boolean(&sync_config, NETDATA_SYNC_CONFIG_NAME,
729
+ local_syscalls[i].syscall, CONFIG_BOOLEAN_YES);
730
}
731
}
732
src/collectors/ebpf.plugin/libbpf_api/ebpf.c
+11
-11
@@ -1010,7 +1010,7 @@ void ebpf_mount_config_name(char *filename, size_t length, char *path, const cha
1010
1011
int ebpf_load_config(struct config *config, char *filename)
1012
{
1013
- return appconfig_load(config, filename, 0, NULL);
1013
+ return inicfg_load(config, filename, 0, NULL);
1014
}
1015
1016
@@ -1299,39 +1299,39 @@ void ebpf_update_module_using_config(ebpf_module_t *modules, netdata_ebpf_load_m
1299
{
1300
char default_value[EBPF_MAX_MODE_LENGTH + 1];
1301
ebpf_select_mode_string(default_value, EBPF_MAX_MODE_LENGTH, modules->mode);
1302
- const char *load_mode = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, default_value);
1302
+ const char *load_mode = inicfg_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_LOAD_MODE, default_value);
1303
modules->mode = ebpf_select_mode(load_mode);
1304
1305
- modules->update_every = (int)appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION,
1305
+ modules->update_every = (int)inicfg_get_number(modules->cfg, EBPF_GLOBAL_SECTION,
1306
EBPF_CFG_UPDATE_EVERY, modules->update_every);
1307
1308
- modules->apps_charts = appconfig_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_APPLICATION,
1308
+ modules->apps_charts = inicfg_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_APPLICATION,
1309
(int) (modules->apps_charts & NETDATA_EBPF_APPS_FLAG_YES));
1310
1311
- modules->cgroup_charts = appconfig_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CGROUP,
1311
+ modules->cgroup_charts = inicfg_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CGROUP,
1312
modules->cgroup_charts);
1313
1314
- modules->pid_map_size = (uint32_t)appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_PID_SIZE,
1314
+ modules->pid_map_size = (uint32_t)inicfg_get_number(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_PID_SIZE,
1315
modules->pid_map_size);
1316
1317
- modules->lifetime = (uint32_t) appconfig_get_number(modules->cfg, EBPF_GLOBAL_SECTION,
1317
+ modules->lifetime = (uint32_t) inicfg_get_number(modules->cfg, EBPF_GLOBAL_SECTION,
1318
EBPF_CFG_LIFETIME, EBPF_DEFAULT_LIFETIME);
1319
1320
char *value = ebpf_convert_load_mode_to_string(modules->load & NETDATA_EBPF_LOAD_METHODS);
1321
- const char *type_format = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, value);
1321
+ const char *type_format = inicfg_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_TYPE_FORMAT, value);
1322
netdata_ebpf_load_mode_t load = epbf_convert_string_to_load_mode(type_format);
1323
load = ebpf_select_load_mode(btf_file, load, kver, is_rh);
1324
modules->load = origin | load;
1325
1326
- const char *core_attach = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CORE_ATTACH, EBPF_CFG_ATTACH_TRAMPOLINE);
1326
+ const char *core_attach = inicfg_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_CORE_ATTACH, EBPF_CFG_ATTACH_TRAMPOLINE);
1327
netdata_ebpf_program_loaded_t fill_lm = ebpf_convert_core_type(core_attach, modules->mode);
1328
ebpf_update_target_with_conf(modules, fill_lm);
1329
1330
value = ebpf_convert_collect_pid_to_string(modules->apps_level);
1331
- const char *collect_pid = appconfig_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_COLLECT_PID, value);
1331
+ const char *collect_pid = inicfg_get(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_COLLECT_PID, value);
1332
modules->apps_level = ebpf_convert_string_to_apps_level(collect_pid);
1333
1334
- modules->maps_per_core = appconfig_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_MAPS_PER_CORE,
1334
+ modules->maps_per_core = inicfg_get_boolean(modules->cfg, EBPF_GLOBAL_SECTION, EBPF_CFG_MAPS_PER_CORE,
1335
modules->maps_per_core);
1336
if (kver < NETDATA_EBPF_KERNEL_4_06)
1337
modules->maps_per_core = CONFIG_BOOLEAN_NO;
src/collectors/freebsd.plugin/freebsd_devstat.c
+1
-1
@@ -222,7 +222,7 @@ int do_kern_devstat(int update_every, usec_t dt) {
222
CONFIG_BOOLEAN_AUTO);
223
224
excluded_disks = simple_pattern_create(
225
- config_get(CONFIG_SECTION_KERN_DEVSTAT, "disable by default disks matching", DEFAULT_EXCLUDED_DISKS),
225
+ inicfg_get(&netdata_config, CONFIG_SECTION_KERN_DEVSTAT, "disable by default disks matching", DEFAULT_EXCLUDED_DISKS),
226
NULL,
227
SIMPLE_PATTERN_EXACT,
228
true);
src/collectors/freebsd.plugin/freebsd_getifaddrs.c
+2
-2
@@ -177,12 +177,12 @@ int do_getifaddrs(int update_every, usec_t dt) {
177
CONFIG_BOOLEAN_AUTO);
178
179
excluded_interfaces = simple_pattern_create(
180
- config_get(CONFIG_SECTION_GETIFADDRS, "disable by default interfaces matching", DEFAULT_EXCLUDED_INTERFACES),
180
+ inicfg_get(&netdata_config, CONFIG_SECTION_GETIFADDRS, "disable by default interfaces matching", DEFAULT_EXCLUDED_INTERFACES),
181
NULL,
182
SIMPLE_PATTERN_EXACT,
183
true);
184
physical_interfaces = simple_pattern_create(
185
- config_get(CONFIG_SECTION_GETIFADDRS, "set physical interfaces for system.net", DEFAULT_PHYSICAL_INTERFACES),
185
+ inicfg_get(&netdata_config, CONFIG_SECTION_GETIFADDRS, "set physical interfaces for system.net", DEFAULT_PHYSICAL_INTERFACES),
186
NULL,
187
SIMPLE_PATTERN_EXACT,
188
true);
src/collectors/freebsd.plugin/freebsd_getmntinfo.c
+2
-2
@@ -143,13 +143,13 @@ int do_getmntinfo(int update_every, usec_t dt) {
143
do_inodes = config_get_boolean_ondemand(CONFIG_SECTION_GETMNTINFO, "inodes usage for all disks", CONFIG_BOOLEAN_AUTO);
144
145
excluded_mountpoints = simple_pattern_create(
146
- config_get(CONFIG_SECTION_GETMNTINFO, "exclude space metrics on paths", DEFAULT_EXCLUDED_PATHS),
146
+ inicfg_get(&netdata_config, CONFIG_SECTION_GETMNTINFO, "exclude space metrics on paths", DEFAULT_EXCLUDED_PATHS),
147
NULL,
148
SIMPLE_PATTERN_EXACT,
149
true);
150
151
excluded_filesystems = simple_pattern_create(
152
- config_get(CONFIG_SECTION_GETMNTINFO, "exclude space metrics on filesystems", DEFAULT_EXCLUDED_FILESYSTEMS),
152
+ inicfg_get(&netdata_config, CONFIG_SECTION_GETMNTINFO, "exclude space metrics on filesystems", DEFAULT_EXCLUDED_FILESYSTEMS),
153
NULL,
154
SIMPLE_PATTERN_EXACT,
155
true);
src/collectors/freebsd.plugin/freebsd_ipfw.c
+3
-3
@@ -22,9 +22,9 @@ int do_ipfw(int update_every, usec_t dt) {
22
static int do_static = -1, do_dynamic = -1, do_mem = -1;
23
24
if (unlikely(do_static == -1)) {
25
- do_static = config_get_boolean("plugin:freebsd:ipfw", "counters for static rules", 1);
26
- do_dynamic = config_get_boolean("plugin:freebsd:ipfw", "number of dynamic rules", 1);
27
- do_mem = config_get_boolean("plugin:freebsd:ipfw", "allocated memory", 1);
25
+ do_static = inicfg_get_boolean(&netdata_config, "plugin:freebsd:ipfw", "counters for static rules", 1);
26
+ do_dynamic = inicfg_get_boolean(&netdata_config, "plugin:freebsd:ipfw", "number of dynamic rules", 1);
27
+ do_mem = inicfg_get_boolean(&netdata_config, "plugin:freebsd:ipfw", "allocated memory", 1);
28
}
29
30
// variables for getting ipfw configuration
src/collectors/freebsd.plugin/freebsd_sysctl.c
+17
-17
@@ -178,9 +178,9 @@ int do_vm_vmtotal(int update_every, usec_t dt) {
178
static int do_all_processes = -1, do_processes = -1, do_mem_real = -1;
179
180
if (unlikely(do_all_processes == -1)) {
181
- do_all_processes = config_get_boolean("plugin:freebsd:vm.vmtotal", "enable total processes", 1);
182
- do_processes = config_get_boolean("plugin:freebsd:vm.vmtotal", "processes running", 1);
183
- do_mem_real = config_get_boolean("plugin:freebsd:vm.vmtotal", "real memory", 1);
181
+ do_all_processes = inicfg_get_boolean(&netdata_config, "plugin:freebsd:vm.vmtotal", "enable total processes", 1);
182
+ do_processes = inicfg_get_boolean(&netdata_config, "plugin:freebsd:vm.vmtotal", "processes running", 1);
183
+ do_mem_real = inicfg_get_boolean(&netdata_config, "plugin:freebsd:vm.vmtotal", "real memory", 1);
184
}
185
186
if (likely(do_all_processes | do_processes | do_mem_real)) {
@@ -1425,8 +1425,8 @@ int do_net_isr(int update_every, usec_t dt) {
1425
static int do_netisr = -1, do_netisr_per_core = -1;
1426
1427
if (unlikely(do_netisr == -1)) {
1428
- do_netisr = config_get_boolean("plugin:freebsd:net.isr", "netisr", 1);
1429
- do_netisr_per_core = config_get_boolean("plugin:freebsd:net.isr", "netisr per core", 1);
1428
+ do_netisr = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.isr", "netisr", 1);
1429
+ do_netisr_per_core = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.isr", "netisr per core", 1);
1430
}
1431
1432
static struct netisr_stats {
@@ -1659,9 +1659,9 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1659
do_tcpext_syncookies = -1, do_tcpext_listen = -1, do_ecn = -1;
1660
1661
if (unlikely(do_tcp_packets == -1)) {
1662
- do_tcp_packets = config_get_boolean("plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP packets", 1);
1663
- do_tcp_errors = config_get_boolean("plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP errors", 1);
1664
- do_tcp_handshake = config_get_boolean("plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP handshake issues", 1);
1662
+ do_tcp_packets = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP packets", 1);
1663
+ do_tcp_errors = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP errors", 1);
1664
+ do_tcp_handshake = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP handshake issues", 1);
1665
do_tcpext_connaborts = config_get_boolean_ondemand("plugin:freebsd:net.inet.tcp.stats", "TCP connection aborts",
1666
CONFIG_BOOLEAN_AUTO);
1667
do_tcpext_ofo = config_get_boolean_ondemand("plugin:freebsd:net.inet.tcp.stats", "TCP out-of-order queue",
@@ -2002,8 +2002,8 @@ int do_net_inet_udp_stats(int update_every, usec_t dt) {
2002
static int do_udp_packets = -1, do_udp_errors = -1;
2003
2004
if (unlikely(do_udp_packets == -1)) {
2005
- do_udp_packets = config_get_boolean("plugin:freebsd:net.inet.udp.stats", "ipv4 UDP packets", 1);
2006
- do_udp_errors = config_get_boolean("plugin:freebsd:net.inet.udp.stats", "ipv4 UDP errors", 1);
2005
+ do_udp_packets = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.udp.stats", "ipv4 UDP packets", 1);
2006
+ do_udp_errors = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.udp.stats", "ipv4 UDP errors", 1);
2007
}
2008
2009
// see http://net-snmp.sourceforge.net/docs/mibs/udp.html
@@ -2099,9 +2099,9 @@ int do_net_inet_icmp_stats(int update_every, usec_t dt) {
2099
static int do_icmp_packets = -1, do_icmp_errors = -1, do_icmpmsg = -1;
2100
2101
if (unlikely(do_icmp_packets == -1)) {
2102
- do_icmp_packets = config_get_boolean("plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP packets", 1);
2103
- do_icmp_errors = config_get_boolean("plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP errors", 1);
2104
- do_icmpmsg = config_get_boolean("plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP messages", 1);
2102
+ do_icmp_packets = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP packets", 1);
2103
+ do_icmp_errors = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP errors", 1);
2104
+ do_icmpmsg = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP messages", 1);
2105
}
2106
2107
if (likely(do_icmp_packets || do_icmp_errors || do_icmpmsg)) {
@@ -2240,10 +2240,10 @@ int do_net_inet_ip_stats(int update_every, usec_t dt) {
2240
static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1;
2241
2242
if (unlikely(do_ip_packets == -1)) {
2243
- do_ip_packets = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 packets", 1);
2244
- do_ip_fragsout = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 fragments sent", 1);
2245
- do_ip_fragsin = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 fragments assembly", 1);
2246
- do_ip_errors = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 errors", 1);
2243
+ do_ip_packets = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.ip.stats", "ipv4 packets", 1);
2244
+ do_ip_fragsout = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.ip.stats", "ipv4 fragments sent", 1);
2245
+ do_ip_fragsin = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.ip.stats", "ipv4 fragments assembly", 1);
2246
+ do_ip_errors = inicfg_get_boolean(&netdata_config, "plugin:freebsd:net.inet.ip.stats", "ipv4 errors", 1);
2247
}
2248
2249
// see also http://net-snmp.sourceforge.net/docs/mibs/ip.html
src/collectors/freebsd.plugin/plugin_freebsd.c
+1
-1
@@ -98,7 +98,7 @@ void *freebsd_main(void *ptr)
98
for (i = 0; freebsd_modules[i].name; i++) {
99
struct freebsd_module *pm = &freebsd_modules[i];
100
101
- pm->enabled = config_get_boolean("plugin:freebsd", pm->name, pm->enabled);
101
+ pm->enabled = inicfg_get_boolean(&netdata_config, "plugin:freebsd", pm->name, pm->enabled);
102
pm->rd = NULL;
103
104
worker_register_job_name(i, freebsd_modules[i].dim);
src/collectors/idlejitter.plugin/plugin_idlejitter.c
+2
-2
@@ -21,9 +21,9 @@ void *cpuidlejitter_main(void *ptr) {
21
worker_register("IDLEJITTER");
22
worker_register_job_name(0, "measurements");
23
24
- usec_t sleep_ut = config_get_duration_ms("plugin:idlejitter", "loop time", CPU_IDLEJITTER_SLEEP_TIME_MS) * USEC_PER_MS;
24
+ usec_t sleep_ut = inicfg_get_duration_ms(&netdata_config, "plugin:idlejitter", "loop time", CPU_IDLEJITTER_SLEEP_TIME_MS) * USEC_PER_MS;
25
if(sleep_ut <= 0) {
26
- config_set_duration_ms("plugin:idlejitter", "loop time", CPU_IDLEJITTER_SLEEP_TIME_MS);
26
+ inicfg_set_duration_ms(&netdata_config, "plugin:idlejitter", "loop time", CPU_IDLEJITTER_SLEEP_TIME_MS);
27
sleep_ut = CPU_IDLEJITTER_SLEEP_TIME_MS * USEC_PER_MS;
28
}
29
src/collectors/macos.plugin/macos_fw.c
+4
-4
@@ -27,10 +27,10 @@ int do_macos_iokit(int update_every, usec_t dt) {
27
static int do_io = -1, do_space = -1, do_inodes = -1, do_bandwidth = -1;
28
29
if (unlikely(do_io == -1)) {
30
- do_io = config_get_boolean("plugin:macos:iokit", "disk i/o", 1);
31
- do_space = config_get_boolean("plugin:macos:sysctl", "space usage for all disks", 1);
32
- do_inodes = config_get_boolean("plugin:macos:sysctl", "inodes usage for all disks", 1);
33
- do_bandwidth = config_get_boolean("plugin:macos:sysctl", "bandwidth", 1);
30
+ do_io = inicfg_get_boolean(&netdata_config, "plugin:macos:iokit", "disk i/o", 1);
31
+ do_space = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "space usage for all disks", 1);
32
+ do_inodes = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "inodes usage for all disks", 1);
33
+ do_bandwidth = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "bandwidth", 1);
34
}
35
36
RRDSET *st;
src/collectors/macos.plugin/macos_mach_smi.c
+4
-4
@@ -10,10 +10,10 @@ int do_macos_mach_smi(int update_every, usec_t dt) {
10
static int do_cpu = -1, do_ram = - 1, do_swapio = -1, do_pgfaults = -1;
11
12
if (unlikely(do_cpu == -1)) {
13
- do_cpu = config_get_boolean("plugin:macos:mach_smi", "cpu utilization", 1);
14
- do_ram = config_get_boolean("plugin:macos:mach_smi", "system ram", 1);
15
- do_swapio = config_get_boolean("plugin:macos:mach_smi", "swap i/o", 1);
16
- do_pgfaults = config_get_boolean("plugin:macos:mach_smi", "memory page faults", 1);
13
+ do_cpu = inicfg_get_boolean(&netdata_config, "plugin:macos:mach_smi", "cpu utilization", 1);
14
+ do_ram = inicfg_get_boolean(&netdata_config, "plugin:macos:mach_smi", "system ram", 1);
15
+ do_swapio = inicfg_get_boolean(&netdata_config, "plugin:macos:mach_smi", "swap i/o", 1);
16
+ do_pgfaults = inicfg_get_boolean(&netdata_config, "plugin:macos:mach_smi", "memory page faults", 1);
17
}
18
19
RRDSET *st;
src/collectors/macos.plugin/macos_sysctl.c
+30
-30
@@ -38,36 +38,36 @@ int do_macos_sysctl(int update_every, usec_t dt) {
38
39
40
if (unlikely(do_loadavg == -1)) {
41
- do_loadavg = config_get_boolean("plugin:macos:sysctl", "enable load average", 1);
42
- do_swap = config_get_boolean("plugin:macos:sysctl", "system swap", 1);
43
- do_bandwidth = config_get_boolean("plugin:macos:sysctl", "bandwidth", 1);
44
- do_tcp_packets = config_get_boolean("plugin:macos:sysctl", "ipv4 TCP packets", 1);
45
- do_tcp_errors = config_get_boolean("plugin:macos:sysctl", "ipv4 TCP errors", 1);
46
- do_tcp_handshake = config_get_boolean("plugin:macos:sysctl", "ipv4 TCP handshake issues", 1);
47
- do_ecn = config_get_boolean_ondemand("plugin:macos:sysctl", "ECN packets", CONFIG_BOOLEAN_AUTO);
48
- do_tcpext_syscookies = config_get_boolean_ondemand("plugin:macos:sysctl", "TCP SYN cookies", CONFIG_BOOLEAN_AUTO);
49
- do_tcpext_ofo = config_get_boolean_ondemand("plugin:macos:sysctl", "TCP out-of-order queue", CONFIG_BOOLEAN_AUTO);
50
- do_tcpext_connaborts = config_get_boolean_ondemand("plugin:macos:sysctl", "TCP connection aborts", CONFIG_BOOLEAN_AUTO);
51
- do_udp_packets = config_get_boolean("plugin:macos:sysctl", "ipv4 UDP packets", 1);
52
- do_udp_errors = config_get_boolean("plugin:macos:sysctl", "ipv4 UDP errors", 1);
53
- do_icmp_packets = config_get_boolean("plugin:macos:sysctl", "ipv4 ICMP packets", 1);
54
- do_icmpmsg = config_get_boolean("plugin:macos:sysctl", "ipv4 ICMP messages", 1);
55
- do_ip_packets = config_get_boolean("plugin:macos:sysctl", "ipv4 packets", 1);
56
- do_ip_fragsout = config_get_boolean("plugin:macos:sysctl", "ipv4 fragments sent", 1);
57
- do_ip_fragsin = config_get_boolean("plugin:macos:sysctl", "ipv4 fragments assembly", 1);
58
- do_ip_errors = config_get_boolean("plugin:macos:sysctl", "ipv4 errors", 1);
59
- do_ip6_packets = config_get_boolean_ondemand("plugin:macos:sysctl", "ipv6 packets", CONFIG_BOOLEAN_AUTO);
60
- do_ip6_fragsout = config_get_boolean_ondemand("plugin:macos:sysctl", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO);
61
- do_ip6_fragsin = config_get_boolean_ondemand("plugin:macos:sysctl", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO);
62
- do_ip6_errors = config_get_boolean_ondemand("plugin:macos:sysctl", "ipv6 errors", CONFIG_BOOLEAN_AUTO);
63
- do_icmp6 = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp", CONFIG_BOOLEAN_AUTO);
64
- do_icmp6_redir = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp redirects", CONFIG_BOOLEAN_AUTO);
65
- do_icmp6_errors = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp errors", CONFIG_BOOLEAN_AUTO);
66
- do_icmp6_echos = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp echos", CONFIG_BOOLEAN_AUTO);
67
- do_icmp6_router = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp router", CONFIG_BOOLEAN_AUTO);
68
- do_icmp6_neighbor = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp neighbor", CONFIG_BOOLEAN_AUTO);
69
- do_icmp6_types = config_get_boolean_ondemand("plugin:macos:sysctl", "icmp types", CONFIG_BOOLEAN_AUTO);
70
- do_uptime = config_get_boolean("plugin:macos:sysctl", "system uptime", 1);
41
+ do_loadavg = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "enable load average", 1);
42
+ do_swap = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "system swap", 1);
43
+ do_bandwidth = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "bandwidth", 1);
44
+ do_tcp_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 TCP packets", 1);
45
+ do_tcp_errors = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 TCP errors", 1);
46
+ do_tcp_handshake = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 TCP handshake issues", 1);
47
+ do_ecn = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ECN packets", CONFIG_BOOLEAN_AUTO);
48
+ do_tcpext_syscookies = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "TCP SYN cookies", CONFIG_BOOLEAN_AUTO);
49
+ do_tcpext_ofo = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "TCP out-of-order queue", CONFIG_BOOLEAN_AUTO);
50
+ do_tcpext_connaborts = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "TCP connection aborts", CONFIG_BOOLEAN_AUTO);
51
+ do_udp_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 UDP packets", 1);
52
+ do_udp_errors = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 UDP errors", 1);
53
+ do_icmp_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 ICMP packets", 1);
54
+ do_icmpmsg = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 ICMP messages", 1);
55
+ do_ip_packets = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 packets", 1);
56
+ do_ip_fragsout = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 fragments sent", 1);
57
+ do_ip_fragsin = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 fragments assembly", 1);
58
+ do_ip_errors = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "ipv4 errors", 1);
59
+ do_ip6_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 packets", CONFIG_BOOLEAN_AUTO);
60
+ do_ip6_fragsout = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO);
61
+ do_ip6_fragsin = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO);
62
+ do_ip6_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "ipv6 errors", CONFIG_BOOLEAN_AUTO);
63
+ do_icmp6 = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp", CONFIG_BOOLEAN_AUTO);
64
+ do_icmp6_redir = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp redirects", CONFIG_BOOLEAN_AUTO);
65
+ do_icmp6_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp errors", CONFIG_BOOLEAN_AUTO);
66
+ do_icmp6_echos = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp echos", CONFIG_BOOLEAN_AUTO);
67
+ do_icmp6_router = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp router", CONFIG_BOOLEAN_AUTO);
68
+ do_icmp6_neighbor = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp neighbor", CONFIG_BOOLEAN_AUTO);
69
+ do_icmp6_types = inicfg_get_boolean_ondemand(&netdata_config, "plugin:macos:sysctl", "icmp types", CONFIG_BOOLEAN_AUTO);
70
+ do_uptime = inicfg_get_boolean(&netdata_config, "plugin:macos:sysctl", "system uptime", 1);
71
}
72
73
RRDSET *st = NULL;
src/collectors/macos.plugin/plugin_macos.c
+1
-1
@@ -47,7 +47,7 @@ void *macos_main(void *ptr)
47
for (int i = 0; macos_modules[i].name; i++) {
48
struct macos_module *pm = &macos_modules[i];
49
50
- pm->enabled = config_get_boolean("plugin:macos", pm->name, pm->enabled);
50
+ pm->enabled = inicfg_get_boolean(&netdata_config, "plugin:macos", pm->name, pm->enabled);
51
pm->rd = NULL;
52
53
worker_register_job_name(i, macos_modules[i].dim);
src/collectors/proc.plugin/ipc.c
+6
-6
@@ -293,19 +293,19 @@ int do_ipc(int update_every, usec_t dt) {
293
static const char *shm_filename = NULL;
294
295
if(unlikely(do_sem == -1)) {
296
- do_msg = config_get_boolean("plugin:proc:ipc", "message queues", CONFIG_BOOLEAN_YES);
297
- do_sem = config_get_boolean("plugin:proc:ipc", "semaphore totals", CONFIG_BOOLEAN_YES);
298
- do_shm = config_get_boolean("plugin:proc:ipc", "shared memory totals", CONFIG_BOOLEAN_YES);
296
+ do_msg = inicfg_get_boolean(&netdata_config, "plugin:proc:ipc", "message queues", CONFIG_BOOLEAN_YES);
297
+ do_sem = inicfg_get_boolean(&netdata_config, "plugin:proc:ipc", "semaphore totals", CONFIG_BOOLEAN_YES);
298
+ do_shm = inicfg_get_boolean(&netdata_config, "plugin:proc:ipc", "shared memory totals", CONFIG_BOOLEAN_YES);
299
300
char filename[FILENAME_MAX + 1];
301
302
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sysvipc/msg");
303
- msg_filename = config_get("plugin:proc:ipc", "msg filename to monitor", filename);
303
+ msg_filename = inicfg_get(&netdata_config, "plugin:proc:ipc", "msg filename to monitor", filename);
304
305
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sysvipc/shm");
306
- shm_filename = config_get("plugin:proc:ipc", "shm filename to monitor", filename);
306
+ shm_filename = inicfg_get(&netdata_config, "plugin:proc:ipc", "shm filename to monitor", filename);
307
308
- dimensions_limit = config_get_number("plugin:proc:ipc", "max dimensions in memory allowed", 50);
308
+ dimensions_limit = inicfg_get_number(&netdata_config, "plugin:proc:ipc", "max dimensions in memory allowed", 50);
309
310
// make sure it works
311
if(ipc_sem_get_limits(&limits) == -1) {
src/collectors/proc.plugin/plugin_proc.c
+4
-4
@@ -207,19 +207,19 @@ void *proc_main(void *ptr)
207
208
rrd_collector_started();
209
210
- if (config_get_boolean("plugin:proc", "/proc/net/dev", CONFIG_BOOLEAN_YES)) {
210
+ if (inicfg_get_boolean(&netdata_config, "plugin:proc", "/proc/net/dev", CONFIG_BOOLEAN_YES)) {
211
netdata_log_debug(D_SYSTEM, "Starting thread %s.", THREAD_NETDEV_NAME);
212
netdev_thread = nd_thread_create(THREAD_NETDEV_NAME, NETDATA_THREAD_OPTION_JOINABLE, netdev_main, NULL);
213
}
214
215
- config_get_boolean("plugin:proc", "/proc/pagetypeinfo", CONFIG_BOOLEAN_NO);
215
+ inicfg_get_boolean(&netdata_config, "plugin:proc", "/proc/pagetypeinfo", CONFIG_BOOLEAN_NO);
216
217
// check the enabled status for each module
218
int i;
219
for(i = 0; proc_modules[i].name; i++) {
220
struct proc_module *pm = &proc_modules[i];
221
222
- pm->enabled = config_get_boolean("plugin:proc", pm->name, CONFIG_BOOLEAN_YES);
222
+ pm->enabled = inicfg_get_boolean(&netdata_config, "plugin:proc", pm->name, CONFIG_BOOLEAN_YES);
223
pm->rd = NULL;
224
225
worker_register_job_name(i, proc_modules[i].dim);
@@ -277,7 +277,7 @@ int get_numa_node_count(void)
277
278
char name[FILENAME_MAX + 1];
279
snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/node");
280
- const char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name);
280
+ const char *dirname = inicfg_get(&netdata_config, "plugin:proc:/sys/devices/system/node", "directory to monitor", name);
281
282
DIR *dir = opendir(dirname);
283
if (dir) {
src/collectors/proc.plugin/proc_diskstats.c
+52
-52
@@ -332,7 +332,7 @@ static inline int is_major_enabled(int major) {
332
if(major_configs[major] == -1) {
333
char buffer[CONFIG_MAX_NAME + 1];
334
snprintfz(buffer, CONFIG_MAX_NAME, "performance metrics for disks with major %d", major);
335
- major_configs[major] = (char)config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, buffer, 1);
335
+ major_configs[major] = (char)inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, buffer, 1);
336
}
337
338
return (int)major_configs[major];
@@ -582,8 +582,8 @@ static void get_disk_config(struct disk *d) {
582
char var_name[4096 + 1];
583
snprintfz(var_name, 4096, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS ":%s", d->disk);
584
585
- if (config_exists(var_name, "enable"))
586
- def_enable = config_get_boolean_ondemand(var_name, "enable", def_enable);
585
+ if (inicfg_exists(&netdata_config, var_name, "enable"))
586
+ def_enable = inicfg_get_boolean_ondemand(&netdata_config, var_name, "enable", def_enable);
587
588
if(unlikely(def_enable == CONFIG_BOOLEAN_NO)) {
589
// the user does not want any metrics for this disk
@@ -636,8 +636,8 @@ static void get_disk_config(struct disk *d) {
636
637
// def_performance
638
// check the user configuration (this will also show our 'on demand' decision)
639
- if (config_exists(var_name, "enable performance metrics"))
640
- def_performance = config_get_boolean_ondemand(var_name, "enable performance metrics", def_performance);
639
+ if (inicfg_exists(&netdata_config, var_name, "enable performance metrics"))
640
+ def_performance = inicfg_get_boolean_ondemand(&netdata_config, var_name, "enable performance metrics", def_performance);
641
642
int ddo_io = CONFIG_BOOLEAN_NO,
643
ddo_ops = CONFIG_BOOLEAN_NO,
@@ -673,28 +673,28 @@ static void get_disk_config(struct disk *d) {
673
d->do_ext = ddo_ext;
674
d->do_backlog = ddo_backlog;
675
676
- if (config_exists(var_name, "bandwidth"))
677
- d->do_io = config_get_boolean_ondemand(var_name, "bandwidth", ddo_io);
678
- if (config_exists(var_name, "operations"))
679
- d->do_ops = config_get_boolean_ondemand(var_name, "operations", ddo_ops);
680
- if (config_exists(var_name, "merged operations"))
681
- d->do_mops = config_get_boolean_ondemand(var_name, "merged operations", ddo_mops);
682
- if (config_exists(var_name, "i/o time"))
683
- d->do_iotime = config_get_boolean_ondemand(var_name, "i/o time", ddo_iotime);
684
- if (config_exists(var_name, "queued operations"))
685
- d->do_qops = config_get_boolean_ondemand(var_name, "queued operations", ddo_qops);
686
- if (config_exists(var_name, "utilization percentage"))
687
- d->do_util = config_get_boolean_ondemand(var_name, "utilization percentage", ddo_util);
688
- if (config_exists(var_name, "extended operations"))
689
- d->do_ext = config_get_boolean_ondemand(var_name, "extended operations", ddo_ext);
690
- if (config_exists(var_name, "backlog"))
691
- d->do_backlog = config_get_boolean_ondemand(var_name, "backlog", ddo_backlog);
676
+ if (inicfg_exists(&netdata_config, var_name, "bandwidth"))
677
+ d->do_io = inicfg_get_boolean_ondemand(&netdata_config, var_name, "bandwidth", ddo_io);
678
+ if (inicfg_exists(&netdata_config, var_name, "operations"))
679
+ d->do_ops = inicfg_get_boolean_ondemand(&netdata_config, var_name, "operations", ddo_ops);
680
+ if (inicfg_exists(&netdata_config, var_name, "merged operations"))
681
+ d->do_mops = inicfg_get_boolean_ondemand(&netdata_config, var_name, "merged operations", ddo_mops);
682
+ if (inicfg_exists(&netdata_config, var_name, "i/o time"))
683
+ d->do_iotime = inicfg_get_boolean_ondemand(&netdata_config, var_name, "i/o time", ddo_iotime);
684
+ if (inicfg_exists(&netdata_config, var_name, "queued operations"))
685
+ d->do_qops = inicfg_get_boolean_ondemand(&netdata_config, var_name, "queued operations", ddo_qops);
686
+ if (inicfg_exists(&netdata_config, var_name, "utilization percentage"))
687
+ d->do_util = inicfg_get_boolean_ondemand(&netdata_config, var_name, "utilization percentage", ddo_util);
688
+ if (inicfg_exists(&netdata_config, var_name, "extended operations"))
689
+ d->do_ext = inicfg_get_boolean_ondemand(&netdata_config, var_name, "extended operations", ddo_ext);
690
+ if (inicfg_exists(&netdata_config, var_name, "backlog"))
691
+ d->do_backlog = inicfg_get_boolean_ondemand(&netdata_config, var_name, "backlog", ddo_backlog);
692
693
d->do_bcache = ddo_bcache;
694
695
if (d->device_is_bcache) {
696
- if (config_exists(var_name, "bcache"))
697
- d->do_bcache = config_get_boolean_ondemand(var_name, "bcache", ddo_bcache);
696
+ if (inicfg_exists(&netdata_config, var_name, "bcache"))
697
+ d->do_bcache = inicfg_get_boolean_ondemand(&netdata_config, var_name, "bcache", ddo_bcache);
698
} else {
699
d->do_bcache = 0;
700
}
@@ -1339,64 +1339,64 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1339
if(unlikely(!globals_initialized)) {
1340
globals_initialized = 1;
1341
1342
- global_enable_new_disks_detected_at_runtime = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "enable new disks detected at runtime", global_enable_new_disks_detected_at_runtime);
1343
- global_enable_performance_for_physical_disks = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "performance metrics for physical disks", global_enable_performance_for_physical_disks);
1344
- global_enable_performance_for_virtual_disks = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "performance metrics for virtual disks", global_enable_performance_for_virtual_disks);
1345
- global_enable_performance_for_partitions = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "performance metrics for partitions", global_enable_performance_for_partitions);
1342
+ global_enable_new_disks_detected_at_runtime = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "enable new disks detected at runtime", global_enable_new_disks_detected_at_runtime);
1343
+ global_enable_performance_for_physical_disks = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "performance metrics for physical disks", global_enable_performance_for_physical_disks);
1344
+ global_enable_performance_for_virtual_disks = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "performance metrics for virtual disks", global_enable_performance_for_virtual_disks);
1345
+ global_enable_performance_for_partitions = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "performance metrics for partitions", global_enable_performance_for_partitions);
1346
1347
- global_do_io = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bandwidth for all disks", global_do_io);
1348
- global_do_ops = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "operations for all disks", global_do_ops);
1349
- global_do_mops = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "merged operations for all disks", global_do_mops);
1350
- global_do_iotime = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "i/o time for all disks", global_do_iotime);
1351
- global_do_qops = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "queued operations for all disks", global_do_qops);
1352
- global_do_util = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "utilization percentage for all disks", global_do_util);
1353
- global_do_ext = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "extended operations for all disks", global_do_ext);
1354
- global_do_backlog = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "backlog for all disks", global_do_backlog);
1355
- global_do_bcache = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache for all disks", global_do_bcache);
1356
- global_bcache_priority_stats_update_every = (int)config_get_duration_seconds(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache priority stats update every", global_bcache_priority_stats_update_every);
1347
+ global_do_io = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bandwidth for all disks", global_do_io);
1348
+ global_do_ops = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "operations for all disks", global_do_ops);
1349
+ global_do_mops = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "merged operations for all disks", global_do_mops);
1350
+ global_do_iotime = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "i/o time for all disks", global_do_iotime);
1351
+ global_do_qops = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "queued operations for all disks", global_do_qops);
1352
+ global_do_util = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "utilization percentage for all disks", global_do_util);
1353
+ global_do_ext = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "extended operations for all disks", global_do_ext);
1354
+ global_do_backlog = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "backlog for all disks", global_do_backlog);
1355
+ global_do_bcache = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache for all disks", global_do_bcache);
1356
+ global_bcache_priority_stats_update_every = (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "bcache priority stats update every", global_bcache_priority_stats_update_every);
1357
1358
- global_cleanup_removed_disks = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "remove charts of removed disks" , global_cleanup_removed_disks);
1358
+ global_cleanup_removed_disks = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "remove charts of removed disks" , global_cleanup_removed_disks);
1359
1360
char buffer[FILENAME_MAX + 1];
1361
1362
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/block/%s");
1363
- path_to_sys_block_device = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get block device", buffer);
1363
+ path_to_sys_block_device = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get block device", buffer);
1364
1365
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/block/%s/bcache");
1366
- path_to_sys_block_device_bcache = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get block device bcache", buffer);
1366
+ path_to_sys_block_device_bcache = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get block device bcache", buffer);
1367
1368
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/virtual/block/%s");
1369
- path_to_sys_devices_virtual_block_device = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get virtual block device", buffer);
1369
+ path_to_sys_devices_virtual_block_device = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get virtual block device", buffer);
1370
1371
snprintfz(buffer, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/dev/block/%lu:%lu/%s");
1372
- path_to_sys_dev_block_major_minor_string = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get block device infos", buffer);
1372
+ path_to_sys_dev_block_major_minor_string = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to get block device infos", buffer);
1373
1374
snprintfz(buffer, FILENAME_MAX, "%s/dev/mapper", netdata_configured_host_prefix);
1375
- path_to_device_mapper = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to device mapper", buffer);
1375
+ path_to_device_mapper = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to device mapper", buffer);
1376
1377
snprintfz(buffer, FILENAME_MAX, "%s/dev/disk", netdata_configured_host_prefix);
1378
- path_to_dev_disk = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/disk", buffer);
1378
+ path_to_dev_disk = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/disk", buffer);
1379
1380
snprintfz(buffer, FILENAME_MAX, "%s/sys/block", netdata_configured_host_prefix);
1381
- path_to_sys_block = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /sys/block", buffer);
1381
+ path_to_sys_block = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /sys/block", buffer);
1382
1383
snprintfz(buffer, FILENAME_MAX, "%s/dev/disk/by-label", netdata_configured_host_prefix);
1384
- path_to_device_label = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/disk/by-label", buffer);
1384
+ path_to_device_label = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/disk/by-label", buffer);
1385
1386
snprintfz(buffer, FILENAME_MAX, "%s/dev/disk/by-id", netdata_configured_host_prefix);
1387
- path_to_device_id = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/disk/by-id", buffer);
1387
+ path_to_device_id = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/disk/by-id", buffer);
1388
1389
snprintfz(buffer, FILENAME_MAX, "%s/dev/vx/dsk", netdata_configured_host_prefix);
1390
- path_to_veritas_volume_groups = config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/vx/dsk", buffer);
1390
+ path_to_veritas_volume_groups = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "path to /dev/vx/dsk", buffer);
1391
1392
- name_disks_by_id = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "name disks by id", name_disks_by_id);
1392
+ name_disks_by_id = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "name disks by id", name_disks_by_id);
1393
1394
preferred_ids = simple_pattern_create(
1395
- config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "preferred disk ids", DEFAULT_PREFERRED_IDS), NULL,
1395
+ inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "preferred disk ids", DEFAULT_PREFERRED_IDS), NULL,
1396
SIMPLE_PATTERN_EXACT, true);
1397
1398
excluded_disks = simple_pattern_create(
1399
- config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "exclude disks", DEFAULT_EXCLUDED_DISKS), NULL,
1399
+ inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "exclude disks", DEFAULT_EXCLUDED_DISKS), NULL,
1400
SIMPLE_PATTERN_EXACT, true);
1401
1402
rrd_function_add_inline(localhost, NULL, "block-devices", 10,
@@ -1411,7 +1411,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1411
if(unlikely(!ff)) {
1412
char filename[FILENAME_MAX + 1];
1413
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/diskstats");
1414
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
1414
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DISKSTATS, "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
1415
}
1416
if(unlikely(!ff)) return 0;
1417
src/collectors/proc.plugin/proc_interrupts.c
+2
-2
@@ -60,12 +60,12 @@ int do_proc_interrupts(int update_every, usec_t dt) {
60
struct interrupt *irrs = NULL;
61
62
if(unlikely(do_per_core == CONFIG_BOOLEAN_INVALID))
63
- do_per_core = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_INTERRUPTS, "interrupts per core", CONFIG_BOOLEAN_NO);
63
+ do_per_core = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_INTERRUPTS, "interrupts per core", CONFIG_BOOLEAN_NO);
64
65
if(unlikely(!ff)) {
66
char filename[FILENAME_MAX + 1];
67
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/interrupts");
68
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_INTERRUPTS, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
68
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_INTERRUPTS, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
69
}
70
if(unlikely(!ff))
71
return 1;
src/collectors/proc.plugin/proc_loadavg.c
+3
-3
@@ -17,7 +17,7 @@ int do_proc_loadavg(int update_every, usec_t dt) {
17
char filename[FILENAME_MAX + 1];
18
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/loadavg");
19
20
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_LOADAVG, "filename to monitor", filename), " \t,:|/", PROCFILE_FLAG_DEFAULT);
20
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_LOADAVG, "filename to monitor", filename), " \t,:|/", PROCFILE_FLAG_DEFAULT);
21
if(unlikely(!ff))
22
return 1;
23
}
@@ -27,8 +27,8 @@ int do_proc_loadavg(int update_every, usec_t dt) {
27
return 0; // we return 0, so that we will retry to open it next time
28
29
if(unlikely(do_loadavg == -1)) {
30
- do_loadavg = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_LOADAVG, "enable load average", 1);
31
- do_all_processes = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_LOADAVG, "enable total processes", 1);
30
+ do_loadavg = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_LOADAVG, "enable load average", 1);
31
+ do_all_processes = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_LOADAVG, "enable total processes", 1);
32
}
33
34
if(unlikely(procfile_lines(ff) < 1)) {
src/collectors/proc.plugin/proc_mdstat.c
+8
-8
@@ -99,26 +99,26 @@ int do_proc_mdstat(int update_every, usec_t dt)
99
100
if (unlikely(do_health == -1)) {
101
do_health =
102
- config_get_boolean("plugin:proc:/proc/mdstat", "faulty devices", CONFIG_BOOLEAN_YES);
102
+ inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/mdstat", "faulty devices", CONFIG_BOOLEAN_YES);
103
do_nonredundant =
104
- config_get_boolean("plugin:proc:/proc/mdstat", "nonredundant arrays availability", CONFIG_BOOLEAN_YES);
104
+ inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/mdstat", "nonredundant arrays availability", CONFIG_BOOLEAN_YES);
105
do_mismatch_config =
106
- config_get_boolean_ondemand("plugin:proc:/proc/mdstat", "mismatch count", CONFIG_BOOLEAN_AUTO);
106
+ inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/mdstat", "mismatch count", CONFIG_BOOLEAN_AUTO);
107
do_disks =
108
- config_get_boolean("plugin:proc:/proc/mdstat", "disk stats", CONFIG_BOOLEAN_YES);
108
+ inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/mdstat", "disk stats", CONFIG_BOOLEAN_YES);
109
do_operations =
110
- config_get_boolean("plugin:proc:/proc/mdstat", "operation status", CONFIG_BOOLEAN_YES);
110
+ inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/mdstat", "operation status", CONFIG_BOOLEAN_YES);
111
112
make_charts_obsolete =
113
- config_get_boolean("plugin:proc:/proc/mdstat", "make charts obsolete", CONFIG_BOOLEAN_YES);
113
+ inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/mdstat", "make charts obsolete", CONFIG_BOOLEAN_YES);
114
115
char filename[FILENAME_MAX + 1];
116
117
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/mdstat");
118
- mdstat_filename = config_get("plugin:proc:/proc/mdstat", "filename to monitor", filename);
118
+ mdstat_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/mdstat", "filename to monitor", filename);
119
120
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/block/%s/md/mismatch_cnt");
121
- mismatch_cnt_filename = config_get("plugin:proc:/proc/mdstat", "mismatch_cnt filename to monitor", filename);
121
+ mismatch_cnt_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/mdstat", "mismatch_cnt filename to monitor", filename);
122
}
123
124
if (unlikely(!ff)) {
src/collectors/proc.plugin/proc_meminfo.c
+14
-14
@@ -103,19 +103,19 @@ int do_proc_meminfo(int update_every, usec_t dt) {
103
;
104
105
if(unlikely(!arl_base)) {
106
- do_ram = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "system ram", CONFIG_BOOLEAN_YES);
107
- do_swap = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "system swap", CONFIG_BOOLEAN_AUTO);
108
- do_hwcorrupt = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "hardware corrupted ECC", CONFIG_BOOLEAN_AUTO);
109
- do_committed = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "committed memory", CONFIG_BOOLEAN_YES);
110
- do_writeback = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "writeback memory", CONFIG_BOOLEAN_YES);
111
- do_kernel = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "kernel memory", CONFIG_BOOLEAN_YES);
112
- do_slab = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "slab memory", CONFIG_BOOLEAN_YES);
113
- do_hugepages = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "hugepages", CONFIG_BOOLEAN_AUTO);
114
- do_transparent_hugepages = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "transparent hugepages", CONFIG_BOOLEAN_AUTO);
115
- do_reclaiming = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "memory reclaiming", CONFIG_BOOLEAN_AUTO);
116
- do_high_low = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "high low memory", CONFIG_BOOLEAN_AUTO);
117
- do_cma = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "cma memory", CONFIG_BOOLEAN_AUTO);
118
- do_directmap = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "direct maps", CONFIG_BOOLEAN_AUTO);
106
+ do_ram = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "system ram", CONFIG_BOOLEAN_YES);
107
+ do_swap = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "system swap", CONFIG_BOOLEAN_AUTO);
108
+ do_hwcorrupt = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "hardware corrupted ECC", CONFIG_BOOLEAN_AUTO);
109
+ do_committed = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "committed memory", CONFIG_BOOLEAN_YES);
110
+ do_writeback = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "writeback memory", CONFIG_BOOLEAN_YES);
111
+ do_kernel = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "kernel memory", CONFIG_BOOLEAN_YES);
112
+ do_slab = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "slab memory", CONFIG_BOOLEAN_YES);
113
+ do_hugepages = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "hugepages", CONFIG_BOOLEAN_AUTO);
114
+ do_transparent_hugepages = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "transparent hugepages", CONFIG_BOOLEAN_AUTO);
115
+ do_reclaiming = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "memory reclaiming", CONFIG_BOOLEAN_AUTO);
116
+ do_high_low = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "high low memory", CONFIG_BOOLEAN_AUTO);
117
+ do_cma = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "cma memory", CONFIG_BOOLEAN_AUTO);
118
+ do_directmap = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "direct maps", CONFIG_BOOLEAN_AUTO);
119
120
// https://github.com/torvalds/linux/blob/master/fs/proc/meminfo.c
121
@@ -214,7 +214,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
214
if(unlikely(!ff)) {
215
char filename[FILENAME_MAX + 1];
216
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/meminfo");
217
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
217
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_MEMINFO, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
218
if(unlikely(!ff))
219
return 1;
220
}
src/collectors/proc.plugin/proc_net_dev.c
+30
-30
@@ -903,10 +903,10 @@ int do_proc_net_dev(int update_every, usec_t dt) {
903
do_carrier = do_mtu = CONFIG_BOOLEAN_YES;
904
905
// only CSLIP, PPP
906
- do_compressed = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETDEV, "compressed packets for all interfaces", CONFIG_BOOLEAN_NO);
906
+ do_compressed = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETDEV, "compressed packets for all interfaces", CONFIG_BOOLEAN_NO);
907
908
disabled_list = simple_pattern_create(
909
- config_get(
909
+ inicfg_get(&netdata_config,
910
CONFIG_SECTION_PLUGIN_PROC_NETDEV,
911
"disable by default interfaces matching",
912
"lo fireqos* *-ifb fwpr* fwbr* fwln* ifb4*"),
@@ -1004,10 +1004,10 @@ int do_proc_net_dev(int update_every, usec_t dt) {
1004
1005
snprintfz(buf, FILENAME_MAX, "plugin:proc:/proc/net/dev:%s", d->name);
1006
1007
- if (config_exists(buf, "enabled"))
1008
- d->enabled = config_get_boolean_ondemand(buf, "enabled", d->enabled);
1009
- if (config_exists(buf, "virtual"))
1010
- d->virtual = config_get_boolean(buf, "virtual", d->virtual);
1007
+ if (inicfg_exists(&netdata_config, buf, "enabled"))
1008
+ d->enabled = inicfg_get_boolean_ondemand(&netdata_config, buf, "enabled", d->enabled);
1009
+ if (inicfg_exists(&netdata_config, buf, "virtual"))
1010
+ d->virtual = inicfg_get_boolean(&netdata_config, buf, "virtual", d->virtual);
1011
1012
if(d->enabled == CONFIG_BOOLEAN_NO)
1013
continue;
@@ -1025,30 +1025,30 @@ int do_proc_net_dev(int update_every, usec_t dt) {
1025
d->do_carrier = do_carrier;
1026
d->do_mtu = do_mtu;
1027
1028
- if (config_exists(buf, "bandwidth"))
1029
- d->do_bandwidth = config_get_boolean_ondemand(buf, "bandwidth", do_bandwidth);
1030
- if (config_exists(buf, "packets"))
1031
- d->do_packets = config_get_boolean_ondemand(buf, "packets", do_packets);
1032
- if (config_exists(buf, "errors"))
1033
- d->do_errors = config_get_boolean_ondemand(buf, "errors", do_errors);
1034
- if (config_exists(buf, "drops"))
1035
- d->do_drops = config_get_boolean_ondemand(buf, "drops", do_drops);
1036
- if (config_exists(buf, "fifo"))
1037
- d->do_fifo = config_get_boolean_ondemand(buf, "fifo", do_fifo);
1038
- if (config_exists(buf, "compressed"))
1039
- d->do_compressed = config_get_boolean_ondemand(buf, "compressed", do_compressed);
1040
- if (config_exists(buf, "events"))
1041
- d->do_events = config_get_boolean_ondemand(buf, "events", do_events);
1042
- if (config_exists(buf, "speed"))
1043
- d->do_speed = config_get_boolean_ondemand(buf, "speed", do_speed);
1044
- if (config_exists(buf, "duplex"))
1045
- d->do_duplex = config_get_boolean_ondemand(buf, "duplex", do_duplex);
1046
- if (config_exists(buf, "operstate"))
1047
- d->do_operstate = config_get_boolean_ondemand(buf, "operstate", do_operstate);
1048
- if (config_exists(buf, "carrier"))
1049
- d->do_carrier = config_get_boolean_ondemand(buf, "carrier", do_carrier);
1050
- if (config_exists(buf, "mtu"))
1051
- d->do_mtu = config_get_boolean_ondemand(buf, "mtu", do_mtu);
1028
+ if (inicfg_exists(&netdata_config, buf, "bandwidth"))
1029
+ d->do_bandwidth = inicfg_get_boolean_ondemand(&netdata_config, buf, "bandwidth", do_bandwidth);
1030
+ if (inicfg_exists(&netdata_config, buf, "packets"))
1031
+ d->do_packets = inicfg_get_boolean_ondemand(&netdata_config, buf, "packets", do_packets);
1032
+ if (inicfg_exists(&netdata_config, buf, "errors"))
1033
+ d->do_errors = inicfg_get_boolean_ondemand(&netdata_config, buf, "errors", do_errors);
1034
+ if (inicfg_exists(&netdata_config, buf, "drops"))
1035
+ d->do_drops = inicfg_get_boolean_ondemand(&netdata_config, buf, "drops", do_drops);
1036
+ if (inicfg_exists(&netdata_config, buf, "fifo"))
1037
+ d->do_fifo = inicfg_get_boolean_ondemand(&netdata_config, buf, "fifo", do_fifo);
1038
+ if (inicfg_exists(&netdata_config, buf, "compressed"))
1039
+ d->do_compressed = inicfg_get_boolean_ondemand(&netdata_config, buf, "compressed", do_compressed);
1040
+ if (inicfg_exists(&netdata_config, buf, "events"))
1041
+ d->do_events = inicfg_get_boolean_ondemand(&netdata_config, buf, "events", do_events);
1042
+ if (inicfg_exists(&netdata_config, buf, "speed"))
1043
+ d->do_speed = inicfg_get_boolean_ondemand(&netdata_config, buf, "speed", do_speed);
1044
+ if (inicfg_exists(&netdata_config, buf, "duplex"))
1045
+ d->do_duplex = inicfg_get_boolean_ondemand(&netdata_config, buf, "duplex", do_duplex);
1046
+ if (inicfg_exists(&netdata_config, buf, "operstate"))
1047
+ d->do_operstate = inicfg_get_boolean_ondemand(&netdata_config, buf, "operstate", do_operstate);
1048
+ if (inicfg_exists(&netdata_config, buf, "carrier"))
1049
+ d->do_carrier = inicfg_get_boolean_ondemand(&netdata_config, buf, "carrier", do_carrier);
1050
+ if (inicfg_exists(&netdata_config, buf, "mtu"))
1051
+ d->do_mtu = inicfg_get_boolean_ondemand(&netdata_config, buf, "mtu", do_mtu);
1052
}
1053
1054
if(unlikely(!d->enabled))
src/collectors/proc.plugin/proc_net_ip_vs_stats.c
+4
-4
@@ -11,14 +11,14 @@ int do_proc_net_ip_vs_stats(int update_every, usec_t dt) {
11
static int do_bandwidth = -1, do_sockets = -1, do_packets = -1;
12
static procfile *ff = NULL;
13
14
- if(do_bandwidth == -1) do_bandwidth = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "IPVS bandwidth", 1);
15
- if(do_sockets == -1) do_sockets = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "IPVS connections", 1);
16
- if(do_packets == -1) do_packets = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "IPVS packets", 1);
14
+ if(do_bandwidth == -1) do_bandwidth = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "IPVS bandwidth", 1);
15
+ if(do_sockets == -1) do_sockets = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "IPVS connections", 1);
16
+ if(do_packets == -1) do_packets = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "IPVS packets", 1);
17
18
if(!ff) {
19
char filename[FILENAME_MAX + 1];
20
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/ip_vs_stats");
21
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
21
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NET_IPVS, "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
22
}
23
if(!ff) return 1;
24
src/collectors/proc.plugin/proc_net_netstat.c
+53
-53
@@ -221,28 +221,28 @@ static void do_proc_net_snmp6(int update_every) {
221
// prepare for /proc/net/snmp6 parsing
222
223
if(unlikely(!arl_ipv6)) {
224
- do_ip6_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_BOOLEAN_AUTO);
225
- do_ip6_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO);
226
- do_ip6_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO);
227
- do_ip6_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_BOOLEAN_AUTO);
228
- do_ip6_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_BOOLEAN_AUTO);
229
- do_ip6_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_BOOLEAN_AUTO);
230
- do_ip6_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_BOOLEAN_AUTO);
231
- do_ip6_udplite_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_BOOLEAN_AUTO);
232
- do_ip6_bandwidth = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_BOOLEAN_AUTO);
233
- do_ip6_mcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_BOOLEAN_AUTO);
234
- do_ip6_bcast = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_BOOLEAN_AUTO);
235
- do_ip6_mcast_p = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_BOOLEAN_AUTO);
236
- do_ip6_icmp = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp", CONFIG_BOOLEAN_AUTO);
237
- do_ip6_icmp_redir = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_BOOLEAN_AUTO);
238
- do_ip6_icmp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_BOOLEAN_AUTO);
239
- do_ip6_icmp_echos = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_BOOLEAN_AUTO);
240
- do_ip6_icmp_groupmemb = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_BOOLEAN_AUTO);
241
- do_ip6_icmp_router = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_BOOLEAN_AUTO);
242
- do_ip6_icmp_neighbor = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_BOOLEAN_AUTO);
243
- do_ip6_icmp_mldv2 = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_BOOLEAN_AUTO);
244
- do_ip6_icmp_types = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_BOOLEAN_AUTO);
245
- do_ip6_ect = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp6", "ect", CONFIG_BOOLEAN_AUTO);
224
+ do_ip6_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 packets", CONFIG_BOOLEAN_AUTO);
225
+ do_ip6_fragsout = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 fragments sent", CONFIG_BOOLEAN_AUTO);
226
+ do_ip6_fragsin = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 fragments assembly", CONFIG_BOOLEAN_AUTO);
227
+ do_ip6_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 errors", CONFIG_BOOLEAN_AUTO);
228
+ do_ip6_udp_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 UDP packets", CONFIG_BOOLEAN_AUTO);
229
+ do_ip6_udp_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 UDP errors", CONFIG_BOOLEAN_AUTO);
230
+ do_ip6_udplite_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 UDPlite packets", CONFIG_BOOLEAN_AUTO);
231
+ do_ip6_udplite_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ipv6 UDPlite errors", CONFIG_BOOLEAN_AUTO);
232
+ do_ip6_bandwidth = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "bandwidth", CONFIG_BOOLEAN_AUTO);
233
+ do_ip6_mcast = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "multicast bandwidth", CONFIG_BOOLEAN_AUTO);
234
+ do_ip6_bcast = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "broadcast bandwidth", CONFIG_BOOLEAN_AUTO);
235
+ do_ip6_mcast_p = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "multicast packets", CONFIG_BOOLEAN_AUTO);
236
+ do_ip6_icmp = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp", CONFIG_BOOLEAN_AUTO);
237
+ do_ip6_icmp_redir = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp redirects", CONFIG_BOOLEAN_AUTO);
238
+ do_ip6_icmp_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp errors", CONFIG_BOOLEAN_AUTO);
239
+ do_ip6_icmp_echos = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp echos", CONFIG_BOOLEAN_AUTO);
240
+ do_ip6_icmp_groupmemb = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp group membership", CONFIG_BOOLEAN_AUTO);
241
+ do_ip6_icmp_router = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp router", CONFIG_BOOLEAN_AUTO);
242
+ do_ip6_icmp_neighbor = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp neighbor", CONFIG_BOOLEAN_AUTO);
243
+ do_ip6_icmp_mldv2 = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp mldv2", CONFIG_BOOLEAN_AUTO);
244
+ do_ip6_icmp_types = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "icmp types", CONFIG_BOOLEAN_AUTO);
245
+ do_ip6_ect = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp6", "ect", CONFIG_BOOLEAN_AUTO);
246
247
arl_ipv6 = arl_create("snmp6", NULL, 60);
248
arl_expect(arl_ipv6, "Ip6InReceives", &Ip6InReceives);
@@ -345,7 +345,7 @@ static void do_proc_net_snmp6(int update_every) {
345
char filename[FILENAME_MAX + 1];
346
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp6");
347
ff_snmp6 = procfile_open(
348
- config_get("plugin:proc:/proc/net/snmp6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
348
+ inicfg_get(&netdata_config, "plugin:proc:/proc/net/snmp6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
349
if (unlikely(!ff_snmp6)) {
350
do_snmp6 = false;
351
return;
@@ -1306,22 +1306,22 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
1306
hash_ipext = simple_hash("IpExt");
1307
hash_tcpext = simple_hash("TcpExt");
1308
1309
- do_bandwidth = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "bandwidth", CONFIG_BOOLEAN_AUTO);
1310
- do_inerrors = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "input errors", CONFIG_BOOLEAN_AUTO);
1311
- do_mcast = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "multicast bandwidth", CONFIG_BOOLEAN_AUTO);
1312
- do_bcast = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "broadcast bandwidth", CONFIG_BOOLEAN_AUTO);
1313
- do_mcast_p = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "multicast packets", CONFIG_BOOLEAN_AUTO);
1314
- do_bcast_p = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "broadcast packets", CONFIG_BOOLEAN_AUTO);
1315
- do_ecn = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "ECN packets", CONFIG_BOOLEAN_AUTO);
1309
+ do_bandwidth = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "bandwidth", CONFIG_BOOLEAN_AUTO);
1310
+ do_inerrors = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "input errors", CONFIG_BOOLEAN_AUTO);
1311
+ do_mcast = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "multicast bandwidth", CONFIG_BOOLEAN_AUTO);
1312
+ do_bcast = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "broadcast bandwidth", CONFIG_BOOLEAN_AUTO);
1313
+ do_mcast_p = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "multicast packets", CONFIG_BOOLEAN_AUTO);
1314
+ do_bcast_p = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "broadcast packets", CONFIG_BOOLEAN_AUTO);
1315
+ do_ecn = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "ECN packets", CONFIG_BOOLEAN_AUTO);
1316
1317
- do_tcpext_reorder = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP reorders", CONFIG_BOOLEAN_AUTO);
1318
- do_tcpext_syscookies = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP SYN cookies", CONFIG_BOOLEAN_AUTO);
1319
- do_tcpext_ofo = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP out-of-order queue", CONFIG_BOOLEAN_AUTO);
1320
- do_tcpext_connaborts = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP connection aborts", CONFIG_BOOLEAN_AUTO);
1321
- do_tcpext_memory = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP memory pressures", CONFIG_BOOLEAN_AUTO);
1317
+ do_tcpext_reorder = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP reorders", CONFIG_BOOLEAN_AUTO);
1318
+ do_tcpext_syscookies = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP SYN cookies", CONFIG_BOOLEAN_AUTO);
1319
+ do_tcpext_ofo = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP out-of-order queue", CONFIG_BOOLEAN_AUTO);
1320
+ do_tcpext_connaborts = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP connection aborts", CONFIG_BOOLEAN_AUTO);
1321
+ do_tcpext_memory = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP memory pressures", CONFIG_BOOLEAN_AUTO);
1322
1323
- do_tcpext_syn_queue = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP SYN queue", CONFIG_BOOLEAN_AUTO);
1324
- do_tcpext_accept_queue = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP accept queue", CONFIG_BOOLEAN_AUTO);
1323
+ do_tcpext_syn_queue = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP SYN queue", CONFIG_BOOLEAN_AUTO);
1324
+ do_tcpext_accept_queue = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "TCP accept queue", CONFIG_BOOLEAN_AUTO);
1325
1326
arl_ipext = arl_create("netstat/ipext", NULL, 60);
1327
arl_tcpext = arl_create("netstat/tcpext", NULL, 60);
@@ -1419,20 +1419,20 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
1419
// prepare for /proc/net/snmp parsing
1420
1421
if(unlikely(!arl_ip)) {
1422
- do_ip_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 packets", CONFIG_BOOLEAN_AUTO);
1423
- do_ip_fragsout = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments sent", CONFIG_BOOLEAN_AUTO);
1424
- do_ip_fragsin = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", CONFIG_BOOLEAN_AUTO);
1425
- do_ip_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 errors", CONFIG_BOOLEAN_AUTO);
1426
- do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP connections", CONFIG_BOOLEAN_AUTO);
1427
- do_tcp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP packets", CONFIG_BOOLEAN_AUTO);
1428
- do_tcp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP errors", CONFIG_BOOLEAN_AUTO);
1429
- do_tcp_opens = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP opens", CONFIG_BOOLEAN_AUTO);
1430
- do_tcp_handshake = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", CONFIG_BOOLEAN_AUTO);
1431
- do_udp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP packets", CONFIG_BOOLEAN_AUTO);
1432
- do_udp_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDP errors", CONFIG_BOOLEAN_AUTO);
1433
- do_icmp_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", CONFIG_BOOLEAN_AUTO);
1434
- do_icmpmsg = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", CONFIG_BOOLEAN_AUTO);
1435
- do_udplite_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", CONFIG_BOOLEAN_AUTO);
1422
+ do_ip_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 packets", CONFIG_BOOLEAN_AUTO);
1423
+ do_ip_fragsout = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 fragments sent", CONFIG_BOOLEAN_AUTO);
1424
+ do_ip_fragsin = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 fragments assembly", CONFIG_BOOLEAN_AUTO);
1425
+ do_ip_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 errors", CONFIG_BOOLEAN_AUTO);
1426
+ do_tcp_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 TCP connections", CONFIG_BOOLEAN_AUTO);
1427
+ do_tcp_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 TCP packets", CONFIG_BOOLEAN_AUTO);
1428
+ do_tcp_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 TCP errors", CONFIG_BOOLEAN_AUTO);
1429
+ do_tcp_opens = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 TCP opens", CONFIG_BOOLEAN_AUTO);
1430
+ do_tcp_handshake = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 TCP handshake issues", CONFIG_BOOLEAN_AUTO);
1431
+ do_udp_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 UDP packets", CONFIG_BOOLEAN_AUTO);
1432
+ do_udp_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 UDP errors", CONFIG_BOOLEAN_AUTO);
1433
+ do_icmp_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 ICMP packets", CONFIG_BOOLEAN_AUTO);
1434
+ do_icmpmsg = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 ICMP messages", CONFIG_BOOLEAN_AUTO);
1435
+ do_udplite_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/snmp", "ipv4 UDPLite packets", CONFIG_BOOLEAN_AUTO);
1436
1437
hash_ip = simple_hash("Ip");
1438
hash_tcp = simple_hash("Tcp");
@@ -1538,7 +1538,7 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
1538
if(unlikely(!ff_netstat)) {
1539
char filename[FILENAME_MAX + 1];
1540
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/netstat");
1541
- ff_netstat = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
1541
+ ff_netstat = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETSTAT, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
1542
if(unlikely(!ff_netstat)) return 1;
1543
}
1544
@@ -1584,7 +1584,7 @@ int do_proc_net_netstat(int update_every, usec_t dt) {
1584
if(unlikely(!ff_snmp)) {
1585
char filename[FILENAME_MAX + 1];
1586
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/snmp");
1587
- ff_snmp = procfile_open(config_get("plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
1587
+ ff_snmp = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
1588
if(unlikely(!ff_snmp)) return 1;
1589
}
1590
src/collectors/proc.plugin/proc_net_rpc_nfs.c
+6
-6
@@ -148,18 +148,18 @@ int do_proc_net_rpc_nfs(int update_every, usec_t dt) {
148
if(!ff) {
149
char filename[FILENAME_MAX + 1];
150
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/rpc/nfs");
151
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_NFS, "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
151
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NFS, "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
152
}
153
if(!ff) return 1;
154
155
ff = procfile_readall(ff);
156
if(!ff) return 0; // we return 0, so that we will retry to open it next time
157
158
- if(do_net == -1) do_net = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NFS, "network", 1);
159
- if(do_rpc == -1) do_rpc = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NFS, "rpc", 1);
160
- if(do_proc2 == -1) do_proc2 = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NFS, "NFS v2 procedures", 1);
161
- if(do_proc3 == -1) do_proc3 = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NFS, "NFS v3 procedures", 1);
162
- if(do_proc4 == -1) do_proc4 = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_NFS, "NFS v4 procedures", 1);
158
+ if(do_net == -1) do_net = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NFS, "network", 1);
159
+ if(do_rpc == -1) do_rpc = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NFS, "rpc", 1);
160
+ if(do_proc2 == -1) do_proc2 = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NFS, "NFS v2 procedures", 1);
161
+ if(do_proc3 == -1) do_proc3 = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NFS, "NFS v3 procedures", 1);
162
+ if(do_proc4 == -1) do_proc4 = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NFS, "NFS v4 procedures", 1);
163
164
// if they are enabled, reset them to 1
165
// later we do them =2 to avoid doing strcmp() for all lines
src/collectors/proc.plugin/proc_net_rpc_nfsd.c
+11
-11
@@ -231,7 +231,7 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
231
if(unlikely(!ff)) {
232
char filename[FILENAME_MAX + 1];
233
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/rpc/nfsd");
234
- ff = procfile_open(config_get("plugin:proc:/proc/net/rpc/nfsd", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
234
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
235
if(unlikely(!ff)) return 1;
236
}
237
@@ -239,16 +239,16 @@ int do_proc_net_rpc_nfsd(int update_every, usec_t dt) {
239
if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
240
241
if(unlikely(do_rc == -1)) {
242
- do_rc = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "read cache", 1);
243
- do_fh = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "file handles", 1);
244
- do_io = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "I/O", 1);
245
- do_th = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "threads", 1);
246
- do_net = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "network", 1);
247
- do_rpc = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "rpc", 1);
248
- do_proc2 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v2 procedures", 1);
249
- do_proc3 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v3 procedures", 1);
250
- do_proc4 = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v4 procedures", 1);
251
- do_proc4ops = config_get_boolean("plugin:proc:/proc/net/rpc/nfsd", "NFS v4 operations", 1);
242
+ do_rc = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "read cache", 1);
243
+ do_fh = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "file handles", 1);
244
+ do_io = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "I/O", 1);
245
+ do_th = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "threads", 1);
246
+ do_net = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "network", 1);
247
+ do_rpc = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "rpc", 1);
248
+ do_proc2 = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "NFS v2 procedures", 1);
249
+ do_proc3 = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "NFS v3 procedures", 1);
250
+ do_proc4 = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "NFS v4 procedures", 1);
251
+ do_proc4ops = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/rpc/nfsd", "NFS v4 operations", 1);
252
}
253
254
// if they are enabled, reset them to 1
src/collectors/proc.plugin/proc_net_sctp_snmp.c
+7
-7
@@ -52,12 +52,12 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) {
52
static unsigned long long SctpInDataChunkDiscards = 0ULL;
53
54
if(unlikely(!arl_base)) {
55
- do_associations = config_get_boolean_ondemand("plugin:proc:/proc/net/sctp/snmp", "established associations", CONFIG_BOOLEAN_AUTO);
56
- do_transitions = config_get_boolean_ondemand("plugin:proc:/proc/net/sctp/snmp", "association transitions", CONFIG_BOOLEAN_AUTO);
57
- do_fragmentation = config_get_boolean_ondemand("plugin:proc:/proc/net/sctp/snmp", "fragmentation", CONFIG_BOOLEAN_AUTO);
58
- do_packets = config_get_boolean_ondemand("plugin:proc:/proc/net/sctp/snmp", "packets", CONFIG_BOOLEAN_AUTO);
59
- do_packet_errors = config_get_boolean_ondemand("plugin:proc:/proc/net/sctp/snmp", "packet errors", CONFIG_BOOLEAN_AUTO);
60
- do_chunk_types = config_get_boolean_ondemand("plugin:proc:/proc/net/sctp/snmp", "chunk types", CONFIG_BOOLEAN_AUTO);
55
+ do_associations = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "established associations", CONFIG_BOOLEAN_AUTO);
56
+ do_transitions = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "association transitions", CONFIG_BOOLEAN_AUTO);
57
+ do_fragmentation = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "fragmentation", CONFIG_BOOLEAN_AUTO);
58
+ do_packets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "packets", CONFIG_BOOLEAN_AUTO);
59
+ do_packet_errors = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "packet errors", CONFIG_BOOLEAN_AUTO);
60
+ do_chunk_types = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "chunk types", CONFIG_BOOLEAN_AUTO);
61
62
arl_base = arl_create("sctp", NULL, 60);
63
arl_expect(arl_base, "SctpCurrEstab", &SctpCurrEstab);
@@ -97,7 +97,7 @@ int do_proc_net_sctp_snmp(int update_every, usec_t dt) {
97
if(unlikely(!ff)) {
98
char filename[FILENAME_MAX + 1];
99
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/sctp/snmp");
100
- ff = procfile_open(config_get("plugin:proc:/proc/net/sctp/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
100
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/sctp/snmp", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
101
if(unlikely(!ff))
102
return 1;
103
}
src/collectors/proc.plugin/proc_net_sockstat.c
+12
-12
@@ -118,17 +118,17 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
118
static ARL_BASE *bases[7] = { NULL };
119
120
if(unlikely(!arl_sockets)) {
121
- do_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 sockets", CONFIG_BOOLEAN_AUTO);
122
- do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 TCP sockets", CONFIG_BOOLEAN_AUTO);
123
- do_tcp_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 TCP memory", CONFIG_BOOLEAN_AUTO);
124
- do_udp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 UDP sockets", CONFIG_BOOLEAN_AUTO);
125
- do_udp_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 UDP memory", CONFIG_BOOLEAN_AUTO);
126
- do_udplite_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 UDPLITE sockets", CONFIG_BOOLEAN_AUTO);
127
- do_raw_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 RAW sockets", CONFIG_BOOLEAN_AUTO);
128
- do_frag_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG sockets", CONFIG_BOOLEAN_AUTO);
129
- do_frag_mem = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat", "ipv4 FRAG memory", CONFIG_BOOLEAN_AUTO);
130
-
131
- update_constants_every = config_get_duration_seconds("plugin:proc:/proc/net/sockstat", "update constants every", update_constants_every);
121
+ do_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 sockets", CONFIG_BOOLEAN_AUTO);
122
+ do_tcp_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 TCP sockets", CONFIG_BOOLEAN_AUTO);
123
+ do_tcp_mem = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 TCP memory", CONFIG_BOOLEAN_AUTO);
124
+ do_udp_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 UDP sockets", CONFIG_BOOLEAN_AUTO);
125
+ do_udp_mem = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 UDP memory", CONFIG_BOOLEAN_AUTO);
126
+ do_udplite_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 UDPLITE sockets", CONFIG_BOOLEAN_AUTO);
127
+ do_raw_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 RAW sockets", CONFIG_BOOLEAN_AUTO);
128
+ do_frag_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 FRAG sockets", CONFIG_BOOLEAN_AUTO);
129
+ do_frag_mem = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat", "ipv4 FRAG memory", CONFIG_BOOLEAN_AUTO);
130
+
131
+ update_constants_every = inicfg_get_duration_seconds(&netdata_config, "plugin:proc:/proc/net/sockstat", "update constants every", update_constants_every);
132
update_constants_count = update_constants_every;
133
134
arl_sockets = arl_create("sockstat/sockets", arl_callback_str2kernel_uint_t, 60);
@@ -181,7 +181,7 @@ int do_proc_net_sockstat(int update_every, usec_t dt) {
181
if(unlikely(!ff)) {
182
char filename[FILENAME_MAX + 1];
183
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/sockstat");
184
- ff = procfile_open(config_get("plugin:proc:/proc/net/sockstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
184
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/sockstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
185
if(unlikely(!ff)) return 1;
186
}
187
src/collectors/proc.plugin/proc_net_sockstat6.c
+6
-6
@@ -36,11 +36,11 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) {
36
static ARL_BASE *bases[6] = { NULL };
37
38
if(unlikely(!arl_tcp)) {
39
- do_tcp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat6", "ipv6 TCP sockets", CONFIG_BOOLEAN_AUTO);
40
- do_udp_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat6", "ipv6 UDP sockets", CONFIG_BOOLEAN_AUTO);
41
- do_udplite_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat6", "ipv6 UDPLITE sockets", CONFIG_BOOLEAN_AUTO);
42
- do_raw_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat6", "ipv6 RAW sockets", CONFIG_BOOLEAN_AUTO);
43
- do_frag_sockets = config_get_boolean_ondemand("plugin:proc:/proc/net/sockstat6", "ipv6 FRAG sockets", CONFIG_BOOLEAN_AUTO);
39
+ do_tcp_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat6", "ipv6 TCP sockets", CONFIG_BOOLEAN_AUTO);
40
+ do_udp_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat6", "ipv6 UDP sockets", CONFIG_BOOLEAN_AUTO);
41
+ do_udplite_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat6", "ipv6 UDPLITE sockets", CONFIG_BOOLEAN_AUTO);
42
+ do_raw_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat6", "ipv6 RAW sockets", CONFIG_BOOLEAN_AUTO);
43
+ do_frag_sockets = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/sockstat6", "ipv6 FRAG sockets", CONFIG_BOOLEAN_AUTO);
44
45
arl_tcp = arl_create("sockstat6/TCP6", arl_callback_str2kernel_uint_t, 60);
46
arl_expect(arl_tcp, "inuse", &sockstat6_root.tcp6_inuse);
@@ -74,7 +74,7 @@ int do_proc_net_sockstat6(int update_every, usec_t dt) {
74
if(unlikely(!ff)) {
75
char filename[FILENAME_MAX + 1];
76
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/sockstat6");
77
- ff = procfile_open(config_get("plugin:proc:/proc/net/sockstat6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
77
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/sockstat6", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
78
if(unlikely(!ff)) return 1;
79
}
80
src/collectors/proc.plugin/proc_net_softnet_stat.c
+2
-2
@@ -26,13 +26,13 @@ int do_proc_net_softnet_stat(int update_every, usec_t dt) {
26
27
if (unlikely(do_per_core == -1)) {
28
do_per_core =
29
- config_get_boolean("plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", CONFIG_BOOLEAN_NO);
29
+ inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/softnet_stat", "softnet_stat per core", CONFIG_BOOLEAN_NO);
30
}
31
32
if(unlikely(!ff)) {
33
char filename[FILENAME_MAX + 1];
34
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/softnet_stat");
35
- ff = procfile_open(config_get("plugin:proc:/proc/net/softnet_stat", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
35
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/softnet_stat", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT);
36
if(unlikely(!ff)) return 1;
37
}
38
src/collectors/proc.plugin/proc_net_stat_conntrack.c
+10
-10
@@ -20,32 +20,32 @@ int do_proc_net_stat_conntrack(int update_every, usec_t dt) {
20
if(unlikely(do_sockets == -1)) {
21
char filename[FILENAME_MAX + 1];
22
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/stat/nf_conntrack");
23
- nf_conntrack_filename = config_get("plugin:proc:/proc/net/stat/nf_conntrack", "filename to monitor", filename);
23
+ nf_conntrack_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "filename to monitor", filename);
24
25
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sys/net/netfilter/nf_conntrack_max");
26
- nf_conntrack_max_filename = config_get("plugin:proc:/proc/sys/net/netfilter/nf_conntrack_max", "filename to monitor", filename);
27
- usec_since_last_max = get_max_every = config_get_number("plugin:proc:/proc/sys/net/netfilter/nf_conntrack_max", "read every seconds", 10) * USEC_PER_SEC;
26
+ nf_conntrack_max_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/sys/net/netfilter/nf_conntrack_max", "filename to monitor", filename);
27
+ usec_since_last_max = get_max_every = inicfg_get_number(&netdata_config, "plugin:proc:/proc/sys/net/netfilter/nf_conntrack_max", "read every seconds", 10) * USEC_PER_SEC;
28
29
read_full = 1;
30
ff = procfile_open(nf_conntrack_filename, " \t:", PROCFILE_FLAG_DEFAULT);
31
if(!ff) read_full = 0;
32
33
- do_new = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter new connections", read_full);
34
- do_changes = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection changes", read_full);
35
- do_expect = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection expectations", read_full);
36
- do_search = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection searches", read_full);
37
- do_errors = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter errors", read_full);
33
+ do_new = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "netfilter new connections", read_full);
34
+ do_changes = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection changes", read_full);
35
+ do_expect = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection expectations", read_full);
36
+ do_search = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connection searches", read_full);
37
+ do_errors = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "netfilter errors", read_full);
38
39
do_sockets = 1;
40
if(!read_full) {
41
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sys/net/netfilter/nf_conntrack_count");
42
- nf_conntrack_count_filename = config_get("plugin:proc:/proc/sys/net/netfilter/nf_conntrack_count", "filename to monitor", filename);
42
+ nf_conntrack_count_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/sys/net/netfilter/nf_conntrack_count", "filename to monitor", filename);
43
44
if(read_single_number_file(nf_conntrack_count_filename, &aentries))
45
do_sockets = 0;
46
}
47
48
- do_sockets = config_get_boolean("plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connections", do_sockets);
48
+ do_sockets = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/net/stat/nf_conntrack", "netfilter connections", do_sockets);
49
50
if(!do_sockets && !read_full)
51
return 1;
src/collectors/proc.plugin/proc_net_stat_synproxy.c
+4
-4
@@ -14,15 +14,15 @@ int do_proc_net_stat_synproxy(int update_every, usec_t dt) {
14
static procfile *ff = NULL;
15
16
if(unlikely(do_cookies == -1)) {
17
- do_cookies = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY cookies", CONFIG_BOOLEAN_AUTO);
18
- do_syns = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY SYN received", CONFIG_BOOLEAN_AUTO);
19
- do_reopened = config_get_boolean_ondemand("plugin:proc:/proc/net/stat/synproxy", "SYNPROXY connections reopened", CONFIG_BOOLEAN_AUTO);
17
+ do_cookies = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/stat/synproxy", "SYNPROXY cookies", CONFIG_BOOLEAN_AUTO);
18
+ do_syns = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/stat/synproxy", "SYNPROXY SYN received", CONFIG_BOOLEAN_AUTO);
19
+ do_reopened = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/net/stat/synproxy", "SYNPROXY connections reopened", CONFIG_BOOLEAN_AUTO);
20
}
21
22
if(unlikely(!ff)) {
23
char filename[FILENAME_MAX + 1];
24
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/stat/synproxy");
25
- ff = procfile_open(config_get("plugin:proc:/proc/net/stat/synproxy", "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
25
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/net/stat/synproxy", "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
26
if(unlikely(!ff))
27
return 1;
28
}
src/collectors/proc.plugin/proc_net_wireless.c
+5
-5
@@ -214,11 +214,11 @@ int do_proc_net_wireless(int update_every, usec_t dt)
214
char filename[FILENAME_MAX + 1];
215
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/wireless");
216
217
- proc_net_wireless_filename = config_get(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,"filename to monitor", filename);
218
- do_status = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "status for all interfaces", CONFIG_BOOLEAN_AUTO);
219
- do_quality = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "quality for all interfaces", CONFIG_BOOLEAN_AUTO);
220
- do_discarded_packets = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "discarded packets for all interfaces", CONFIG_BOOLEAN_AUTO);
221
- do_beacon = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "missed beacon for all interface", CONFIG_BOOLEAN_AUTO);
217
+ proc_net_wireless_filename = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS,"filename to monitor", filename);
218
+ do_status = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "status for all interfaces", CONFIG_BOOLEAN_AUTO);
219
+ do_quality = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "quality for all interfaces", CONFIG_BOOLEAN_AUTO);
220
+ do_discarded_packets = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "discarded packets for all interfaces", CONFIG_BOOLEAN_AUTO);
221
+ do_beacon = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_NETWIRELESS, "missed beacon for all interface", CONFIG_BOOLEAN_AUTO);
222
}
223
224
if (unlikely(!ff)) {
src/collectors/proc.plugin/proc_pagetypeinfo.c
+4
-4
@@ -90,7 +90,7 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) {
90
91
if(unlikely(!ff)) {
92
snprintfz(ff_path, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, PLUGIN_PROC_MODULE_PAGETYPEINFO_NAME);
93
- ff = procfile_open(config_get(CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "filename to monitor", ff_path), " \t:", PROCFILE_FLAG_DEFAULT);
93
+ ff = procfile_open(inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "filename to monitor", ff_path), " \t:", PROCFILE_FLAG_DEFAULT);
94
95
if(unlikely(!ff)) {
96
strncpyz(ff_path, PLUGIN_PROC_MODULE_PAGETYPEINFO_NAME, FILENAME_MAX);
@@ -117,10 +117,10 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) {
117
}
118
119
// Configuration
120
- do_global = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "enable system summary", CONFIG_BOOLEAN_YES);
121
- do_detail = config_get_boolean_ondemand(CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "enable detail per-type", CONFIG_BOOLEAN_AUTO);
120
+ do_global = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "enable system summary", CONFIG_BOOLEAN_YES);
121
+ do_detail = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "enable detail per-type", CONFIG_BOOLEAN_AUTO);
122
filter_types = simple_pattern_create(
123
- config_get(CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "hide charts id matching", ""), NULL,
123
+ inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PAGETYPEINFO, "hide charts id matching", ""), NULL,
124
SIMPLE_PATTERN_SUFFIX, true);
125
126
pagelines_cnt = 0;
src/collectors/proc.plugin/proc_pressure.c
+3
-3
@@ -171,7 +171,7 @@ int do_proc_pressure(int update_every, usec_t dt) {
171
}
172
173
if (unlikely(!base_path))
174
- base_path = config_get(CONFIG_SECTION_PLUGIN_PROC_PRESSURE, "base path of pressure metrics", "/proc/pressure");
174
+ base_path = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PRESSURE, "base path of pressure metrics", "/proc/pressure");
175
176
for (i = 0; i < PRESSURE_NUM_RESOURCES; i++) {
177
procfile *ff = resource_info[i].pf;
@@ -195,11 +195,11 @@ int do_proc_pressure(int update_every, usec_t dt) {
195
do_full = resources[i].full.available ? CONFIG_BOOLEAN_YES : CONFIG_BOOLEAN_NO;
196
197
snprintfz(config_key, CONFIG_MAX_NAME, "enable %s some pressure", resource_info[i].name);
198
- do_some = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_PRESSURE, config_key, do_some);
198
+ do_some = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PRESSURE, config_key, do_some);
199
resources[i].some.enabled = do_some;
200
201
snprintfz(config_key, CONFIG_MAX_NAME, "enable %s full pressure", resource_info[i].name);
202
- do_full = config_get_boolean(CONFIG_SECTION_PLUGIN_PROC_PRESSURE, config_key, do_full);
202
+ do_full = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_PRESSURE, config_key, do_full);
203
resources[i].full.enabled = do_full;
204
205
if (!do_full && !do_some) {
src/collectors/proc.plugin/proc_softirqs.c
+2
-2
@@ -59,12 +59,12 @@ int do_proc_softirqs(int update_every, usec_t dt) {
59
struct interrupt *irrs = NULL;
60
61
if(unlikely(do_per_core == CONFIG_BOOLEAN_INVALID))
62
- do_per_core = config_get_boolean_ondemand("plugin:proc:/proc/softirqs", "interrupts per core", CONFIG_BOOLEAN_NO);
62
+ do_per_core = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/softirqs", "interrupts per core", CONFIG_BOOLEAN_NO);
63
64
if(unlikely(!ff)) {
65
char filename[FILENAME_MAX + 1];
66
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/softirqs");
67
- ff = procfile_open(config_get("plugin:proc:/proc/softirqs", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
67
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/softirqs", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
68
if(unlikely(!ff)) return 1;
69
}
70
src/collectors/proc.plugin/proc_spl_kstat_zfs.c
+2
-2
@@ -124,12 +124,12 @@ int do_proc_spl_kstat_zfs_arcstats(int update_every, usec_t dt) {
124
if(unlikely(!ff)) {
125
char filename[FILENAME_MAX + 1];
126
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, ZFS_PROC_ARCSTATS);
127
- ff = procfile_open(config_get("plugin:proc:" ZFS_PROC_ARCSTATS, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
127
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:" ZFS_PROC_ARCSTATS, "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
128
if(unlikely(!ff))
129
return 1;
130
131
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/spl/kstat/zfs");
132
- dirname = config_get("plugin:proc:" ZFS_PROC_ARCSTATS, "directory to monitor", filename);
132
+ dirname = inicfg_get(&netdata_config, "plugin:proc:" ZFS_PROC_ARCSTATS, "directory to monitor", filename);
133
}
134
135
// check if any pools exist
src/collectors/proc.plugin/proc_stat.c
+20
-20
@@ -491,12 +491,12 @@ int do_proc_stat(int update_every, usec_t dt) {
491
size_t cores_found = (size_t)os_get_system_cpus();
492
493
if(unlikely(do_cpu == -1)) {
494
- do_cpu = config_get_boolean("plugin:proc:/proc/stat", "cpu utilization", CONFIG_BOOLEAN_YES);
495
- do_cpu_cores = config_get_boolean("plugin:proc:/proc/stat", "per cpu core utilization", CONFIG_BOOLEAN_NO);
496
- do_interrupts = config_get_boolean("plugin:proc:/proc/stat", "cpu interrupts", CONFIG_BOOLEAN_YES);
497
- do_context = config_get_boolean("plugin:proc:/proc/stat", "context switches", CONFIG_BOOLEAN_YES);
498
- do_forks = config_get_boolean("plugin:proc:/proc/stat", "processes started", CONFIG_BOOLEAN_YES);
499
- do_processes = config_get_boolean("plugin:proc:/proc/stat", "processes running", CONFIG_BOOLEAN_YES);
494
+ do_cpu = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "cpu utilization", CONFIG_BOOLEAN_YES);
495
+ do_cpu_cores = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "per cpu core utilization", CONFIG_BOOLEAN_NO);
496
+ do_interrupts = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "cpu interrupts", CONFIG_BOOLEAN_YES);
497
+ do_context = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "context switches", CONFIG_BOOLEAN_YES);
498
+ do_forks = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "processes started", CONFIG_BOOLEAN_YES);
499
+ do_processes = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "processes running", CONFIG_BOOLEAN_YES);
500
501
// give sane defaults based on the number of processors
502
if(unlikely(os_get_system_cpus() > 128)) {
@@ -524,12 +524,12 @@ int do_proc_stat(int update_every, usec_t dt) {
524
keep_cpuidle_fds_open = CONFIG_BOOLEAN_YES;
525
}
526
527
- keep_per_core_fds_open = config_get_boolean("plugin:proc:/proc/stat", "keep per core files open", keep_per_core_fds_open);
528
- keep_cpuidle_fds_open = config_get_boolean("plugin:proc:/proc/stat", "keep cpuidle files open", keep_cpuidle_fds_open);
529
- do_core_throttle_count = config_get_boolean_ondemand("plugin:proc:/proc/stat", "core_throttle_count", do_core_throttle_count);
530
- do_package_throttle_count = config_get_boolean_ondemand("plugin:proc:/proc/stat", "package_throttle_count", do_package_throttle_count);
531
- do_cpu_freq = config_get_boolean_ondemand("plugin:proc:/proc/stat", "cpu frequency", do_cpu_freq);
532
- do_cpuidle = config_get_boolean_ondemand("plugin:proc:/proc/stat", "cpu idle states", do_cpuidle);
527
+ keep_per_core_fds_open = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "keep per core files open", keep_per_core_fds_open);
528
+ keep_cpuidle_fds_open = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/stat", "keep cpuidle files open", keep_cpuidle_fds_open);
529
+ do_core_throttle_count = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/stat", "core_throttle_count", do_core_throttle_count);
530
+ do_package_throttle_count = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/stat", "package_throttle_count", do_package_throttle_count);
531
+ do_cpu_freq = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/stat", "cpu frequency", do_cpu_freq);
532
+ do_cpuidle = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/stat", "cpu idle states", do_cpuidle);
533
534
hash_intr = simple_hash("intr");
535
hash_ctxt = simple_hash("ctxt");
@@ -539,19 +539,19 @@ int do_proc_stat(int update_every, usec_t dt) {
539
540
char filename[FILENAME_MAX + 1];
541
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/cpu/%s/thermal_throttle/core_throttle_count");
542
- core_throttle_count_filename = config_get("plugin:proc:/proc/stat", "core_throttle_count filename to monitor", filename);
542
+ core_throttle_count_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "core_throttle_count filename to monitor", filename);
543
544
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/cpu/%s/thermal_throttle/package_throttle_count");
545
- package_throttle_count_filename = config_get("plugin:proc:/proc/stat", "package_throttle_count filename to monitor", filename);
545
+ package_throttle_count_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "package_throttle_count filename to monitor", filename);
546
547
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/cpu/%s/cpufreq/scaling_cur_freq");
548
- scaling_cur_freq_filename = config_get("plugin:proc:/proc/stat", "scaling_cur_freq filename to monitor", filename);
548
+ scaling_cur_freq_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "scaling_cur_freq filename to monitor", filename);
549
550
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/cpu/%s/cpufreq/stats/time_in_state");
551
- time_in_state_filename = config_get("plugin:proc:/proc/stat", "time_in_state filename to monitor", filename);
551
+ time_in_state_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "time_in_state filename to monitor", filename);
552
553
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/schedstat");
554
- schedstat_filename = config_get("plugin:proc:/proc/stat", "schedstat filename to monitor", filename);
554
+ schedstat_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "schedstat filename to monitor", filename);
555
556
if(do_cpuidle != CONFIG_BOOLEAN_NO) {
557
struct stat stbuf;
@@ -561,16 +561,16 @@ int do_proc_stat(int update_every, usec_t dt) {
561
}
562
563
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/cpu/cpu%zu/cpuidle/state%zu/name");
564
- cpuidle_name_filename = config_get("plugin:proc:/proc/stat", "cpuidle name filename to monitor", filename);
564
+ cpuidle_name_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "cpuidle name filename to monitor", filename);
565
566
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/cpu/cpu%zu/cpuidle/state%zu/time");
567
- cpuidle_time_filename = config_get("plugin:proc:/proc/stat", "cpuidle time filename to monitor", filename);
567
+ cpuidle_time_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "cpuidle time filename to monitor", filename);
568
}
569
570
if(unlikely(!ff)) {
571
char filename[FILENAME_MAX + 1];
572
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/stat");
573
- ff = procfile_open(config_get("plugin:proc:/proc/stat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
573
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/stat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
574
if(unlikely(!ff)) return 1;
575
}
576
src/collectors/proc.plugin/proc_sys_fs_file_nr.c
+1
-1
@@ -10,7 +10,7 @@ int do_proc_sys_fs_file_nr(int update_every, usec_t dt) {
10
if(unlikely(!ff)) {
11
char filename[FILENAME_MAX + 1];
12
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sys/fs/file-nr");
13
- ff = procfile_open(config_get("plugin:proc:/proc/sys/fs/file-nr", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT);
13
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/sys/fs/file-nr", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT);
14
if(unlikely(!ff)) return 1;
15
}
16
src/collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c
+1
-1
@@ -10,7 +10,7 @@ int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt) {
10
if(unlikely(!ff)) {
11
char filename[FILENAME_MAX + 1];
12
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/sys/kernel/random/entropy_avail");
13
- ff = procfile_open(config_get("plugin:proc:/proc/sys/kernel/random/entropy_avail", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT);
13
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/sys/kernel/random/entropy_avail", "filename to monitor", filename), "", PROCFILE_FLAG_DEFAULT);
14
if(unlikely(!ff)) return 1;
15
}
16
src/collectors/proc.plugin/proc_uptime.c
+1
-1
@@ -10,7 +10,7 @@ int do_proc_uptime(int update_every, usec_t dt) {
10
char filename[FILENAME_MAX + 1];
11
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/uptime");
12
13
- uptime_filename = config_get("plugin:proc:/proc/uptime", "filename to monitor", filename);
13
+ uptime_filename = inicfg_get(&netdata_config, "plugin:proc:/proc/uptime", "filename to monitor", filename);
14
}
15
16
static RRDSET *st = NULL;
src/collectors/proc.plugin/proc_vmstat.c
+10
-10
@@ -136,7 +136,7 @@ int do_proc_vmstat(int update_every, usec_t dt) {
136
if(unlikely(!ff)) {
137
char filename[FILENAME_MAX + 1];
138
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/vmstat");
139
- ff = procfile_open(config_get("plugin:proc:/proc/vmstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
139
+ ff = procfile_open(inicfg_get(&netdata_config, "plugin:proc:/proc/vmstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
140
if(unlikely(!ff)) return 1;
141
}
142
@@ -146,15 +146,15 @@ int do_proc_vmstat(int update_every, usec_t dt) {
146
size_t lines = procfile_lines(ff), l;
147
148
if(unlikely(!arl_base)) {
149
- do_swapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "swap i/o", CONFIG_BOOLEAN_AUTO);
150
- do_io = config_get_boolean("plugin:proc:/proc/vmstat", "disk i/o", CONFIG_BOOLEAN_YES);
151
- do_pgfaults = config_get_boolean("plugin:proc:/proc/vmstat", "memory page faults", CONFIG_BOOLEAN_YES);
152
- do_oom_kill = config_get_boolean("plugin:proc:/proc/vmstat", "out of memory kills", CONFIG_BOOLEAN_AUTO);
153
- do_numa = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "system-wide numa metric summary", CONFIG_BOOLEAN_AUTO);
154
- do_thp = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "transparent huge pages", CONFIG_BOOLEAN_AUTO);
155
- do_zswapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "zswap i/o", CONFIG_BOOLEAN_AUTO);
156
- do_balloon = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "memory ballooning", CONFIG_BOOLEAN_AUTO);
157
- do_ksm = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "kernel same memory", CONFIG_BOOLEAN_AUTO);
149
+ do_swapio = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/vmstat", "swap i/o", CONFIG_BOOLEAN_AUTO);
150
+ do_io = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/vmstat", "disk i/o", CONFIG_BOOLEAN_YES);
151
+ do_pgfaults = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/vmstat", "memory page faults", CONFIG_BOOLEAN_YES);
152
+ do_oom_kill = inicfg_get_boolean(&netdata_config, "plugin:proc:/proc/vmstat", "out of memory kills", CONFIG_BOOLEAN_AUTO);
153
+ do_numa = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/vmstat", "system-wide numa metric summary", CONFIG_BOOLEAN_AUTO);
154
+ do_thp = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/vmstat", "transparent huge pages", CONFIG_BOOLEAN_AUTO);
155
+ do_zswapio = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/vmstat", "zswap i/o", CONFIG_BOOLEAN_AUTO);
156
+ do_balloon = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/vmstat", "memory ballooning", CONFIG_BOOLEAN_AUTO);
157
+ do_ksm = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/proc/vmstat", "kernel same memory", CONFIG_BOOLEAN_AUTO);
158
159
arl_base = arl_create("vmstat", NULL, 60);
160
arl_expect(arl_base, "pgfault", &pgfault);
src/collectors/proc.plugin/sys_class_drm.c
+1
-1
@@ -838,7 +838,7 @@ int do_sys_class_drm(int update_every, usec_t dt) {
838
if(unlikely(!drm_dir)) {
839
char filename[FILENAME_MAX];
840
snprintfz(filename, sizeof(filename), "%s%s", netdata_configured_host_prefix, "/sys/class/drm");
841
- const char *drm_dir_name = config_get(CONFIG_SECTION_PLUGIN_PROC_DRM, "directory to monitor", filename);
841
+ const char *drm_dir_name = inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_PROC_DRM, "directory to monitor", filename);
842
if(unlikely(NULL == (drm_dir = opendir(drm_dir_name)))){
843
collector_error("Cannot read directory '%s'", drm_dir_name);
844
return 1;
src/collectors/proc.plugin/sys_class_infiniband.c
+22
-22
@@ -311,28 +311,28 @@ int do_sys_class_infiniband(int update_every, usec_t dt)
311
312
snprintfz(dirname, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/class/infiniband");
313
sys_class_infiniband_dirname =
314
- config_get(CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "dirname to monitor", dirname);
315
-
316
- do_bytes = config_get_boolean_ondemand(
317
- CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "bandwidth counters", CONFIG_BOOLEAN_YES);
318
- do_packets = config_get_boolean_ondemand(
319
- CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "packets counters", CONFIG_BOOLEAN_YES);
320
- do_errors = config_get_boolean_ondemand(
321
- CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "errors counters", CONFIG_BOOLEAN_YES);
322
- do_hwpackets = config_get_boolean_ondemand(
323
- CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "hardware packets counters", CONFIG_BOOLEAN_AUTO);
324
- do_hwerrors = config_get_boolean_ondemand(
325
- CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "hardware errors counters", CONFIG_BOOLEAN_AUTO);
326
-
327
- enable_only_active = config_get_boolean_ondemand(
328
- CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "monitor only active ports", CONFIG_BOOLEAN_AUTO);
314
+ inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "dirname to monitor", dirname);
315
+
316
+ do_bytes = inicfg_get_boolean_ondemand(
317
+ &netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "bandwidth counters", CONFIG_BOOLEAN_YES);
318
+ do_packets = inicfg_get_boolean_ondemand(
319
+ &netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "packets counters", CONFIG_BOOLEAN_YES);
320
+ do_errors = inicfg_get_boolean_ondemand(
321
+ &netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "errors counters", CONFIG_BOOLEAN_YES);
322
+ do_hwpackets = inicfg_get_boolean_ondemand(
323
+ &netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "hardware packets counters", CONFIG_BOOLEAN_AUTO);
324
+ do_hwerrors = inicfg_get_boolean_ondemand(
325
+ &netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "hardware errors counters", CONFIG_BOOLEAN_AUTO);
326
+
327
+ enable_only_active = inicfg_get_boolean_ondemand(
328
+ &netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "monitor only active ports", CONFIG_BOOLEAN_AUTO);
329
disabled_list = simple_pattern_create(
330
- config_get(CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "disable by default interfaces matching", ""),
330
+ inicfg_get(&netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "disable by default interfaces matching", ""),
331
NULL,
332
SIMPLE_PATTERN_EXACT, true);
333
334
dt_to_refresh_ports =
335
- config_get_duration_seconds(CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "refresh ports state every", 30) *
335
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PLUGIN_SYS_CLASS_INFINIBAND, "refresh ports state every", 30) *
336
USEC_PER_SEC;
337
if (dt_to_refresh_ports < 0)
338
dt_to_refresh_ports = 0;
@@ -401,9 +401,9 @@ int do_sys_class_infiniband(int update_every, usec_t dt)
401
snprintfz(buffer, FILENAME_MAX, "plugin:proc:/sys/class/infiniband:%s", p->name);
402
403
// Standard counters
404
- p->do_bytes = config_get_boolean_ondemand(buffer, "bytes", do_bytes);
405
- p->do_packets = config_get_boolean_ondemand(buffer, "packets", do_packets);
406
- p->do_errors = config_get_boolean_ondemand(buffer, "errors", do_errors);
404
+ p->do_bytes = inicfg_get_boolean_ondemand(&netdata_config, buffer, "bytes", do_bytes);
405
+ p->do_packets = inicfg_get_boolean_ondemand(&netdata_config, buffer, "packets", do_packets);
406
+ p->do_errors = inicfg_get_boolean_ondemand(&netdata_config, buffer, "errors", do_errors);
407
408
// Gen filename allocation and concatenation
409
#define GEN_DO_COUNTER_NAME(NAME, GRP, DESC, DIR, PORT, ...) \
@@ -416,8 +416,8 @@ int do_sys_class_infiniband(int update_every, usec_t dt)
416
DIR *hwcounters_dir = opendir(hwcounters_dirname);
417
if (hwcounters_dir) {
418
// By default set standard
419
- p->do_hwpackets = config_get_boolean_ondemand(buffer, "hwpackets", do_hwpackets);
420
- p->do_hwerrors = config_get_boolean_ondemand(buffer, "hwerrors", do_hwerrors);
419
+ p->do_hwpackets = inicfg_get_boolean_ondemand(&netdata_config, buffer, "hwpackets", do_hwpackets);
420
+ p->do_hwerrors = inicfg_get_boolean_ondemand(&netdata_config, buffer, "hwerrors", do_hwerrors);
421
422
// VENDORS: Set your own
423
src/collectors/proc.plugin/sys_class_power_supply.c
+7
-7
@@ -202,17 +202,17 @@ int do_sys_class_power_supply(int update_every, usec_t dt) {
202
static const char *dirname = NULL;
203
204
if(unlikely(do_capacity == -1)) {
205
- do_capacity = config_get_boolean("plugin:proc:/sys/class/power_supply", "battery capacity", CONFIG_BOOLEAN_YES);
206
- do_power = config_get_boolean("plugin:proc:/sys/class/power_supply", "battery power", CONFIG_BOOLEAN_YES);
207
- do_property[0] = config_get_boolean("plugin:proc:/sys/class/power_supply", "battery charge", CONFIG_BOOLEAN_NO);
208
- do_property[1] = config_get_boolean("plugin:proc:/sys/class/power_supply", "battery energy", CONFIG_BOOLEAN_NO);
209
- do_property[2] = config_get_boolean("plugin:proc:/sys/class/power_supply", "power supply voltage", CONFIG_BOOLEAN_NO);
205
+ do_capacity = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/power_supply", "battery capacity", CONFIG_BOOLEAN_YES);
206
+ do_power = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/power_supply", "battery power", CONFIG_BOOLEAN_YES);
207
+ do_property[0] = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/power_supply", "battery charge", CONFIG_BOOLEAN_NO);
208
+ do_property[1] = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/power_supply", "battery energy", CONFIG_BOOLEAN_NO);
209
+ do_property[2] = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/power_supply", "power supply voltage", CONFIG_BOOLEAN_NO);
210
211
- keep_fds_open_config = config_get_boolean_ondemand("plugin:proc:/sys/class/power_supply", "keep files open", CONFIG_BOOLEAN_AUTO);
211
+ keep_fds_open_config = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/class/power_supply", "keep files open", CONFIG_BOOLEAN_AUTO);
212
213
char filename[FILENAME_MAX + 1];
214
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/class/power_supply");
215
- dirname = config_get("plugin:proc:/sys/class/power_supply", "directory to monitor", filename);
215
+ dirname = inicfg_get(&netdata_config, "plugin:proc:/sys/class/power_supply", "directory to monitor", filename);
216
}
217
218
DIR *dir = opendir(dirname);
src/collectors/proc.plugin/sys_devices_pci_aer.c
+3
-3
@@ -102,7 +102,7 @@ static bool recursively_find_pci_aer(AER_TYPE types, const char *base_dir, const
102
static void find_all_pci_aer(AER_TYPE types) {
103
char name[FILENAME_MAX + 1];
104
snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices");
105
- pci_aer_dirname = config_get("plugin:proc:/sys/devices/pci/aer", "directory to monitor", name);
105
+ pci_aer_dirname = inicfg_get(&netdata_config, "plugin:proc:/sys/devices/pci/aer", "directory to monitor", name);
106
107
DIR *dir = opendir(pci_aer_dirname);
108
if(unlikely(!dir)) {
@@ -203,8 +203,8 @@ int do_proc_sys_devices_pci_aer(int update_every, usec_t dt __maybe_unused) {
203
do_pci_slots = CONFIG_BOOLEAN_NO;
204
}
205
206
- do_root_ports = config_get_boolean("plugin:proc:/sys/class/pci/aer", "enable root ports", do_root_ports);
207
- do_pci_slots = config_get_boolean("plugin:proc:/sys/class/pci/aer", "enable pci slots", do_pci_slots);
206
+ do_root_ports = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/pci/aer", "enable root ports", do_root_ports);
207
+ do_pci_slots = inicfg_get_boolean(&netdata_config, "plugin:proc:/sys/class/pci/aer", "enable pci slots", do_pci_slots);
208
209
if(!do_root_ports && !do_pci_slots)
210
return 1;
src/collectors/proc.plugin/sys_devices_system_edac_mc.c
+1
-1
@@ -42,7 +42,7 @@ static const char *mc_dirname = NULL;
42
static void find_all_mc() {
43
char name[FILENAME_MAX + 1];
44
snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/edac/mc");
45
- mc_dirname = config_get("plugin:proc:/sys/devices/system/edac/mc", "directory to monitor", name);
45
+ mc_dirname = inicfg_get(&netdata_config, "plugin:proc:/sys/devices/system/edac/mc", "directory to monitor", name);
46
47
DIR *dir = opendir(mc_dirname);
48
if(unlikely(!dir)) {
src/collectors/proc.plugin/sys_devices_system_node.c
+3
-3
@@ -27,7 +27,7 @@ static int find_all_nodes() {
27
int numa_node_count = 0;
28
char name[FILENAME_MAX + 1];
29
snprintfz(name, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/devices/system/node");
30
- const char *dirname = config_get("plugin:proc:/sys/devices/system/node", "directory to monitor", name);
30
+ const char *dirname = inicfg_get(&netdata_config, "plugin:proc:/sys/devices/system/node", "directory to monitor", name);
31
32
DIR *dir = opendir(dirname);
33
if(!dir) {
@@ -276,8 +276,8 @@ int do_proc_sys_devices_system_node(int update_every, usec_t dt) {
276
static int do_numastat = -1;
277
278
if(unlikely(do_numastat == -1)) {
279
- do_numastat = config_get_boolean_ondemand(
280
- "plugin:proc:/sys/devices/system/node", "enable per-node numa metrics", CONFIG_BOOLEAN_AUTO);
279
+ do_numastat = inicfg_get_boolean_ondemand(
280
+ &netdata_config, "plugin:proc:/sys/devices/system/node", "enable per-node numa metrics", CONFIG_BOOLEAN_AUTO);
281
}
282
283
if(unlikely(numa_root == NULL)) {
src/collectors/proc.plugin/sys_fs_btrfs.c
+8
-8
@@ -687,17 +687,17 @@ int do_sys_fs_btrfs(int update_every, usec_t dt) {
687
688
char filename[FILENAME_MAX + 1];
689
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/fs/btrfs");
690
- btrfs_path = config_get("plugin:proc:/sys/fs/btrfs", "path to monitor", filename);
690
+ btrfs_path = inicfg_get(&netdata_config, "plugin:proc:/sys/fs/btrfs", "path to monitor", filename);
691
692
- refresh_every = config_get_duration_seconds("plugin:proc:/sys/fs/btrfs", "check for btrfs changes every", refresh_every / USEC_PER_SEC) * USEC_PER_SEC;
692
+ refresh_every = inicfg_get_duration_seconds(&netdata_config, "plugin:proc:/sys/fs/btrfs", "check for btrfs changes every", refresh_every / USEC_PER_SEC) * USEC_PER_SEC;
693
refresh_delta = refresh_every;
694
695
- do_allocation_disks = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "physical disks allocation", do_allocation_disks);
696
- do_allocation_data = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "data allocation", do_allocation_data);
697
- do_allocation_metadata = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "metadata allocation", do_allocation_metadata);
698
- do_allocation_system = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "system allocation", do_allocation_system);
699
- do_commit_stats = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "commit stats", do_commit_stats);
700
- do_error_stats = config_get_boolean_ondemand("plugin:proc:/sys/fs/btrfs", "error stats", do_error_stats);
695
+ do_allocation_disks = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/fs/btrfs", "physical disks allocation", do_allocation_disks);
696
+ do_allocation_data = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/fs/btrfs", "data allocation", do_allocation_data);
697
+ do_allocation_metadata = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/fs/btrfs", "metadata allocation", do_allocation_metadata);
698
+ do_allocation_system = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/fs/btrfs", "system allocation", do_allocation_system);
699
+ do_commit_stats = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/fs/btrfs", "commit stats", do_commit_stats);
700
+ do_error_stats = inicfg_get_boolean_ondemand(&netdata_config, "plugin:proc:/sys/fs/btrfs", "error stats", do_error_stats);
701
}
702
703
refresh_delta += dt;
src/collectors/proc.plugin/sys_kernel_mm_ksm.c
+5
-5
@@ -33,31 +33,31 @@ int do_sys_kernel_mm_ksm(int update_every, usec_t dt) {
33
34
if(unlikely(!ff_pages_shared)) {
35
snprintfz(values[PAGES_SHARED].filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/kernel/mm/ksm/pages_shared");
36
- snprintfz(values[PAGES_SHARED].filename, FILENAME_MAX, "%s", config_get("plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_shared", values[PAGES_SHARED].filename));
36
+ snprintfz(values[PAGES_SHARED].filename, FILENAME_MAX, "%s", inicfg_get(&netdata_config, "plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_shared", values[PAGES_SHARED].filename));
37
ff_pages_shared = procfile_open(values[PAGES_SHARED].filename, " \t:", PROCFILE_FLAG_DEFAULT);
38
}
39
40
if(unlikely(!ff_pages_sharing)) {
41
snprintfz(values[PAGES_SHARING].filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/kernel/mm/ksm/pages_sharing");
42
- snprintfz(values[PAGES_SHARING].filename, FILENAME_MAX, "%s", config_get("plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_sharing", values[PAGES_SHARING].filename));
42
+ snprintfz(values[PAGES_SHARING].filename, FILENAME_MAX, "%s", inicfg_get(&netdata_config, "plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_sharing", values[PAGES_SHARING].filename));
43
ff_pages_sharing = procfile_open(values[PAGES_SHARING].filename, " \t:", PROCFILE_FLAG_DEFAULT);
44
}
45
46
if(unlikely(!ff_pages_unshared)) {
47
snprintfz(values[PAGES_UNSHARED].filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/kernel/mm/ksm/pages_unshared");
48
- snprintfz(values[PAGES_UNSHARED].filename, FILENAME_MAX, "%s", config_get("plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_unshared", values[PAGES_UNSHARED].filename));
48
+ snprintfz(values[PAGES_UNSHARED].filename, FILENAME_MAX, "%s", inicfg_get(&netdata_config, "plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_unshared", values[PAGES_UNSHARED].filename));
49
ff_pages_unshared = procfile_open(values[PAGES_UNSHARED].filename, " \t:", PROCFILE_FLAG_DEFAULT);
50
}
51
52
if(unlikely(!ff_pages_volatile)) {
53
snprintfz(values[PAGES_VOLATILE].filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/kernel/mm/ksm/pages_volatile");
54
- snprintfz(values[PAGES_VOLATILE].filename, FILENAME_MAX, "%s", config_get("plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_volatile", values[PAGES_VOLATILE].filename));
54
+ snprintfz(values[PAGES_VOLATILE].filename, FILENAME_MAX, "%s", inicfg_get(&netdata_config, "plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_volatile", values[PAGES_VOLATILE].filename));
55
ff_pages_volatile = procfile_open(values[PAGES_VOLATILE].filename, " \t:", PROCFILE_FLAG_DEFAULT);
56
}
57
58
//if(unlikely(!ff_pages_to_scan)) {
59
// snprintfz(values[PAGES_TO_SCAN].filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/kernel/mm/ksm/pages_to_scan");
60
- // snprintfz(values[PAGES_TO_SCAN].filename, FILENAME_MAX, "%s", config_get("plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_to_scan", values[PAGES_TO_SCAN].filename));
60
+ // snprintfz(values[PAGES_TO_SCAN].filename, FILENAME_MAX, "%s", inicfg_get(&netdata_config, "plugin:proc:/sys/kernel/mm/ksm", "/sys/kernel/mm/ksm/pages_to_scan", values[PAGES_TO_SCAN].filename));
61
// ff_pages_to_scan = procfile_open(values[PAGES_TO_SCAN].filename, " \t:", PROCFILE_FLAG_DEFAULT);
62
//}
63
src/collectors/profile.plugin/plugin_profile.cc
+6
-6
@@ -192,17 +192,17 @@ static void profile_main_cleanup(void *pptr) {
192
extern "C" void *profile_main(void *ptr) {
193
CLEANUP_FUNCTION_REGISTER(profile_main_cleanup) cleanup_ptr = ptr;
194
195
- int UpdateEvery = (int) config_get_duration_seconds(CONFIG_SECTION_PROFILE, "update every", 1);
195
+ int UpdateEvery = (int) inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PROFILE, "update every", 1);
196
if (UpdateEvery < localhost->rrd_update_every) {
197
UpdateEvery = localhost->rrd_update_every;
198
- config_set_duration_seconds(CONFIG_SECTION_PROFILE, "update every", UpdateEvery);
198
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_PROFILE, "update every", UpdateEvery);
199
}
200
201
// pick low-default values, in case this plugin is ever enabled accidentaly.
202
- size_t NumThreads = config_get_number(CONFIG_SECTION_PROFILE, "number of threads", 2);
203
- size_t NumCharts = config_get_number(CONFIG_SECTION_PROFILE, "number of charts", 2);
204
- size_t NumDimsPerChart = config_get_number(CONFIG_SECTION_PROFILE, "number of dimensions per chart", 2);
205
- size_t SecondsToBackfill = config_get_number(CONFIG_SECTION_PROFILE, "seconds to backfill", 10 * 60);
202
+ size_t NumThreads = inicfg_get_number(&netdata_config, CONFIG_SECTION_PROFILE, "number of threads", 2);
203
+ size_t NumCharts = inicfg_get_number(&netdata_config, CONFIG_SECTION_PROFILE, "number of charts", 2);
204
+ size_t NumDimsPerChart = inicfg_get_number(&netdata_config, CONFIG_SECTION_PROFILE, "number of dimensions per chart", 2);
205
+ size_t SecondsToBackfill = inicfg_get_number(&netdata_config, CONFIG_SECTION_PROFILE, "seconds to backfill", 10 * 60);
206
207
std::vector<Profiler> Profilers;
208
src/collectors/statsd.plugin/statsd.c
+23
-23
@@ -2489,42 +2489,42 @@ void *statsd_main(void *ptr) {
2489
// ----------------------------------------------------------------------------------------------------------------
2490
// statsd configuration
2491
2492
- statsd.enabled = config_get_boolean(CONFIG_SECTION_PLUGINS, "statsd", statsd.enabled);
2492
+ statsd.enabled = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGINS, "statsd", statsd.enabled);
2493
2494
statsd.update_every = nd_profile.update_every;
2495
- statsd.update_every = (int)config_get_duration_seconds(CONFIG_SECTION_STATSD, "update every (flushInterval)", statsd.update_every);
2495
+ statsd.update_every = (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_STATSD, "update every (flushInterval)", statsd.update_every);
2496
if(statsd.update_every < nd_profile.update_every) {
2497
collector_error("STATSD: minimum flush interval %d given, but the minimum is the update every of netdata. Using %d",
2498
(int)statsd.update_every, (int)nd_profile.update_every);
2499
statsd.update_every = nd_profile.update_every;
2500
- config_set_duration_seconds(CONFIG_SECTION_STATSD, "update every (flushInterval)", statsd.update_every);
2500
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_STATSD, "update every (flushInterval)", statsd.update_every);
2501
}
2502
2503
#ifdef HAVE_RECVMMSG
2504
- statsd.recvmmsg_size = (size_t)config_get_number(CONFIG_SECTION_STATSD, "udp messages to process at once", (long long)statsd.recvmmsg_size);
2504
+ statsd.recvmmsg_size = (size_t)inicfg_get_number(&netdata_config, CONFIG_SECTION_STATSD, "udp messages to process at once", (long long)statsd.recvmmsg_size);
2505
#endif
2506
2507
statsd.charts_for = simple_pattern_create(
2508
- config_get(CONFIG_SECTION_STATSD, "create private charts for metrics matching", "*"), NULL,
2508
+ inicfg_get(&netdata_config, CONFIG_SECTION_STATSD, "create private charts for metrics matching", "*"), NULL,
2509
SIMPLE_PATTERN_EXACT, true);
2510
2511
statsd.max_private_charts_hard =
2512
- (size_t)config_get_number(CONFIG_SECTION_STATSD, "max private charts hard limit", (long long)statsd.max_private_charts_hard);
2512
+ (size_t)inicfg_get_number(&netdata_config, CONFIG_SECTION_STATSD, "max private charts hard limit", (long long)statsd.max_private_charts_hard);
2513
2514
statsd.set_obsolete_after =
2515
- (size_t)config_get_duration_seconds(CONFIG_SECTION_STATSD, "set charts as obsolete after", (long long)statsd.set_obsolete_after);
2515
+ (size_t)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_STATSD, "set charts as obsolete after", (long long)statsd.set_obsolete_after);
2516
2517
statsd.decimal_detail =
2518
- (collected_number)config_get_number(CONFIG_SECTION_STATSD, "decimal detail", (long long int)statsd.decimal_detail);
2518
+ (collected_number)inicfg_get_number(&netdata_config, CONFIG_SECTION_STATSD, "decimal detail", (long long int)statsd.decimal_detail);
2519
2520
statsd.tcp_idle_timeout =
2521
- (size_t) config_get_duration_seconds(CONFIG_SECTION_STATSD, "disconnect idle tcp clients after", (long long int)statsd.tcp_idle_timeout);
2521
+ (size_t) inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_STATSD, "disconnect idle tcp clients after", (long long int)statsd.tcp_idle_timeout);
2522
2523
statsd.private_charts_hidden =
2524
- (unsigned int)config_get_boolean(CONFIG_SECTION_STATSD, "private charts hidden", statsd.private_charts_hidden);
2524
+ (unsigned int)inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "private charts hidden", statsd.private_charts_hidden);
2525
2526
statsd.histogram_percentile =
2527
- (double)config_get_double(
2527
+ (double)inicfg_get_double(&netdata_config,
2528
CONFIG_SECTION_STATSD, "histograms and timers percentile (percentThreshold)", statsd.histogram_percentile);
2529
2530
if(isless(statsd.histogram_percentile, 0) || isgreater(statsd.histogram_percentile, 100)) {
@@ -2538,9 +2538,9 @@ void *statsd_main(void *ptr) {
2538
}
2539
2540
statsd.dictionary_max_unique =
2541
- config_get_number(CONFIG_SECTION_STATSD, "dictionaries max unique dimensions", statsd.dictionary_max_unique);
2541
+ inicfg_get_number(&netdata_config, CONFIG_SECTION_STATSD, "dictionaries max unique dimensions", statsd.dictionary_max_unique);
2542
2543
- if(config_get_boolean(CONFIG_SECTION_STATSD, "add dimension for number of events received", 0)) {
2543
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "add dimension for number of events received", 0)) {
2544
statsd.gauges.default_options |= STATSD_METRIC_OPTION_CHART_DIMENSION_COUNT;
2545
statsd.counters.default_options |= STATSD_METRIC_OPTION_CHART_DIMENSION_COUNT;
2546
statsd.meters.default_options |= STATSD_METRIC_OPTION_CHART_DIMENSION_COUNT;
@@ -2550,35 +2550,35 @@ void *statsd_main(void *ptr) {
2550
statsd.dictionaries.default_options |= STATSD_METRIC_OPTION_CHART_DIMENSION_COUNT;
2551
}
2552
2553
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on gauges (deleteGauges)", 0))
2553
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on gauges (deleteGauges)", 0))
2554
statsd.gauges.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2555
2556
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on counters (deleteCounters)", 0))
2556
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on counters (deleteCounters)", 0))
2557
statsd.counters.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2558
2559
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on meters (deleteMeters)", 0))
2559
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on meters (deleteMeters)", 0))
2560
statsd.meters.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2561
2562
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on sets (deleteSets)", 0))
2562
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on sets (deleteSets)", 0))
2563
statsd.sets.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2564
2565
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on histograms (deleteHistograms)", 0))
2565
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on histograms (deleteHistograms)", 0))
2566
statsd.histograms.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2567
2568
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on timers (deleteTimers)", 0))
2568
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on timers (deleteTimers)", 0))
2569
statsd.timers.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2570
2571
- if(config_get_boolean(CONFIG_SECTION_STATSD, "gaps on dictionaries (deleteDictionaries)", 0))
2571
+ if(inicfg_get_boolean(&netdata_config, CONFIG_SECTION_STATSD, "gaps on dictionaries (deleteDictionaries)", 0))
2572
statsd.dictionaries.default_options |= STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED;
2573
2574
- size_t max_sockets = (size_t)config_get_number(CONFIG_SECTION_STATSD, "statsd server max TCP sockets", (long long int)(rlimit_nofile.rlim_cur / 4));
2574
+ size_t max_sockets = (size_t)inicfg_get_number(&netdata_config, CONFIG_SECTION_STATSD, "statsd server max TCP sockets", (long long int)(rlimit_nofile.rlim_cur / 4));
2575
2576
#ifdef STATSD_MULTITHREADED
2577
- statsd.threads = (int)config_get_number(CONFIG_SECTION_STATSD, "threads", processors);
2577
+ statsd.threads = (int)inicfg_get_number(&netdata_config, CONFIG_SECTION_STATSD, "threads", processors);
2578
if(statsd.threads < 1) {
2579
collector_error("STATSD: Invalid number of threads %d, using %d", statsd.threads, processors);
2580
statsd.threads = processors;
2581
- config_set_number(CONFIG_SECTION_STATSD, "collector threads", statsd.threads);
2581
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_STATSD, "collector threads", statsd.threads);
2582
}
2583
#else
2584
statsd.threads = 1;
src/collectors/tc.plugin/plugin_tc.c
+19
-19
@@ -185,7 +185,7 @@ static inline void tc_device_classes_cleanup(struct tc_device *d) {
185
static int cleanup_every = 999;
186
187
if(unlikely(cleanup_every > 0)) {
188
- cleanup_every = (int) config_get_number("plugin:tc", "cleanup unused classes every", 120);
188
+ cleanup_every = (int) inicfg_get_number(&netdata_config, "plugin:tc", "cleanup unused classes every", 120);
189
if(cleanup_every < 0) cleanup_every = -cleanup_every;
190
}
191
@@ -209,9 +209,9 @@ static inline void tc_device_commit(struct tc_device *d) {
209
static int enable_tokens = -1, enable_ctokens = -1, enabled_all_classes_qdiscs = -1;
210
211
if(unlikely(enabled_all_classes_qdiscs == -1)) {
212
- enable_tokens = config_get_boolean_ondemand("plugin:tc", "enable tokens charts for all interfaces", CONFIG_BOOLEAN_NO);
213
- enable_ctokens = config_get_boolean_ondemand("plugin:tc", "enable ctokens charts for all interfaces", CONFIG_BOOLEAN_NO);
214
- enabled_all_classes_qdiscs = config_get_boolean_ondemand("plugin:tc", "enable show all classes and qdiscs for all interfaces", CONFIG_BOOLEAN_NO);
212
+ enable_tokens = inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", "enable tokens charts for all interfaces", CONFIG_BOOLEAN_NO);
213
+ enable_ctokens = inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", "enable ctokens charts for all interfaces", CONFIG_BOOLEAN_NO);
214
+ enabled_all_classes_qdiscs = inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", "enable show all classes and qdiscs for all interfaces", CONFIG_BOOLEAN_NO);
215
}
216
217
if(unlikely(d->enabled == (char)-1)) {
@@ -227,33 +227,33 @@ static inline void tc_device_commit(struct tc_device *d) {
227
char var_name[CONFIG_MAX_NAME + 1];
228
229
snprintfz(var_name, CONFIG_MAX_NAME, "qos for %s", string2str(d->id));
230
- if (config_exists("plugin:tc", var_name))
231
- d->enabled = (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled);
230
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
231
+ d->enabled = (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled);
232
233
snprintfz(var_name, CONFIG_MAX_NAME, "traffic chart for %s", string2str(d->id));
234
- if (config_exists("plugin:tc", var_name))
235
- d->enabled_bytes = (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled_bytes);
234
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
235
+ d->enabled_bytes = (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled_bytes);
236
237
snprintfz(var_name, CONFIG_MAX_NAME, "packets chart for %s", string2str(d->id));
238
- if (config_exists("plugin:tc", var_name))
239
- d->enabled_packets = (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled_packets);
238
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
239
+ d->enabled_packets = (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled_packets);
240
241
snprintfz(var_name, CONFIG_MAX_NAME, "dropped packets chart for %s", string2str(d->id));
242
- if (config_exists("plugin:tc", var_name))
243
- d->enabled_dropped = (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled_dropped);
242
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
243
+ d->enabled_dropped = (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled_dropped);
244
245
snprintfz(var_name, CONFIG_MAX_NAME, "tokens chart for %s", string2str(d->id));
246
- if (config_exists("plugin:tc", var_name))
247
- d->enabled_tokens = (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled_tokens);
246
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
247
+ d->enabled_tokens = (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled_tokens);
248
249
snprintfz(var_name, CONFIG_MAX_NAME, "ctokens chart for %s", string2str(d->id));
250
- if (config_exists("plugin:tc", var_name))
251
- d->enabled_ctokens = (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled_ctokens);
250
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
251
+ d->enabled_ctokens = (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled_ctokens);
252
253
snprintfz(var_name, CONFIG_MAX_NAME, "show all classes for %s", string2str(d->id));
254
- if (config_exists("plugin:tc", var_name))
254
+ if (inicfg_exists(&netdata_config, "plugin:tc", var_name))
255
d->enabled_all_classes_qdiscs =
256
- (char)config_get_boolean_ondemand("plugin:tc", var_name, d->enabled_all_classes_qdiscs);
256
+ (char)inicfg_get_boolean_ondemand(&netdata_config, "plugin:tc", var_name, d->enabled_all_classes_qdiscs);
257
}
258
259
// we only need to add leaf classes
@@ -910,7 +910,7 @@ void *tc_main(void *ptr) {
910
uint32_t first_hash;
911
912
snprintfz(command, TC_LINE_MAX, "%s/tc-qos-helper.sh", netdata_configured_primary_plugins_dir);
913
- const char *tc_script = config_get("plugin:tc", "script to run to get tc values", command);
913
+ const char *tc_script = inicfg_get(&netdata_config, "plugin:tc", "script to run to get tc values", command);
914
915
while(service_running(SERVICE_COLLECTORS)) {
916
struct tc_device *device = NULL;
src/collectors/timex.plugin/plugin_timex.c
+4
-4
@@ -48,14 +48,14 @@ void *timex_main(void *ptr)
48
worker_register("TIMEX");
49
worker_register_job_name(0, "clock check");
50
51
- int update_every = (int)config_get_duration_seconds(CONFIG_SECTION_TIMEX, "update every", 10);
51
+ int update_every = (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_TIMEX, "update every", 10);
52
if (update_every < localhost->rrd_update_every) {
53
update_every = localhost->rrd_update_every;
54
- config_set_duration_seconds(CONFIG_SECTION_TIMEX, "update every", update_every);
54
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_TIMEX, "update every", update_every);
55
}
56
57
- int do_sync = config_get_boolean(CONFIG_SECTION_TIMEX, "clock synchronization state", CONFIG_BOOLEAN_YES);
58
- int do_offset = config_get_boolean(CONFIG_SECTION_TIMEX, "time offset", CONFIG_BOOLEAN_YES);
57
+ int do_sync = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_TIMEX, "clock synchronization state", CONFIG_BOOLEAN_YES);
58
+ int do_offset = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_TIMEX, "time offset", CONFIG_BOOLEAN_YES);
59
60
if (unlikely(do_sync == CONFIG_BOOLEAN_NO && do_offset == CONFIG_BOOLEAN_NO)) {
61
netdata_log_info("No charts to show");
src/collectors/windows.plugin/windows_plugin.c
+1
-1
@@ -89,7 +89,7 @@ void *win_plugin_main(void *ptr)
89
for (i = 0; win_modules[i].name; i++) {
90
struct proc_module *pm = &win_modules[i];
91
92
- pm->enabled = config_get_boolean("plugin:windows", pm->name, pm->enabled);
92
+ pm->enabled = inicfg_get_boolean(&netdata_config, "plugin:windows", pm->name, pm->enabled);
93
pm->rd = NULL;
94
95
worker_register_job_name(i, win_modules[i].dim);
src/daemon/analytics.c
+5
-5
@@ -463,19 +463,19 @@ void analytics_misc(void)
463
analytics_set_data(&analytics_data.netdata_host_cloud_available, "true");
464
analytics_set_data_str(&analytics_data.netdata_host_aclk_implementation, "Next Generation");
465
466
- analytics_data.exporting_enabled = appconfig_get_boolean(&exporting_config, CONFIG_SECTION_EXPORTING, "enabled", CONFIG_BOOLEAN_NO);
466
+ analytics_data.exporting_enabled = inicfg_get_boolean(&exporting_config, CONFIG_SECTION_EXPORTING, "enabled", CONFIG_BOOLEAN_NO);
467
analytics_set_data(&analytics_data.netdata_config_exporting_enabled, analytics_data.exporting_enabled ? "true" : "false");
468
469
analytics_set_data(&analytics_data.netdata_config_is_private_registry, "false");
470
analytics_set_data(&analytics_data.netdata_config_use_private_registry, "false");
471
472
if (strcmp(
473
- config_get(CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io"),
473
+ inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io"),
474
"https://registry.my-netdata.io") != 0)
475
analytics_set_data(&analytics_data.netdata_config_use_private_registry, "true");
476
477
//do we need both registry to announce and enabled to indicate that this is a private registry ?
478
- if (config_get_boolean(CONFIG_SECTION_REGISTRY, "enabled", CONFIG_BOOLEAN_NO) &&
478
+ if (inicfg_get_boolean(&netdata_config, CONFIG_SECTION_REGISTRY, "enabled", CONFIG_BOOLEAN_NO) &&
479
web_server_mode != WEB_SERVER_MODE_NONE)
480
analytics_set_data(&analytics_data.netdata_config_is_private_registry, "true");
481
}
@@ -654,7 +654,7 @@ void get_system_timezone(void)
654
// http://stackoverflow.com/questions/4554271/how-to-avoid-excessive-stat-etc-localtime-calls-in-strftime-on-linux
655
const char *tz = getenv("TZ");
656
if (!tz || !*tz)
657
- setenv("TZ", config_get(CONFIG_SECTION_ENV_VARS, "TZ", ":/etc/localtime"), 0);
657
+ setenv("TZ", inicfg_get(&netdata_config, CONFIG_SECTION_ENV_VARS, "TZ", ":/etc/localtime"), 0);
658
659
char buffer[FILENAME_MAX + 1] = "";
660
const char *timezone = NULL;
@@ -734,7 +734,7 @@ void get_system_timezone(void)
734
if (!timezone || !*timezone)
735
timezone = "unknown";
736
737
- netdata_configured_timezone = config_get(CONFIG_SECTION_GLOBAL, "timezone", timezone);
737
+ netdata_configured_timezone = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "timezone", timezone);
738
739
//get the utc offset, and the timezone as returned by strftime
740
//will be sent to the cloud
src/daemon/commands.c
+3
-3
@@ -259,7 +259,7 @@ static cmd_status_t cmd_read_config_execute(char *args, char **message)
259
const char *conf_file = temp; /* "cloud" is cloud.conf, otherwise netdata.conf */
260
struct config *tmp_config = strcmp(conf_file, "cloud") ? &netdata_config : &cloud_config;
261
262
- const char *value = appconfig_get(tmp_config, temp + offset + 1, temp + offset2 + 1, NULL);
262
+ const char *value = inicfg_get(tmp_config, temp + offset + 1, temp + offset2 + 1, NULL);
263
if (value == NULL) {
264
netdata_log_error("Cannot execute read-config conf_file=%s section=%s / key=%s because no value set",
265
conf_file,
@@ -301,7 +301,7 @@ static cmd_status_t cmd_write_config_execute(char *args, char **message)
301
const char *conf_file = temp; /* "cloud" is cloud.conf, otherwise netdata.conf */
302
struct config *tmp_config = strcmp(conf_file, "cloud") ? &netdata_config : &cloud_config;
303
304
- appconfig_set(tmp_config, temp + offset + 1, temp + offset2 + 1, temp + offset3 + 1);
304
+ inicfg_set(tmp_config, temp + offset + 1, temp + offset2 + 1, temp + offset3 + 1);
305
netdata_log_info("write-config conf_file=%s section=%s key=%s value=%s",conf_file, temp + offset + 1, temp + offset2 + 1,
306
temp + offset3 + 1);
307
freez(temp);
@@ -345,7 +345,7 @@ static cmd_status_t cmd_dumpconfig(char *args, char **message)
345
(void)args;
346
347
BUFFER *wb = buffer_create(1024, NULL);
348
- netdata_conf_generate(wb, 0);
348
+ inicfg_generate(&netdata_config, wb, 0, true);
349
*message = strdupz(buffer_tostring(wb));
350
buffer_free(wb);
351
return CMD_STATUS_SUCCESS;
src/daemon/config/netdata-conf-backwards-compatibility.c
+86
-86
@@ -6,199 +6,199 @@
6
void netdata_conf_backwards_compatibility(void) {
7
// move [global] options to the [web] section
8
9
- config_move(CONFIG_SECTION_GLOBAL, "http port listen backlog",
9
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "http port listen backlog",
10
CONFIG_SECTION_WEB, "listen backlog");
11
12
- config_move(CONFIG_SECTION_GLOBAL, "bind socket to IP",
12
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "bind socket to IP",
13
CONFIG_SECTION_WEB, "bind to");
14
15
- config_move(CONFIG_SECTION_GLOBAL, "bind to",
15
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "bind to",
16
CONFIG_SECTION_WEB, "bind to");
17
18
- config_move(CONFIG_SECTION_GLOBAL, "port",
18
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "port",
19
CONFIG_SECTION_WEB, "default port");
20
21
- config_move(CONFIG_SECTION_GLOBAL, "default port",
21
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "default port",
22
CONFIG_SECTION_WEB, "default port");
23
24
- config_move(CONFIG_SECTION_GLOBAL, "disconnect idle web clients after seconds",
24
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "disconnect idle web clients after seconds",
25
CONFIG_SECTION_WEB, "disconnect idle clients after seconds");
26
27
- config_move(CONFIG_SECTION_GLOBAL, "respect web browser do not track policy",
27
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "respect web browser do not track policy",
28
CONFIG_SECTION_WEB, "respect do not track policy");
29
30
- config_move(CONFIG_SECTION_GLOBAL, "web x-frame-options header",
30
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "web x-frame-options header",
31
CONFIG_SECTION_WEB, "x-frame-options response header");
32
33
- config_move(CONFIG_SECTION_GLOBAL, "enable web responses gzip compression",
33
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "enable web responses gzip compression",
34
CONFIG_SECTION_WEB, "enable gzip compression");
35
36
- config_move(CONFIG_SECTION_GLOBAL, "web compression strategy",
36
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "web compression strategy",
37
CONFIG_SECTION_WEB, "gzip compression strategy");
38
39
- config_move(CONFIG_SECTION_GLOBAL, "web compression level",
39
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "web compression level",
40
CONFIG_SECTION_WEB, "gzip compression level");
41
42
- config_move(CONFIG_SECTION_GLOBAL, "config directory",
42
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "config directory",
43
CONFIG_SECTION_DIRECTORIES, "config");
44
45
- config_move(CONFIG_SECTION_GLOBAL, "stock config directory",
45
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "stock config directory",
46
CONFIG_SECTION_DIRECTORIES, "stock config");
47
48
- config_move(CONFIG_SECTION_GLOBAL, "log directory",
48
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "log directory",
49
CONFIG_SECTION_DIRECTORIES, "log");
50
51
- config_move(CONFIG_SECTION_GLOBAL, "web files directory",
51
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "web files directory",
52
CONFIG_SECTION_DIRECTORIES, "web");
53
54
- config_move(CONFIG_SECTION_GLOBAL, "cache directory",
54
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "cache directory",
55
CONFIG_SECTION_DIRECTORIES, "cache");
56
57
- config_move(CONFIG_SECTION_GLOBAL, "lib directory",
57
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "lib directory",
58
CONFIG_SECTION_DIRECTORIES, "lib");
59
60
- config_move(CONFIG_SECTION_GLOBAL, "home directory",
60
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "home directory",
61
CONFIG_SECTION_DIRECTORIES, "home");
62
63
- config_move(CONFIG_SECTION_GLOBAL, "lock directory",
63
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "lock directory",
64
CONFIG_SECTION_DIRECTORIES, "lock");
65
66
- config_move(CONFIG_SECTION_GLOBAL, "plugins directory",
66
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "plugins directory",
67
CONFIG_SECTION_DIRECTORIES, "plugins");
68
69
- config_move(CONFIG_SECTION_HEALTH, "health configuration directory",
69
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "health configuration directory",
70
CONFIG_SECTION_DIRECTORIES, "health config");
71
72
- config_move(CONFIG_SECTION_HEALTH, "stock health configuration directory",
72
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "stock health configuration directory",
73
CONFIG_SECTION_DIRECTORIES, "stock health config");
74
75
- config_move(CONFIG_SECTION_REGISTRY, "registry db directory",
75
+ inicfg_move(&netdata_config, CONFIG_SECTION_REGISTRY, "registry db directory",
76
CONFIG_SECTION_DIRECTORIES, "registry");
77
78
- config_move(CONFIG_SECTION_GLOBAL, "debug log",
78
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "debug log",
79
CONFIG_SECTION_LOGS, "debug");
80
81
- config_move(CONFIG_SECTION_GLOBAL, "error log",
81
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "error log",
82
CONFIG_SECTION_LOGS, "error");
83
84
- config_move(CONFIG_SECTION_GLOBAL, "access log",
84
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "access log",
85
CONFIG_SECTION_LOGS, "access");
86
87
- config_move(CONFIG_SECTION_GLOBAL, "facility log",
87
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "facility log",
88
CONFIG_SECTION_LOGS, "facility");
89
90
- config_move(CONFIG_SECTION_GLOBAL, "errors flood protection period",
90
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "errors flood protection period",
91
CONFIG_SECTION_LOGS, "errors flood protection period");
92
93
- config_move(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection",
93
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "errors to trigger flood protection",
94
CONFIG_SECTION_LOGS, "errors to trigger flood protection");
95
96
- config_move(CONFIG_SECTION_GLOBAL, "debug flags",
96
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "debug flags",
97
CONFIG_SECTION_LOGS, "debug flags");
98
99
- config_move(CONFIG_SECTION_GLOBAL, "TZ environment variable",
99
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "TZ environment variable",
100
CONFIG_SECTION_ENV_VARS, "TZ");
101
102
- config_move(CONFIG_SECTION_PLUGINS, "PATH environment variable",
102
+ inicfg_move(&netdata_config, CONFIG_SECTION_PLUGINS, "PATH environment variable",
103
CONFIG_SECTION_ENV_VARS, "PATH");
104
105
- config_move(CONFIG_SECTION_PLUGINS, "PYTHONPATH environment variable",
105
+ inicfg_move(&netdata_config, CONFIG_SECTION_PLUGINS, "PYTHONPATH environment variable",
106
CONFIG_SECTION_ENV_VARS, "PYTHONPATH");
107
108
- config_move(CONFIG_SECTION_STATSD, "enabled",
108
+ inicfg_move(&netdata_config, CONFIG_SECTION_STATSD, "enabled",
109
CONFIG_SECTION_PLUGINS, "statsd");
110
111
- config_move(CONFIG_SECTION_GLOBAL, "memory mode",
111
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "memory mode",
112
CONFIG_SECTION_DB, "db");
113
114
- config_move(CONFIG_SECTION_DB, "mode",
114
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "mode",
115
CONFIG_SECTION_DB, "db");
116
117
- config_move(CONFIG_SECTION_GLOBAL, "history",
117
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "history",
118
CONFIG_SECTION_DB, "retention");
119
120
- config_move(CONFIG_SECTION_GLOBAL, "update every",
120
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "update every",
121
CONFIG_SECTION_DB, "update every");
122
123
- config_move(CONFIG_SECTION_GLOBAL, "page cache size",
123
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "page cache size",
124
CONFIG_SECTION_DB, "dbengine page cache size");
125
126
- config_move(CONFIG_SECTION_DB, "dbengine page cache size MB",
126
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "dbengine page cache size MB",
127
CONFIG_SECTION_DB, "dbengine page cache size");
128
129
- config_move(CONFIG_SECTION_DB, "dbengine extent cache size MB",
129
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "dbengine extent cache size MB",
130
CONFIG_SECTION_DB, "dbengine extent cache size");
131
132
- config_move(CONFIG_SECTION_DB, "page cache size",
132
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "page cache size",
133
CONFIG_SECTION_DB, "dbengine page cache size MB");
134
135
-// config_move(CONFIG_SECTION_GLOBAL, "page cache uses malloc",
135
+// inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "page cache uses malloc",
136
// CONFIG_SECTION_DB, "dbengine page cache with malloc");
137
//
138
-// config_move(CONFIG_SECTION_DB, "page cache with malloc",
138
+// inicfg_move(&netdata_config, CONFIG_SECTION_DB, "page cache with malloc",
139
// CONFIG_SECTION_DB, "dbengine page cache with malloc");
140
141
- config_move(CONFIG_SECTION_GLOBAL, "memory deduplication (ksm)",
141
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "memory deduplication (ksm)",
142
CONFIG_SECTION_DB, "memory deduplication (ksm)");
143
144
- config_move(CONFIG_SECTION_GLOBAL, "dbengine page fetch timeout",
144
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "dbengine page fetch timeout",
145
CONFIG_SECTION_DB, "dbengine page fetch timeout secs");
146
147
- config_move(CONFIG_SECTION_GLOBAL, "dbengine page fetch retries",
147
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "dbengine page fetch retries",
148
CONFIG_SECTION_DB, "dbengine page fetch retries");
149
150
- config_move(CONFIG_SECTION_GLOBAL, "dbengine extent pages",
150
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "dbengine extent pages",
151
CONFIG_SECTION_DB, "dbengine pages per extent");
152
153
- config_move(CONFIG_SECTION_GLOBAL, "cleanup obsolete charts after seconds",
153
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "cleanup obsolete charts after seconds",
154
CONFIG_SECTION_DB, "cleanup obsolete charts after");
155
156
- config_move(CONFIG_SECTION_DB, "cleanup obsolete charts after secs",
156
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "cleanup obsolete charts after secs",
157
CONFIG_SECTION_DB, "cleanup obsolete charts after");
158
159
- config_move(CONFIG_SECTION_GLOBAL, "gap when lost iterations above",
159
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "gap when lost iterations above",
160
CONFIG_SECTION_DB, "gap when lost iterations above");
161
162
- config_move(CONFIG_SECTION_GLOBAL, "cleanup orphan hosts after seconds",
162
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "cleanup orphan hosts after seconds",
163
CONFIG_SECTION_DB, "cleanup orphan hosts after");
164
165
- config_move(CONFIG_SECTION_DB, "cleanup orphan hosts after secs",
165
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "cleanup orphan hosts after secs",
166
CONFIG_SECTION_DB, "cleanup orphan hosts after");
167
168
- config_move(CONFIG_SECTION_DB, "cleanup ephemeral hosts after secs",
168
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "cleanup ephemeral hosts after secs",
169
CONFIG_SECTION_DB, "cleanup ephemeral hosts after");
170
171
- config_move(CONFIG_SECTION_DB, "seconds to replicate",
171
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "seconds to replicate",
172
CONFIG_SECTION_DB, "replication period");
173
174
- config_move(CONFIG_SECTION_DB, "seconds per replication step",
174
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, "seconds per replication step",
175
CONFIG_SECTION_DB, "replication step");
176
177
- config_move(CONFIG_SECTION_GLOBAL, "enable zero metrics",
177
+ inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "enable zero metrics",
178
CONFIG_SECTION_DB, "enable zero metrics");
179
180
- config_move(CONFIG_SECTION_CLOUD, "query thread count",
180
+ inicfg_move(&netdata_config, CONFIG_SECTION_CLOUD, "query thread count",
181
CONFIG_SECTION_CLOUD, "query threads");
182
183
// ----------------------------------------------------------------------------------------------------------------
184
// global statistics -> telemetry -> pulse
185
186
- config_move(CONFIG_SECTION_PLUGINS, "netdata monitoring",
186
+ inicfg_move(&netdata_config, CONFIG_SECTION_PLUGINS, "netdata monitoring",
187
CONFIG_SECTION_PLUGINS, "netdata pulse");
188
189
- config_move(CONFIG_SECTION_PLUGINS, "netdata telemetry",
189
+ inicfg_move(&netdata_config, CONFIG_SECTION_PLUGINS, "netdata telemetry",
190
CONFIG_SECTION_PLUGINS, "netdata pulse");
191
192
- config_move(CONFIG_SECTION_PLUGINS, "netdata monitoring extended",
192
+ inicfg_move(&netdata_config, CONFIG_SECTION_PLUGINS, "netdata monitoring extended",
193
CONFIG_SECTION_PULSE, "extended");
194
195
- config_move("telemetry", "extended telemetry",
195
+ inicfg_move(&netdata_config, "telemetry", "extended telemetry",
196
CONFIG_SECTION_PULSE, "extended");
197
198
- config_move("global statistics", "update every",
198
+ inicfg_move(&netdata_config, "global statistics", "update every",
199
CONFIG_SECTION_PULSE, "update every");
200
201
- config_move("telemetry", "update every",
201
+ inicfg_move(&netdata_config, "telemetry", "update every",
202
CONFIG_SECTION_PULSE, "update every");
203
204
@@ -206,15 +206,15 @@ void netdata_conf_backwards_compatibility(void) {
206
207
bool found_old_config = false;
208
209
- if(config_move(CONFIG_SECTION_GLOBAL, "dbengine disk space",
209
+ if(inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "dbengine disk space",
210
CONFIG_SECTION_DB, "dbengine tier 0 retention size") != -1)
211
found_old_config = true;
212
213
- if(config_move(CONFIG_SECTION_GLOBAL, "dbengine multihost disk space",
213
+ if(inicfg_move(&netdata_config, CONFIG_SECTION_GLOBAL, "dbengine multihost disk space",
214
CONFIG_SECTION_DB, "dbengine tier 0 retention size") != -1)
215
found_old_config = true;
216
217
- if(config_move(CONFIG_SECTION_DB, "dbengine disk space MB",
217
+ if(inicfg_move(&netdata_config, CONFIG_SECTION_DB, "dbengine disk space MB",
218
CONFIG_SECTION_DB, "dbengine tier 0 retention size") != -1)
219
found_old_config = true;
220
@@ -223,7 +223,7 @@ void netdata_conf_backwards_compatibility(void) {
223
224
snprintfz(old_config, sizeof(old_config), "dbengine tier %zu retention days", tier);
225
snprintfz(new_config, sizeof(new_config), "dbengine tier %zu retention time", tier);
226
- config_move(CONFIG_SECTION_DB, old_config,
226
+ inicfg_move(&netdata_config, CONFIG_SECTION_DB, old_config,
227
CONFIG_SECTION_DB, new_config);
228
229
if(tier == 0)
@@ -231,13 +231,13 @@ void netdata_conf_backwards_compatibility(void) {
231
else
232
snprintfz(old_config, sizeof(old_config), "dbengine tier %zu multihost disk space MB", tier);
233
snprintfz(new_config, sizeof(new_config), "dbengine tier %zu retention size", tier);
234
- if(config_move(CONFIG_SECTION_DB, old_config,
234
+ if(inicfg_move(&netdata_config, CONFIG_SECTION_DB, old_config,
235
CONFIG_SECTION_DB, new_config) != -1 && tier == 0)
236
found_old_config = true;
237
238
snprintfz(old_config, sizeof(old_config), "dbengine tier %zu disk space MB", tier);
239
snprintfz(new_config, sizeof(new_config), "dbengine tier %zu retention size", tier);
240
- if(config_move(CONFIG_SECTION_DB, old_config,
240
+ if(inicfg_move(&netdata_config, CONFIG_SECTION_DB, old_config,
241
CONFIG_SECTION_DB, new_config) != -1 && tier == 0)
242
found_old_config = true;
243
}
@@ -246,51 +246,51 @@ void netdata_conf_backwards_compatibility(void) {
246
247
// ----------------------------------------------------------------------------------------------------------------
248
249
- config_move(CONFIG_SECTION_LOGS, "error",
249
+ inicfg_move(&netdata_config, CONFIG_SECTION_LOGS, "error",
250
CONFIG_SECTION_LOGS, "daemon");
251
252
- config_move(CONFIG_SECTION_LOGS, "severity level",
252
+ inicfg_move(&netdata_config, CONFIG_SECTION_LOGS, "severity level",
253
CONFIG_SECTION_LOGS, "level");
254
255
- config_move(CONFIG_SECTION_LOGS, "errors to trigger flood protection",
255
+ inicfg_move(&netdata_config, CONFIG_SECTION_LOGS, "errors to trigger flood protection",
256
CONFIG_SECTION_LOGS, "logs to trigger flood protection");
257
258
- config_move(CONFIG_SECTION_LOGS, "errors flood protection period",
258
+ inicfg_move(&netdata_config, CONFIG_SECTION_LOGS, "errors flood protection period",
259
CONFIG_SECTION_LOGS, "logs flood protection period");
260
261
- config_move(CONFIG_SECTION_HEALTH, "is ephemeral",
261
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "is ephemeral",
262
CONFIG_SECTION_GLOBAL, "is ephemeral node");
263
264
- config_move(CONFIG_SECTION_HEALTH, "has unstable connection",
264
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "has unstable connection",
265
CONFIG_SECTION_GLOBAL, "has unstable connection");
266
267
- config_move(CONFIG_SECTION_HEALTH, "run at least every seconds",
267
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "run at least every seconds",
268
CONFIG_SECTION_HEALTH, "run at least every");
269
270
- config_move(CONFIG_SECTION_HEALTH, "postpone alarms during hibernation for seconds",
270
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "postpone alarms during hibernation for seconds",
271
CONFIG_SECTION_HEALTH, "postpone alarms during hibernation for");
272
273
- config_move(CONFIG_SECTION_HEALTH, "health log history",
273
+ inicfg_move(&netdata_config, CONFIG_SECTION_HEALTH, "health log history",
274
CONFIG_SECTION_HEALTH, "health log retention");
275
276
- config_move(CONFIG_SECTION_REGISTRY, "registry expire idle persons days",
276
+ inicfg_move(&netdata_config, CONFIG_SECTION_REGISTRY, "registry expire idle persons days",
277
CONFIG_SECTION_REGISTRY, "registry expire idle persons");
278
279
- config_move(CONFIG_SECTION_WEB, "disconnect idle clients after seconds",
279
+ inicfg_move(&netdata_config, CONFIG_SECTION_WEB, "disconnect idle clients after seconds",
280
CONFIG_SECTION_WEB, "disconnect idle clients after");
281
282
- config_move(CONFIG_SECTION_WEB, "accept a streaming request every seconds",
282
+ inicfg_move(&netdata_config, CONFIG_SECTION_WEB, "accept a streaming request every seconds",
283
CONFIG_SECTION_WEB, "accept a streaming request every");
284
285
- config_move(CONFIG_SECTION_STATSD, "set charts as obsolete after secs",
285
+ inicfg_move(&netdata_config, CONFIG_SECTION_STATSD, "set charts as obsolete after secs",
286
CONFIG_SECTION_STATSD, "set charts as obsolete after");
287
288
- config_move(CONFIG_SECTION_STATSD, "disconnect idle tcp clients after seconds",
288
+ inicfg_move(&netdata_config, CONFIG_SECTION_STATSD, "disconnect idle tcp clients after seconds",
289
CONFIG_SECTION_STATSD, "disconnect idle tcp clients after");
290
291
- config_move("plugin:idlejitter", "loop time in ms",
291
+ inicfg_move(&netdata_config, "plugin:idlejitter", "loop time in ms",
292
"plugin:idlejitter", "loop time");
293
294
- config_move("plugin:proc:/sys/class/infiniband", "refresh ports state every seconds",
294
+ inicfg_move(&netdata_config, "plugin:proc:/sys/class/infiniband", "refresh ports state every seconds",
295
"plugin:proc:/sys/class/infiniband", "refresh ports state every");
296
}
src/daemon/config/netdata-conf-cloud.c
+2
-2
@@ -8,11 +8,11 @@ size_t netdata_conf_cloud_query_threads(void) {
8
size_t threads = MIN(cpus * (netdata_conf_is_parent() ? 2 : 1), (size_t)libuv_worker_threads / 2);
9
threads = MAX(threads, 6);
10
11
- threads = config_get_number(CONFIG_SECTION_CLOUD, "query threads", threads);
11
+ threads = inicfg_get_number(&netdata_config, CONFIG_SECTION_CLOUD, "query threads", threads);
12
if(threads < 1) {
13
netdata_log_error("[" CONFIG_SECTION_CLOUD "].query threads in netdata.conf needs to be at least 1. Overwriting it.");
14
threads = 1;
15
- config_set_number(CONFIG_SECTION_CLOUD, "query threads", threads);
15
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_CLOUD, "query threads", threads);
16
}
17
return threads;
18
}
src/daemon/config/netdata-conf-db.c
+50
-50
@@ -39,7 +39,7 @@ static void netdata_conf_dbengine_pre_logs(void) {
39
// ------------------------------------------------------------------------
40
// get default Database Engine page type
41
42
- const char *page_type = config_get(CONFIG_SECTION_DB, "dbengine page type", "gorilla");
42
+ const char *page_type = inicfg_get(&netdata_config, CONFIG_SECTION_DB, "dbengine page type", "gorilla");
43
if (strcmp(page_type, "gorilla") == 0)
44
tier_page_type[0] = RRDENG_PAGE_TYPE_GORILLA_32BIT;
45
else if (strcmp(page_type, "raw") == 0)
@@ -52,19 +52,19 @@ static void netdata_conf_dbengine_pre_logs(void) {
52
// ------------------------------------------------------------------------
53
// get default Database Engine page cache size in MiB
54
55
- default_rrdeng_page_cache_mb = (int) config_get_size_mb(CONFIG_SECTION_DB, "dbengine page cache size", default_rrdeng_page_cache_mb);
56
- default_rrdeng_extent_cache_mb = (int) config_get_size_mb(CONFIG_SECTION_DB, "dbengine extent cache size", default_rrdeng_extent_cache_mb);
57
- db_engine_journal_check = config_get_boolean(CONFIG_SECTION_DB, "dbengine enable journal integrity check", CONFIG_BOOLEAN_NO);
55
+ default_rrdeng_page_cache_mb = (int) inicfg_get_size_mb(&netdata_config, CONFIG_SECTION_DB, "dbengine page cache size", default_rrdeng_page_cache_mb);
56
+ default_rrdeng_extent_cache_mb = (int) inicfg_get_size_mb(&netdata_config, CONFIG_SECTION_DB, "dbengine extent cache size", default_rrdeng_extent_cache_mb);
57
+ db_engine_journal_check = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_DB, "dbengine enable journal integrity check", CONFIG_BOOLEAN_NO);
58
59
if(default_rrdeng_extent_cache_mb < 0) {
60
default_rrdeng_extent_cache_mb = 0;
61
- config_set_size_mb(CONFIG_SECTION_DB, "dbengine extent cache size", default_rrdeng_extent_cache_mb);
61
+ inicfg_set_size_mb(&netdata_config, CONFIG_SECTION_DB, "dbengine extent cache size", default_rrdeng_extent_cache_mb);
62
}
63
64
if(default_rrdeng_page_cache_mb < RRDENG_MIN_PAGE_CACHE_SIZE_MB) {
65
netdata_log_error("Invalid page cache size %d given. Defaulting to %d.", default_rrdeng_page_cache_mb, RRDENG_MIN_PAGE_CACHE_SIZE_MB);
66
default_rrdeng_page_cache_mb = RRDENG_MIN_PAGE_CACHE_SIZE_MB;
67
- config_set_size_mb(CONFIG_SECTION_DB, "dbengine page cache size", default_rrdeng_page_cache_mb);
67
+ inicfg_set_size_mb(&netdata_config, CONFIG_SECTION_DB, "dbengine page cache size", default_rrdeng_page_cache_mb);
68
}
69
70
// ------------------------------------------------------------------------
@@ -72,18 +72,18 @@ static void netdata_conf_dbengine_pre_logs(void) {
72
//
73
// // if (!config_exists(CONFIG_SECTION_DB, "dbengine disk space MB") && !config_exists(CONFIG_SECTION_DB, "dbengine multihost disk space MB"))
74
//
75
- // default_rrdeng_disk_quota_mb = (int) config_get_number(CONFIG_SECTION_DB, "dbengine disk space MB", default_rrdeng_disk_quota_mb);
75
+ // default_rrdeng_disk_quota_mb = (int) inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "dbengine disk space MB", default_rrdeng_disk_quota_mb);
76
// if(default_rrdeng_disk_quota_mb < RRDENG_MIN_DISK_SPACE_MB) {
77
// netdata_log_error("Invalid dbengine disk space %d given. Defaulting to %d.", default_rrdeng_disk_quota_mb, RRDENG_MIN_DISK_SPACE_MB);
78
// default_rrdeng_disk_quota_mb = RRDENG_MIN_DISK_SPACE_MB;
79
- // config_set_number(CONFIG_SECTION_DB, "dbengine disk space MB", default_rrdeng_disk_quota_mb);
79
+ // inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "dbengine disk space MB", default_rrdeng_disk_quota_mb);
80
// }
81
//
82
- // default_multidb_disk_quota_mb = (int) config_get_number(CONFIG_SECTION_DB, "dbengine multihost disk space MB", compute_multidb_diskspace());
82
+ // default_multidb_disk_quota_mb = (int) inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "dbengine multihost disk space MB", compute_multidb_diskspace());
83
// if(default_multidb_disk_quota_mb < RRDENG_MIN_DISK_SPACE_MB) {
84
// netdata_log_error("Invalid multidb disk space %d given. Defaulting to %d.", default_multidb_disk_quota_mb, default_rrdeng_disk_quota_mb);
85
// default_multidb_disk_quota_mb = default_rrdeng_disk_quota_mb;
86
- // config_set_number(CONFIG_SECTION_DB, "dbengine multihost disk space MB", default_multidb_disk_quota_mb);
86
+ // inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "dbengine multihost disk space MB", default_multidb_disk_quota_mb);
87
// }
88
89
#else
@@ -112,7 +112,7 @@ void *dbengine_tier_init(void *ptr) {
112
113
RRD_BACKFILL get_dbengine_backfill(RRD_BACKFILL backfill)
114
{
115
- const char *bf = config_get(
115
+ const char *bf = inicfg_get(&netdata_config,
116
CONFIG_SECTION_DB,
117
"dbengine tier backfill",
118
backfill == RRD_BACKFILL_NEW ? "new" :
@@ -127,7 +127,7 @@ RRD_BACKFILL get_dbengine_backfill(RRD_BACKFILL backfill)
127
backfill = RRD_BACKFILL_NONE;
128
else {
129
nd_log(NDLS_DAEMON, NDLP_WARNING, "DBENGINE: unknown backfill value '%s', assuming 'new'", bf);
130
- config_set(CONFIG_SECTION_DB, "dbengine tier backfill", "new");
130
+ inicfg_set(&netdata_config, CONFIG_SECTION_DB, "dbengine tier backfill", "new");
131
backfill = RRD_BACKFILL_NEW;
132
}
133
return backfill;
@@ -153,8 +153,8 @@ void netdata_conf_dbengine_init(const char *hostname) {
153
}
154
155
if(dbengine_out_of_memory_protection) {
156
- dbengine_use_all_ram_for_caches = config_get_boolean(CONFIG_SECTION_DB, "dbengine use all ram for caches", dbengine_use_all_ram_for_caches);
157
- dbengine_out_of_memory_protection = config_get_size_bytes(CONFIG_SECTION_DB, "dbengine out of memory protection", dbengine_out_of_memory_protection);
156
+ dbengine_use_all_ram_for_caches = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_DB, "dbengine use all ram for caches", dbengine_use_all_ram_for_caches);
157
+ dbengine_out_of_memory_protection = inicfg_get_size_bytes(&netdata_config, CONFIG_SECTION_DB, "dbengine out of memory protection", dbengine_out_of_memory_protection);
158
159
char buf_total[64], buf_avail[64], buf_oom[64];
160
size_snprintf(buf_total, sizeof(buf_total), sm.ram_total_bytes, "B", false);
@@ -177,9 +177,9 @@ void netdata_conf_dbengine_init(const char *hostname) {
177
178
// ----------------------------------------------------------------------------------------------------------------
179
180
- dbengine_use_direct_io = config_get_boolean(CONFIG_SECTION_DB, "dbengine use direct io", dbengine_use_direct_io);
180
+ dbengine_use_direct_io = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_DB, "dbengine use direct io", dbengine_use_direct_io);
181
182
- unsigned read_num = (unsigned)config_get_number(CONFIG_SECTION_DB, "dbengine pages per extent", DEFAULT_PAGES_PER_EXTENT);
182
+ unsigned read_num = (unsigned)inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "dbengine pages per extent", DEFAULT_PAGES_PER_EXTENT);
183
if (read_num > 0 && read_num <= DEFAULT_PAGES_PER_EXTENT)
184
rrdeng_pages_per_extent = read_num;
185
else {
@@ -187,15 +187,15 @@ void netdata_conf_dbengine_init(const char *hostname) {
187
"Invalid dbengine pages per extent %u given. Using %u.",
188
read_num, rrdeng_pages_per_extent);
189
190
- config_set_number(CONFIG_SECTION_DB, "dbengine pages per extent", rrdeng_pages_per_extent);
190
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "dbengine pages per extent", rrdeng_pages_per_extent);
191
}
192
193
- nd_profile.storage_tiers = config_get_number(CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
193
+ nd_profile.storage_tiers = inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
194
if(nd_profile.storage_tiers < 1) {
195
nd_log(NDLS_DAEMON, NDLP_WARNING, "At least 1 storage tier is required. Assuming 1.");
196
197
nd_profile.storage_tiers = 1;
198
- config_set_number(CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
198
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
199
}
200
if(nd_profile.storage_tiers > RRD_STORAGE_TIERS) {
201
nd_log(NDLS_DAEMON, NDLP_WARNING,
@@ -203,19 +203,19 @@ void netdata_conf_dbengine_init(const char *hostname) {
203
RRD_STORAGE_TIERS, RRD_STORAGE_TIERS);
204
205
nd_profile.storage_tiers = RRD_STORAGE_TIERS;
206
- config_set_number(CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
206
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
207
}
208
209
new_dbengine_defaults =
210
(!legacy_multihost_db_space &&
211
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 1 update every iterations") &&
212
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 2 update every iterations") &&
213
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 3 update every iterations") &&
214
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 4 update every iterations") &&
215
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 1 retention size") &&
216
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 2 retention size") &&
217
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 3 retention size") &&
218
- !config_exists(CONFIG_SECTION_DB, "dbengine tier 4 retention size"));
211
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 1 update every iterations") &&
212
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 2 update every iterations") &&
213
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 3 update every iterations") &&
214
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 4 update every iterations") &&
215
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 1 retention size") &&
216
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 2 retention size") &&
217
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 3 retention size") &&
218
+ !inicfg_exists(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 4 retention size"));
219
220
default_backfill = get_dbengine_backfill(RRD_BACKFILL_NEW);
221
char dbengineconfig[200 + 1];
@@ -226,10 +226,10 @@ void netdata_conf_dbengine_init(const char *hostname) {
226
for (size_t tier = 1; tier < nd_profile.storage_tiers; tier++) {
227
grouping_iterations = storage_tiers_grouping_iterations[tier];
228
snprintfz(dbengineconfig, sizeof(dbengineconfig) - 1, "dbengine tier %zu update every iterations", tier);
229
- grouping_iterations = config_get_number(CONFIG_SECTION_DB, dbengineconfig, grouping_iterations);
229
+ grouping_iterations = inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, dbengineconfig, grouping_iterations);
230
if(grouping_iterations < 2) {
231
grouping_iterations = 2;
232
- config_set_number(CONFIG_SECTION_DB, dbengineconfig, grouping_iterations);
232
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, dbengineconfig, grouping_iterations);
233
nd_log(NDLS_DAEMON, NDLP_WARNING,
234
"DBENGINE on '%s': 'dbegnine tier %zu update every iterations' cannot be less than 2. Assuming 2.",
235
hostname, tier);
@@ -237,11 +237,11 @@ void netdata_conf_dbengine_init(const char *hostname) {
237
storage_tiers_grouping_iterations[tier] = grouping_iterations;
238
}
239
240
- default_multidb_disk_quota_mb = (int) config_get_size_mb(CONFIG_SECTION_DB, "dbengine tier 0 retention size", RRDENG_DEFAULT_TIER_DISK_SPACE_MB);
240
+ default_multidb_disk_quota_mb = (int) inicfg_get_size_mb(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 0 retention size", RRDENG_DEFAULT_TIER_DISK_SPACE_MB);
241
if(default_multidb_disk_quota_mb && default_multidb_disk_quota_mb < RRDENG_MIN_DISK_SPACE_MB) {
242
netdata_log_error("Invalid disk space %d for tier 0 given. Defaulting to %d.", default_multidb_disk_quota_mb, RRDENG_MIN_DISK_SPACE_MB);
243
default_multidb_disk_quota_mb = RRDENG_MIN_DISK_SPACE_MB;
244
- config_set_size_mb(CONFIG_SECTION_DB, "dbengine tier 0 retention size", default_multidb_disk_quota_mb);
244
+ inicfg_set_size_mb(&netdata_config, CONFIG_SECTION_DB, "dbengine tier 0 retention size", default_multidb_disk_quota_mb);
245
}
246
247
#ifdef OS_WINDOWS
@@ -272,10 +272,10 @@ void netdata_conf_dbengine_init(const char *hostname) {
272
273
int disk_space_mb = tier ? RRDENG_DEFAULT_TIER_DISK_SPACE_MB : default_multidb_disk_quota_mb;
274
snprintfz(dbengineconfig, sizeof(dbengineconfig) - 1, "dbengine tier %zu retention size", tier);
275
- disk_space_mb = config_get_size_mb(CONFIG_SECTION_DB, dbengineconfig, disk_space_mb);
275
+ disk_space_mb = inicfg_get_size_mb(&netdata_config, CONFIG_SECTION_DB, dbengineconfig, disk_space_mb);
276
277
snprintfz(dbengineconfig, sizeof(dbengineconfig) - 1, "dbengine tier %zu retention time", tier);
278
- storage_tiers_retention_days[tier] = config_get_duration_days(
278
+ storage_tiers_retention_days[tier] = inicfg_get_duration_days(&netdata_config,
279
CONFIG_SECTION_DB, dbengineconfig, new_dbengine_defaults ? storage_tiers_retention_days[tier] : 0);
280
281
tiers_init[tier].disk_space_mb = (int) disk_space_mb;
@@ -324,14 +324,14 @@ void netdata_conf_dbengine_init(const char *hostname) {
324
325
dbengine_enabled = true;
326
#else
327
- nd_profile.storage_tiers = config_get_number(CONFIG_SECTION_DB, "storage tiers", 1);
327
+ nd_profile.storage_tiers = inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "storage tiers", 1);
328
if(nd_profile.storage_tiers != 1) {
329
nd_log(NDLS_DAEMON, NDLP_WARNING,
330
"DBENGINE is not available on '%s', so only 1 database tier can be supported.",
331
hostname);
332
333
nd_profile.storage_tiers = 1;
334
- config_set_number(CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
334
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "storage tiers", nd_profile.storage_tiers);
335
}
336
dbengine_enabled = false;
337
#endif
@@ -345,36 +345,36 @@ void netdata_conf_section_db(void) {
345
// ------------------------------------------------------------------------
346
347
rrdhost_free_orphan_time_s =
348
- config_get_duration_seconds(CONFIG_SECTION_DB, "cleanup orphan hosts after", rrdhost_free_orphan_time_s);
348
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "cleanup orphan hosts after", rrdhost_free_orphan_time_s);
349
350
// ------------------------------------------------------------------------
351
// get default database update frequency
352
353
- nd_profile.update_every = (int) config_get_duration_seconds(CONFIG_SECTION_DB, "update every", nd_profile.update_every);
353
+ nd_profile.update_every = (int) inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "update every", nd_profile.update_every);
354
if(nd_profile.update_every < UPDATE_EVERY_MIN) {
355
nd_log(NDLS_DAEMON, NDLP_WARNING,
356
"Data collection frequency in netdata.conf ([" CONFIG_SECTION_DB "].update every), changed from %d to %d",
357
(int)nd_profile.update_every, UPDATE_EVERY_MIN);
358
nd_profile.update_every = UPDATE_EVERY_MIN;
359
- config_set_duration_seconds(CONFIG_SECTION_DB, "update every", nd_profile.update_every);
359
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "update every", nd_profile.update_every);
360
}
361
if(nd_profile.update_every > UPDATE_EVERY_MAX) {
362
nd_log(NDLS_DAEMON, NDLP_WARNING,
363
"Data collection frequency in netdata.conf ([" CONFIG_SECTION_DB "].update every), changed from %d to %d",
364
(int)nd_profile.update_every, UPDATE_EVERY_MIN);
365
nd_profile.update_every = UPDATE_EVERY_MAX;
366
- config_set_duration_seconds(CONFIG_SECTION_DB, "update every", nd_profile.update_every);
366
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "update every", nd_profile.update_every);
367
}
368
369
// ------------------------------------------------------------------------
370
// get the database selection
371
372
{
373
- const char *mode = config_get(CONFIG_SECTION_DB, "db", rrd_memory_mode_name(default_rrd_memory_mode));
373
+ const char *mode = inicfg_get(&netdata_config, CONFIG_SECTION_DB, "db", rrd_memory_mode_name(default_rrd_memory_mode));
374
default_rrd_memory_mode = rrd_memory_mode_id(mode);
375
if(strcmp(mode, rrd_memory_mode_name(default_rrd_memory_mode)) != 0) {
376
netdata_log_error("Invalid memory mode '%s' given. Using '%s'", mode, rrd_memory_mode_name(default_rrd_memory_mode));
377
- config_set(CONFIG_SECTION_DB, "db", rrd_memory_mode_name(default_rrd_memory_mode));
377
+ inicfg_set(&netdata_config, CONFIG_SECTION_DB, "db", rrd_memory_mode_name(default_rrd_memory_mode));
378
}
379
}
380
@@ -382,13 +382,13 @@ void netdata_conf_section_db(void) {
382
// get default database size
383
384
if(default_rrd_memory_mode != RRD_DB_MODE_DBENGINE && default_rrd_memory_mode != RRD_DB_MODE_NONE) {
385
- default_rrd_history_entries = (int)config_get_duration_seconds(
385
+ default_rrd_history_entries = (int)inicfg_get_duration_seconds(&netdata_config,
386
CONFIG_SECTION_DB, "retention",
387
align_entries_to_pagesize(default_rrd_memory_mode, RRD_DEFAULT_HISTORY_ENTRIES));
388
389
long h = align_entries_to_pagesize(default_rrd_memory_mode, default_rrd_history_entries);
390
if (h != default_rrd_history_entries) {
391
- config_set_duration_seconds(CONFIG_SECTION_DB, "retention", h);
391
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "retention", h);
392
default_rrd_history_entries = (int)h;
393
}
394
}
@@ -397,16 +397,16 @@ void netdata_conf_section_db(void) {
397
// get KSM settings
398
399
#ifdef MADV_MERGEABLE
400
- enable_ksm = config_get_boolean_ondemand(CONFIG_SECTION_DB, "memory deduplication (ksm)", enable_ksm);
400
+ enable_ksm = inicfg_get_boolean_ondemand(&netdata_config, CONFIG_SECTION_DB, "memory deduplication (ksm)", enable_ksm);
401
#endif
402
403
// --------------------------------------------------------------------
404
405
rrdhost_free_ephemeral_time_s =
406
- config_get_duration_seconds(CONFIG_SECTION_DB, "cleanup ephemeral hosts after", rrdhost_free_ephemeral_time_s);
406
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "cleanup ephemeral hosts after", rrdhost_free_ephemeral_time_s);
407
408
rrdset_free_obsolete_time_s =
409
- config_get_duration_seconds(CONFIG_SECTION_DB, "cleanup obsolete charts after", rrdset_free_obsolete_time_s);
409
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "cleanup obsolete charts after", rrdset_free_obsolete_time_s);
410
411
// Current chart locking and invalidation scheme doesn't prevent Netdata from segmentation faults if a short
412
// cleanup delay is set. Extensive stress tests showed that 10 seconds is quite a safe delay. Look at
@@ -414,13 +414,13 @@ void netdata_conf_section_db(void) {
414
if (rrdset_free_obsolete_time_s < 10) {
415
rrdset_free_obsolete_time_s = 10;
416
netdata_log_info("The \"cleanup obsolete charts after\" option was set to 10 seconds.");
417
- config_set_duration_seconds(CONFIG_SECTION_DB, "cleanup obsolete charts after", rrdset_free_obsolete_time_s);
417
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "cleanup obsolete charts after", rrdset_free_obsolete_time_s);
418
}
419
420
- gap_when_lost_iterations_above = (int)config_get_number(CONFIG_SECTION_DB, "gap when lost iterations above", gap_when_lost_iterations_above);
420
+ gap_when_lost_iterations_above = (int)inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "gap when lost iterations above", gap_when_lost_iterations_above);
421
if (gap_when_lost_iterations_above < 1) {
422
gap_when_lost_iterations_above = 1;
423
- config_set_number(CONFIG_SECTION_DB, "gap when lost iterations above", gap_when_lost_iterations_above);
423
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "gap when lost iterations above", gap_when_lost_iterations_above);
424
}
425
gap_when_lost_iterations_above += 2;
426
src/daemon/config/netdata-conf-directories.c
+7
-7
@@ -6,7 +6,7 @@
6
static const char *get_varlib_subdir_from_config(const char *prefix, const char *dir) {
7
char filename[FILENAME_MAX + 1];
8
snprintfz(filename, FILENAME_MAX, "%s/%s", prefix, dir);
9
- return config_get(CONFIG_SECTION_DIRECTORIES, dir, filename);
9
+ return inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, dir, filename);
10
}
11
12
void netdata_conf_section_directories(void) {
@@ -17,12 +17,12 @@ void netdata_conf_section_directories(void) {
17
// ------------------------------------------------------------------------
18
// get system paths
19
20
- netdata_configured_user_config_dir = config_get(CONFIG_SECTION_DIRECTORIES, "config", netdata_configured_user_config_dir);
21
- netdata_configured_stock_config_dir = config_get(CONFIG_SECTION_DIRECTORIES, "stock config", netdata_configured_stock_config_dir);
22
- netdata_configured_log_dir = config_get(CONFIG_SECTION_DIRECTORIES, "log", netdata_configured_log_dir);
23
- netdata_configured_web_dir = config_get(CONFIG_SECTION_DIRECTORIES, "web", netdata_configured_web_dir);
24
- netdata_configured_cache_dir = config_get(CONFIG_SECTION_DIRECTORIES, "cache", netdata_configured_cache_dir);
25
- netdata_configured_varlib_dir = config_get(CONFIG_SECTION_DIRECTORIES, "lib", netdata_configured_varlib_dir);
20
+ netdata_configured_user_config_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "config", netdata_configured_user_config_dir);
21
+ netdata_configured_stock_config_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "stock config", netdata_configured_stock_config_dir);
22
+ netdata_configured_log_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "log", netdata_configured_log_dir);
23
+ netdata_configured_web_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "web", netdata_configured_web_dir);
24
+ netdata_configured_cache_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "cache", netdata_configured_cache_dir);
25
+ netdata_configured_varlib_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "lib", netdata_configured_varlib_dir);
26
27
netdata_configured_lock_dir = get_varlib_subdir_from_config(netdata_configured_varlib_dir, "lock");
28
netdata_configured_cloud_dir = get_varlib_subdir_from_config(netdata_configured_varlib_dir, "cloud.d");
src/daemon/config/netdata-conf-global.c
+11
-11
@@ -25,7 +25,7 @@ size_t netdata_conf_cpus(void) {
25
if(!p)
26
p = os_get_system_cpus_uncached();
27
28
- p = config_get_number(CONFIG_SECTION_GLOBAL, "cpu cores", p);
28
+ p = inicfg_get_number(&netdata_config, CONFIG_SECTION_GLOBAL, "cpu cores", p);
29
if(p < 1)
30
p = 1;
31
@@ -41,11 +41,11 @@ skip:
41
}
42
43
void netdata_conf_glibc_malloc_initialize(size_t wanted_arenas, size_t trim_threshold __maybe_unused) {
44
- wanted_arenas = config_get_number(CONFIG_SECTION_GLOBAL, "glibc malloc arena max for plugins", wanted_arenas);
44
+ wanted_arenas = inicfg_get_number(&netdata_config, CONFIG_SECTION_GLOBAL, "glibc malloc arena max for plugins", wanted_arenas);
45
if(wanted_arenas < 1 || wanted_arenas > os_get_system_cpus_cached(true)) {
46
if(wanted_arenas < 1) wanted_arenas = 1;
47
else wanted_arenas = os_get_system_cpus_cached(true);
48
- config_set_number(CONFIG_SECTION_GLOBAL, "glibc malloc arena max for plugins", wanted_arenas);
48
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_GLOBAL, "glibc malloc arena max for plugins", wanted_arenas);
49
nd_log(NDLS_DAEMON, NDLP_NOTICE,
50
"malloc arenas can be from 1 to %zu. Setting it to %zu",
51
os_get_system_cpus_cached(true), wanted_arenas);
@@ -56,11 +56,11 @@ void netdata_conf_glibc_malloc_initialize(size_t wanted_arenas, size_t trim_thre
56
setenv("MALLOC_ARENA_MAX", buf, true);
57
58
#if defined(HAVE_C_MALLOPT)
59
- wanted_arenas = config_get_number(CONFIG_SECTION_GLOBAL, "glibc malloc arena max for netdata", wanted_arenas);
59
+ wanted_arenas = inicfg_get_number(&netdata_config, CONFIG_SECTION_GLOBAL, "glibc malloc arena max for netdata", wanted_arenas);
60
if(wanted_arenas < 1 || wanted_arenas > os_get_system_cpus_cached(true)) {
61
if(wanted_arenas < 1) wanted_arenas = 1;
62
else wanted_arenas = os_get_system_cpus_cached(true);
63
- config_set_number(CONFIG_SECTION_GLOBAL, "glibc malloc arena max for netdata", wanted_arenas);
63
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_GLOBAL, "glibc malloc arena max for netdata", wanted_arenas);
64
nd_log(NDLS_DAEMON, NDLP_NOTICE,
65
"malloc arenas can be from 1 to %zu. Setting it to %zu",
66
os_get_system_cpus_cached(true), wanted_arenas);
@@ -85,10 +85,10 @@ static void libuv_initialize(void) {
85
libuv_worker_threads = MAX_LIBUV_WORKER_THREADS;
86
87
88
- libuv_worker_threads = config_get_number(CONFIG_SECTION_GLOBAL, "libuv worker threads", libuv_worker_threads);
88
+ libuv_worker_threads = inicfg_get_number(&netdata_config, CONFIG_SECTION_GLOBAL, "libuv worker threads", libuv_worker_threads);
89
if(libuv_worker_threads < MIN_LIBUV_WORKER_THREADS) {
90
libuv_worker_threads = MIN_LIBUV_WORKER_THREADS;
91
- config_set_number(CONFIG_SECTION_GLOBAL, "libuv worker threads", libuv_worker_threads);
91
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_GLOBAL, "libuv worker threads", libuv_worker_threads);
92
}
93
94
char buf[20 + 1];
@@ -100,14 +100,14 @@ void netdata_conf_section_global(void) {
100
// ------------------------------------------------------------------------
101
// get the hostname
102
103
- netdata_configured_host_prefix = config_get(CONFIG_SECTION_GLOBAL, "host access prefix", "");
103
+ netdata_configured_host_prefix = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "host access prefix", "");
104
(void) verify_netdata_host_prefix(true);
105
106
char buf[HOST_NAME_MAX * 4 + 1];
107
if (!os_hostname(buf, sizeof(buf), netdata_configured_host_prefix))
108
netdata_log_error("Cannot get machine hostname.");
109
110
- netdata_configured_hostname = config_get(CONFIG_SECTION_GLOBAL, "hostname", buf);
110
+ netdata_configured_hostname = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "hostname", buf);
111
netdata_log_debug(D_OPTIONS, "hostname set to '%s'", netdata_configured_hostname);
112
113
netdata_conf_section_directories();
@@ -130,11 +130,11 @@ void netdata_conf_section_global_run_as_user(const char **user) {
130
131
// IMPORTANT: this is required before web_files_uid()
132
if(getuid() == 0) {
133
- *user = config_get(CONFIG_SECTION_GLOBAL, "run as user", NETDATA_USER);
133
+ *user = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "run as user", NETDATA_USER);
134
}
135
else {
136
struct passwd *passwd = getpwuid(getuid());
137
- *user = config_get(CONFIG_SECTION_GLOBAL, "run as user", (passwd && passwd->pw_name)?passwd->pw_name:"");
137
+ *user = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "run as user", (passwd && passwd->pw_name)?passwd->pw_name:"");
138
}
139
}
140
src/daemon/config/netdata-conf-logs.c
+12
-12
@@ -7,7 +7,7 @@ static void debug_flags_initialize(void) {
7
// --------------------------------------------------------------------
8
// get the debugging flags from the configuration file
9
10
- const char *flags = config_get(CONFIG_SECTION_LOGS, "debug flags", "0x0000000000000000");
10
+ const char *flags = inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "debug flags", "0x0000000000000000");
11
nd_setenv("NETDATA_DEBUG_FLAGS", flags, 1);
12
13
debug_flags = strtoull(flags, NULL, 0);
@@ -29,18 +29,18 @@ void netdata_conf_section_logs(void) {
29
if(run) return;
30
run = true;
31
32
- nd_log_set_facility(config_get(CONFIG_SECTION_LOGS, "facility", "daemon"));
32
+ nd_log_set_facility(inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "facility", "daemon"));
33
34
time_t period = ND_LOG_DEFAULT_THROTTLE_PERIOD;
35
size_t logs = ND_LOG_DEFAULT_THROTTLE_LOGS;
36
- period = config_get_duration_seconds(CONFIG_SECTION_LOGS, "logs flood protection period", period);
37
- logs = (unsigned long)config_get_number(CONFIG_SECTION_LOGS, "logs to trigger flood protection", (long long int)logs);
36
+ period = inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_LOGS, "logs flood protection period", period);
37
+ logs = (unsigned long)inicfg_get_number(&netdata_config, CONFIG_SECTION_LOGS, "logs to trigger flood protection", (long long int)logs);
38
nd_log_set_flood_protection(logs, period);
39
40
const char *netdata_log_level = getenv("NETDATA_LOG_LEVEL");
41
netdata_log_level = netdata_log_level ? nd_log_id2priority(nd_log_priority2id(netdata_log_level)) : NDLP_INFO_STR;
42
43
- nd_log_set_priority_level(config_get(CONFIG_SECTION_LOGS, "level", netdata_log_level));
43
+ nd_log_set_priority_level(inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "level", netdata_log_level));
44
45
char filename[FILENAME_MAX + 1];
46
char* os_default_method = NULL;
@@ -61,19 +61,19 @@ void netdata_conf_section_logs(void) {
61
snprintfz(filename, FILENAME_MAX, "%s/debug.log", netdata_configured_log_dir);
62
#endif
63
64
- nd_log_set_user_settings(NDLS_DEBUG, config_get(CONFIG_SECTION_LOGS, "debug", filename));
64
+ nd_log_set_user_settings(NDLS_DEBUG, inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "debug", filename));
65
66
if(os_default_method)
67
snprintfz(filename, FILENAME_MAX, "%s", os_default_method);
68
else
69
snprintfz(filename, FILENAME_MAX, "%s/daemon.log", netdata_configured_log_dir);
70
- nd_log_set_user_settings(NDLS_DAEMON, config_get(CONFIG_SECTION_LOGS, "daemon", filename));
70
+ nd_log_set_user_settings(NDLS_DAEMON, inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "daemon", filename));
71
72
if(os_default_method)
73
snprintfz(filename, FILENAME_MAX, "%s", os_default_method);
74
else
75
snprintfz(filename, FILENAME_MAX, "%s/collector.log", netdata_configured_log_dir);
76
- nd_log_set_user_settings(NDLS_COLLECTORS, config_get(CONFIG_SECTION_LOGS, "collector", filename));
76
+ nd_log_set_user_settings(NDLS_COLLECTORS, inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "collector", filename));
77
78
#if defined(OS_WINDOWS)
79
// on windows, access log goes to windows events
@@ -81,15 +81,15 @@ void netdata_conf_section_logs(void) {
81
#else
82
snprintfz(filename, FILENAME_MAX, "%s/access.log", netdata_configured_log_dir);
83
#endif
84
- nd_log_set_user_settings(NDLS_ACCESS, config_get(CONFIG_SECTION_LOGS, "access", filename));
84
+ nd_log_set_user_settings(NDLS_ACCESS, inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "access", filename));
85
86
if(os_default_method)
87
snprintfz(filename, FILENAME_MAX, "%s", os_default_method);
88
else
89
snprintfz(filename, FILENAME_MAX, "%s/health.log", netdata_configured_log_dir);
90
- nd_log_set_user_settings(NDLS_HEALTH, config_get(CONFIG_SECTION_LOGS, "health", filename));
90
+ nd_log_set_user_settings(NDLS_HEALTH, inicfg_get(&netdata_config, CONFIG_SECTION_LOGS, "health", filename));
91
92
- aclklog_enabled = config_get_boolean(CONFIG_SECTION_CLOUD, "conversation log", CONFIG_BOOLEAN_NO);
92
+ aclklog_enabled = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_CLOUD, "conversation log", CONFIG_BOOLEAN_NO);
93
if (aclklog_enabled) {
94
#if defined(OS_WINDOWS)
95
// on windows, aclk log goes to windows events
@@ -97,7 +97,7 @@ void netdata_conf_section_logs(void) {
97
#else
98
snprintfz(filename, FILENAME_MAX, "%s/aclk.log", netdata_configured_log_dir);
99
#endif
100
- nd_log_set_user_settings(NDLS_ACLK, config_get(CONFIG_SECTION_CLOUD, "conversation log file", filename));
100
+ nd_log_set_user_settings(NDLS_ACLK, inicfg_get(&netdata_config, CONFIG_SECTION_CLOUD, "conversation log file", filename));
101
}
102
103
debug_flags_initialize();
src/daemon/config/netdata-conf-profile.c
+2
-2
@@ -52,7 +52,7 @@ ND_PROFILE nd_profile_detect_and_configure(bool recheck) {
52
CLEAN_BUFFER *wb = buffer_create(0, NULL);
53
ND_PROFILE_2buffer(wb, def_profile, " ");
54
55
- CLEAN_CHAR_P *s = strdupz(config_get(CONFIG_SECTION_GLOBAL, "profile", buffer_tostring(wb)));
55
+ CLEAN_CHAR_P *s = strdupz(inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "profile", buffer_tostring(wb)));
56
57
char *words[100];
58
size_t n = quoted_strings_splitter(s, words, _countof(words), isspace_map_whitespace);
@@ -80,7 +80,7 @@ ND_PROFILE nd_profile_detect_and_configure(bool recheck) {
80
if(pt != started) {
81
buffer_flush(wb);
82
ND_PROFILE_2buffer(wb, pt, " ");
83
- config_set(CONFIG_SECTION_GLOBAL, "profile", buffer_tostring(wb));
83
+ inicfg_set(&netdata_config, CONFIG_SECTION_GLOBAL, "profile", buffer_tostring(wb));
84
85
nd_log(NDLS_DAEMON, NDLP_WARNING,
86
"The netdata.conf setting [global].profile has been overwritten to '%s'",
src/daemon/config/netdata-conf-web.c
+24
-24
@@ -6,7 +6,7 @@
6
size_t netdata_conf_web_query_threads(void) {
7
// See https://github.com/netdata/netdata/issues/11081#issuecomment-831998240 for more details
8
if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_110) {
9
- config_set_number(CONFIG_SECTION_WEB, "web server threads", 1);
9
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_WEB, "web server threads", 1);
10
netdata_log_info("You are running an OpenSSL older than 1.1.0, web server will not enable multithreading.");
11
return 1;
12
}
@@ -15,17 +15,17 @@ size_t netdata_conf_web_query_threads(void) {
15
size_t threads = cpus * (netdata_conf_is_parent() ? 2 : 1);
16
threads = MAX(threads, 6);
17
18
- threads = config_get_number(CONFIG_SECTION_WEB, "web server threads", threads);
18
+ threads = inicfg_get_number(&netdata_config, CONFIG_SECTION_WEB, "web server threads", threads);
19
if(threads < 1) {
20
netdata_log_error("[" CONFIG_SECTION_WEB "].web server threads in netdata.conf needs to be at least 1. Overwriting it.");
21
threads = 1;
22
- config_set_number(CONFIG_SECTION_WEB, "web server threads", threads);
22
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_WEB, "web server threads", threads);
23
}
24
return threads;
25
}
26
27
static int make_dns_decision(const char *section_name, const char *config_name, const char *default_value, SIMPLE_PATTERN *p) {
28
- const char *value = config_get(section_name,config_name,default_value);
28
+ const char *value = inicfg_get(&netdata_config, section_name,config_name,default_value);
29
30
if(!strcmp("yes",value))
31
return 1;
@@ -46,7 +46,7 @@ void web_server_threading_selection(void) {
46
if(run) return;
47
run = true;
48
49
- web_server_mode = web_server_mode_id(config_get(CONFIG_SECTION_WEB, "mode", web_server_mode_name(web_server_mode)));
49
+ web_server_mode = web_server_mode_id(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "mode", web_server_mode_name(web_server_mode)));
50
51
int static_threaded = (web_server_mode == WEB_SERVER_MODE_STATIC_THREADED);
52
@@ -63,46 +63,46 @@ void netdata_conf_section_web(void) {
63
run = true;
64
65
web_client_timeout =
66
- (int)config_get_duration_seconds(CONFIG_SECTION_WEB, "disconnect idle clients after", web_client_timeout);
66
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_WEB, "disconnect idle clients after", web_client_timeout);
67
68
web_client_first_request_timeout =
69
- (int)config_get_duration_seconds(CONFIG_SECTION_WEB, "timeout for first request", web_client_first_request_timeout);
69
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_WEB, "timeout for first request", web_client_first_request_timeout);
70
71
web_client_streaming_rate_t =
72
- config_get_duration_seconds(CONFIG_SECTION_WEB, "accept a streaming request every", web_client_streaming_rate_t);
72
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_WEB, "accept a streaming request every", web_client_streaming_rate_t);
73
74
respect_web_browser_do_not_track_policy =
75
- config_get_boolean(CONFIG_SECTION_WEB, "respect do not track policy", respect_web_browser_do_not_track_policy);
76
- web_x_frame_options = config_get(CONFIG_SECTION_WEB, "x-frame-options response header", "");
75
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_WEB, "respect do not track policy", respect_web_browser_do_not_track_policy);
76
+ web_x_frame_options = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "x-frame-options response header", "");
77
if(!*web_x_frame_options)
78
web_x_frame_options = NULL;
79
80
web_allow_connections_from =
81
- simple_pattern_create(config_get(CONFIG_SECTION_WEB, "allow connections from", "localhost *"),
81
+ simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "allow connections from", "localhost *"),
82
NULL, SIMPLE_PATTERN_EXACT, true);
83
web_allow_connections_dns =
84
make_dns_decision(CONFIG_SECTION_WEB, "allow connections by dns", "heuristic", web_allow_connections_from);
85
web_allow_dashboard_from =
86
- simple_pattern_create(config_get(CONFIG_SECTION_WEB, "allow dashboard from", "localhost *"),
86
+ simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "allow dashboard from", "localhost *"),
87
NULL, SIMPLE_PATTERN_EXACT, true);
88
web_allow_dashboard_dns =
89
make_dns_decision(CONFIG_SECTION_WEB, "allow dashboard by dns", "heuristic", web_allow_dashboard_from);
90
web_allow_badges_from =
91
- simple_pattern_create(config_get(CONFIG_SECTION_WEB, "allow badges from", "*"), NULL, SIMPLE_PATTERN_EXACT,
91
+ simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "allow badges from", "*"), NULL, SIMPLE_PATTERN_EXACT,
92
true);
93
web_allow_badges_dns =
94
make_dns_decision(CONFIG_SECTION_WEB, "allow badges by dns", "heuristic", web_allow_badges_from);
95
web_allow_registry_from =
96
- simple_pattern_create(config_get(CONFIG_SECTION_REGISTRY, "allow from", "*"), NULL, SIMPLE_PATTERN_EXACT,
96
+ simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "allow from", "*"), NULL, SIMPLE_PATTERN_EXACT,
97
true);
98
web_allow_registry_dns = make_dns_decision(CONFIG_SECTION_REGISTRY, "allow by dns", "heuristic",
99
web_allow_registry_from);
100
- web_allow_streaming_from = simple_pattern_create(config_get(CONFIG_SECTION_WEB, "allow streaming from", "*"),
100
+ web_allow_streaming_from = simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "allow streaming from", "*"),
101
NULL, SIMPLE_PATTERN_EXACT, true);
102
web_allow_streaming_dns = make_dns_decision(CONFIG_SECTION_WEB, "allow streaming by dns", "heuristic",
103
web_allow_streaming_from);
104
// Note the default is not heuristic, the wildcards could match DNS but the intent is ip-addresses.
105
- web_allow_netdataconf_from = simple_pattern_create(config_get(CONFIG_SECTION_WEB, "allow netdata.conf from",
105
+ web_allow_netdataconf_from = simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "allow netdata.conf from",
106
"localhost fd* 10.* 192.168.* 172.16.* 172.17.* 172.18.*"
107
" 172.19.* 172.20.* 172.21.* 172.22.* 172.23.* 172.24.*"
108
" 172.25.* 172.26.* 172.27.* 172.28.* 172.29.* 172.30.*"
@@ -111,14 +111,14 @@ void netdata_conf_section_web(void) {
111
web_allow_netdataconf_dns =
112
make_dns_decision(CONFIG_SECTION_WEB, "allow netdata.conf by dns", "no", web_allow_netdataconf_from);
113
web_allow_mgmt_from =
114
- simple_pattern_create(config_get(CONFIG_SECTION_WEB, "allow management from", "localhost"),
114
+ simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "allow management from", "localhost"),
115
NULL, SIMPLE_PATTERN_EXACT, true);
116
web_allow_mgmt_dns =
117
make_dns_decision(CONFIG_SECTION_WEB, "allow management by dns","heuristic",web_allow_mgmt_from);
118
119
- web_enable_gzip = config_get_boolean(CONFIG_SECTION_WEB, "enable gzip compression", web_enable_gzip);
119
+ web_enable_gzip = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_WEB, "enable gzip compression", web_enable_gzip);
120
121
- const char *s = config_get(CONFIG_SECTION_WEB, "gzip compression strategy", "default");
121
+ const char *s = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "gzip compression strategy", "default");
122
if(!strcmp(s, "default"))
123
web_gzip_strategy = Z_DEFAULT_STRATEGY;
124
else if(!strcmp(s, "filtered"))
@@ -134,7 +134,7 @@ void netdata_conf_section_web(void) {
134
web_gzip_strategy = Z_DEFAULT_STRATEGY;
135
}
136
137
- web_gzip_level = (int)config_get_number(CONFIG_SECTION_WEB, "gzip compression level", 3);
137
+ web_gzip_level = (int)inicfg_get_number(&netdata_config, CONFIG_SECTION_WEB, "gzip compression level", 3);
138
if(web_gzip_level < 1) {
139
netdata_log_error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).", web_gzip_level);
140
web_gzip_level = 1;
@@ -152,13 +152,13 @@ void netdata_conf_web_security_init(void) {
152
153
char filename[FILENAME_MAX + 1];
154
snprintfz(filename, FILENAME_MAX, "%s/ssl/key.pem",netdata_configured_user_config_dir);
155
- netdata_ssl_security_key = config_get(CONFIG_SECTION_WEB, "ssl key", filename);
155
+ netdata_ssl_security_key = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "ssl key", filename);
156
157
snprintfz(filename, FILENAME_MAX, "%s/ssl/cert.pem",netdata_configured_user_config_dir);
158
- netdata_ssl_security_cert = config_get(CONFIG_SECTION_WEB, "ssl certificate", filename);
158
+ netdata_ssl_security_cert = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "ssl certificate", filename);
159
160
- tls_version = config_get(CONFIG_SECTION_WEB, "tls version", "1.3");
161
- tls_ciphers = config_get(CONFIG_SECTION_WEB, "tls ciphers", "none");
160
+ tls_version = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "tls version", "1.3");
161
+ tls_ciphers = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "tls ciphers", "none");
162
163
netdata_ssl_initialize_openssl();
164
}
src/daemon/config/netdata-conf.c
+3
-5
@@ -3,8 +3,6 @@
3
#include "netdata-conf.h"
4
#include "daemon/common.h"
5
6
-struct config netdata_config = APPCONFIG_INITIALIZER;
7
-
6
bool netdata_conf_load(char *filename, char overwrite_used, const char **user) {
7
static bool run = false;
8
if(run) return false;
@@ -15,20 +13,20 @@ bool netdata_conf_load(char *filename, char overwrite_used, const char **user) {
13
int ret = 0;
14
15
if(filename && *filename) {
18
- ret = config_load(filename, overwrite_used, NULL);
16
+ ret = inicfg_load(&netdata_config, filename, overwrite_used, NULL);
17
if(!ret)
18
netdata_log_error("CONFIG: cannot load config file '%s'.", filename);
19
}
20
else {
21
filename = filename_from_path_entry_strdupz(netdata_configured_user_config_dir, "netdata.conf");
22
25
- ret = config_load(filename, overwrite_used, NULL);
23
+ ret = inicfg_load(&netdata_config, filename, overwrite_used, NULL);
24
if(!ret) {
25
netdata_log_info("CONFIG: cannot load user config '%s'. Will try the stock version.", filename);
26
freez(filename);
27
28
filename = filename_from_path_entry_strdupz(netdata_configured_stock_config_dir, "netdata.conf");
31
- ret = config_load(filename, overwrite_used, NULL);
29
+ ret = inicfg_load(&netdata_config, filename, overwrite_used, NULL);
30
if(!ret)
31
netdata_log_info("CONFIG: cannot load stock config '%s'. Running with internal defaults.", filename);
32
}
src/daemon/daemon.c
+4
-4
@@ -195,7 +195,7 @@ static void oom_score_adj(void) {
195
}
196
197
// check netdata.conf configuration
198
- s = config_get(CONFIG_SECTION_GLOBAL, "OOM score", s);
198
+ s = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "OOM score", s);
199
if(s && *s && (isdigit((uint8_t)*s) || *s == '-' || *s == '+'))
200
wanted_score = atoll(s);
201
else if(s && !strcmp(s, "keep")) {
@@ -248,7 +248,7 @@ static void oom_score_adj(void) {
248
249
static void process_nice_level(void) {
250
#ifdef HAVE_NICE
251
- int nice_level = (int)config_get_number(CONFIG_SECTION_GLOBAL, "process nice level", 0);
251
+ int nice_level = (int)inicfg_get_number(&netdata_config, CONFIG_SECTION_GLOBAL, "process nice level", 0);
252
if(nice(nice_level) == -1)
253
netdata_log_error("Cannot set netdata CPU nice level to %d.", nice_level);
254
else
@@ -355,7 +355,7 @@ static void sched_setscheduler_set(void) {
355
int found = 0;
356
357
// read the configuration
358
- name = config_get(CONFIG_SECTION_GLOBAL, "process scheduling policy", name);
358
+ name = inicfg_get(&netdata_config, CONFIG_SECTION_GLOBAL, "process scheduling policy", name);
359
int i;
360
for(i = 0 ; scheduler_defaults[i].name ; i++) {
361
if(!strcmp(name, scheduler_defaults[i].name)) {
@@ -368,7 +368,7 @@ static void sched_setscheduler_set(void) {
368
goto report;
369
370
if(flags & SCHED_FLAG_PRIORITY_CONFIGURABLE)
371
- priority = (int)config_get_number(CONFIG_SECTION_GLOBAL, "process scheduling priority", priority);
371
+ priority = (int)inicfg_get_number(&netdata_config, CONFIG_SECTION_GLOBAL, "process scheduling priority", priority);
372
373
#ifdef HAVE_SCHED_GET_PRIORITY_MIN
374
errno_clear();
src/daemon/environment.c
+3
-3
@@ -69,7 +69,7 @@ void set_environment_for_plugins_and_scripts(void) {
69
buffer_free(user_plugins_dirs);
70
}
71
72
- const char *default_port = appconfig_get(&netdata_config, CONFIG_SECTION_WEB, "default port", NULL);
72
+ const char *default_port = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "default port", NULL);
73
int clean = 0;
74
if (!default_port) {
75
default_port = strdupz("19999");
@@ -84,12 +84,12 @@ void set_environment_for_plugins_and_scripts(void) {
84
char path[4096], *p = getenv("PATH");
85
if (!p) p = "/bin:/usr/bin";
86
snprintfz(path, sizeof(path), "%s:%s", p, "/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin");
87
- setenv("PATH", config_get(CONFIG_SECTION_ENV_VARS, "PATH", path), 1);
87
+ setenv("PATH", inicfg_get(&netdata_config, CONFIG_SECTION_ENV_VARS, "PATH", path), 1);
88
89
// python options
90
p = getenv("PYTHONPATH");
91
if (!p) p = "";
92
- setenv("PYTHONPATH", config_get(CONFIG_SECTION_ENV_VARS, "PYTHONPATH", p), 1);
92
+ setenv("PYTHONPATH", inicfg_get(&netdata_config, CONFIG_SECTION_ENV_VARS, "PYTHONPATH", p), 1);
93
94
// disable buffering for python plugins
95
setenv("PYTHONUNBUFFERED", "1", 1);
src/daemon/main.c
+18
-18
@@ -297,22 +297,22 @@ int netdata_main(int argc, char **argv) {
297
case 'h':
298
return help(0);
299
case 'i':
300
- config_set(CONFIG_SECTION_WEB, "bind to", optarg);
300
+ inicfg_set(&netdata_config, CONFIG_SECTION_WEB, "bind to", optarg);
301
break;
302
case 'P':
303
pidfile = strdupz(optarg);
304
break;
305
case 'p':
306
- config_set(CONFIG_SECTION_GLOBAL, "default port", optarg);
306
+ inicfg_set(&netdata_config, CONFIG_SECTION_GLOBAL, "default port", optarg);
307
break;
308
case 's':
309
- config_set(CONFIG_SECTION_GLOBAL, "host access prefix", optarg);
309
+ inicfg_set(&netdata_config, CONFIG_SECTION_GLOBAL, "host access prefix", optarg);
310
break;
311
case 't':
312
- config_set(CONFIG_SECTION_GLOBAL, "update every", optarg);
312
+ inicfg_set(&netdata_config, CONFIG_SECTION_GLOBAL, "update every", optarg);
313
break;
314
case 'u':
315
- config_set(CONFIG_SECTION_GLOBAL, "run as user", optarg);
315
+ inicfg_set(&netdata_config, CONFIG_SECTION_GLOBAL, "run as user", optarg);
316
break;
317
case 'v':
318
case 'V':
@@ -355,7 +355,7 @@ int netdata_main(int argc, char **argv) {
355
unittest_running = true;
356
357
// set defaults for dbegnine unittest
358
- config_set(CONFIG_SECTION_DB, "dbengine page type", "gorilla");
358
+ inicfg_set(&netdata_config, CONFIG_SECTION_DB, "dbengine page type", "gorilla");
359
#ifdef ENABLE_DBENGINE
360
default_rrdeng_disk_quota_mb = default_multidb_disk_quota_mb = 256;
361
#endif
@@ -571,11 +571,11 @@ int netdata_main(int argc, char **argv) {
571
}
572
else if(strncmp(optarg, stacksize_string, strlen(stacksize_string)) == 0) {
573
optarg += strlen(stacksize_string);
574
- config_set(CONFIG_SECTION_GLOBAL, "pthread stack size", optarg);
574
+ inicfg_set(&netdata_config, CONFIG_SECTION_GLOBAL, "pthread stack size", optarg);
575
}
576
else if(strncmp(optarg, debug_flags_string, strlen(debug_flags_string)) == 0) {
577
optarg += strlen(debug_flags_string);
578
- config_set(CONFIG_SECTION_LOGS, "debug flags", optarg);
578
+ inicfg_set(&netdata_config, CONFIG_SECTION_LOGS, "debug flags", optarg);
579
debug_flags = strtoull(optarg, NULL, 0);
580
}
581
else if(strcmp(optarg, "set") == 0) {
@@ -604,7 +604,7 @@ int netdata_main(int argc, char **argv) {
604
// so the caller can use -c netdata.conf before or
605
// after this parameter to prevent or allow overwriting
606
// variables at netdata.conf
607
- config_set_default_raw_value(section, key, value);
607
+ inicfg_set_default_raw_value(&netdata_config, section, key, value);
608
609
// fprintf(stderr, "SET section '%s', key '%s', value '%s'\n", section, key, value);
610
}
@@ -637,7 +637,7 @@ int netdata_main(int argc, char **argv) {
637
// so the caller can use -c netdata.conf before or
638
// after this parameter to prevent or allow overwriting
639
// variables at netdata.conf
640
- appconfig_set_default_raw_value(tmp_config, section, key, value);
640
+ inicfg_set_default_raw_value(tmp_config, section, key, value);
641
642
// fprintf(stderr, "SET section '%s', key '%s', value '%s'\n", section, key, value);
643
}
@@ -663,7 +663,7 @@ int netdata_main(int argc, char **argv) {
663
const char *section = argv[optind];
664
const char *key = argv[optind + 1];
665
const char *def = argv[optind + 2];
666
- const char *value = config_get(section, key, def);
666
+ const char *value = inicfg_get(&netdata_config, section, key, def);
667
printf("%s\n", value);
668
return 0;
669
}
@@ -693,7 +693,7 @@ int netdata_main(int argc, char **argv) {
693
const char *section = argv[optind + 1];
694
const char *key = argv[optind + 2];
695
const char *def = argv[optind + 3];
696
- const char *value = appconfig_get(tmp_config, section, key, def);
696
+ const char *value = inicfg_get(tmp_config, section, key, def);
697
printf("%s\n", value);
698
return 0;
699
}
@@ -792,7 +792,7 @@ int netdata_main(int argc, char **argv) {
792
#endif
793
794
pulse_extended_enabled =
795
- config_get_boolean(CONFIG_SECTION_PULSE, "extended", pulse_extended_enabled);
795
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PULSE, "extended", pulse_extended_enabled);
796
797
if(pulse_extended_enabled)
798
// this has to run before starting any other threads that use workers
@@ -843,7 +843,7 @@ int netdata_main(int argc, char **argv) {
843
st->enabled = st->enable_routine();
844
845
if(st->config_name)
846
- st->enabled = config_get_boolean(st->config_section, st->config_name, st->enabled);
846
+ st->enabled = inicfg_get_boolean(&netdata_config, st->config_section, st->config_name, st->enabled);
847
848
if(st->enabled && st->init_routine)
849
st->init_routine();
@@ -917,10 +917,10 @@ int netdata_main(int argc, char **argv) {
917
918
// The "HOME" env var points to the root's home dir because Netdata starts as root. Can't use "HOME".
919
struct passwd *pw = getpwuid(getuid());
920
- if (config_exists(CONFIG_SECTION_DIRECTORIES, "home") || !pw || !pw->pw_dir) {
921
- netdata_configured_home_dir = config_get(CONFIG_SECTION_DIRECTORIES, "home", netdata_configured_home_dir);
920
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_DIRECTORIES, "home") || !pw || !pw->pw_dir) {
921
+ netdata_configured_home_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "home", netdata_configured_home_dir);
922
} else {
923
- netdata_configured_home_dir = config_get(CONFIG_SECTION_DIRECTORIES, "home", pw->pw_dir);
923
+ netdata_configured_home_dir = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "home", pw->pw_dir);
924
}
925
926
nd_setenv("HOME", netdata_configured_home_dir, 1);
@@ -931,7 +931,7 @@ int netdata_main(int argc, char **argv) {
931
932
delta_startup_time("initialize threads after fork");
933
934
- netdata_threads_init_after_fork((size_t)config_get_size_bytes(CONFIG_SECTION_GLOBAL, "pthread stack size", default_stacksize));
934
+ netdata_threads_init_after_fork((size_t)inicfg_get_size_bytes(&netdata_config, CONFIG_SECTION_GLOBAL, "pthread stack size", default_stacksize));
935
936
// initialize internal registry
937
delta_startup_time("initialize registry");
src/daemon/pulse/pulse.c
+8
-8
@@ -57,10 +57,10 @@ void *pulse_thread_main(void *ptr) {
57
pulse_register_workers();
58
59
int update_every =
60
- (int)config_get_duration_seconds(CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
60
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
61
if (update_every < localhost->rrd_update_every) {
62
update_every = localhost->rrd_update_every;
63
- config_set_duration_seconds(CONFIG_SECTION_PULSE, "update every", update_every);
63
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", update_every);
64
}
65
66
pulse_aral_init();
@@ -151,10 +151,10 @@ void *pulse_thread_sqlite3_main(void *ptr) {
151
pulse_register_workers();
152
153
int update_every =
154
- (int)config_get_duration_seconds(CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
154
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
155
if (update_every < localhost->rrd_update_every) {
156
update_every = localhost->rrd_update_every;
157
- config_set_duration_seconds(CONFIG_SECTION_PULSE, "update every", update_every);
157
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", update_every);
158
}
159
160
usec_t step = update_every * USEC_PER_SEC;
@@ -194,10 +194,10 @@ void *pulse_thread_workers_main(void *ptr) {
194
pulse_register_workers();
195
196
int update_every =
197
- (int)config_get_duration_seconds(CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
197
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
198
if (update_every < localhost->rrd_update_every) {
199
update_every = localhost->rrd_update_every;
200
- config_set_duration_seconds(CONFIG_SECTION_PULSE, "update every", update_every);
200
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", update_every);
201
}
202
203
usec_t step = update_every * USEC_PER_SEC;
@@ -238,10 +238,10 @@ void *pulse_thread_memory_extended_main(void *ptr) {
238
pulse_register_workers();
239
240
int update_every =
241
- (int)config_get_duration_seconds(CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
241
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", localhost->rrd_update_every);
242
if (update_every < localhost->rrd_update_every) {
243
update_every = localhost->rrd_update_every;
244
- config_set_duration_seconds(CONFIG_SECTION_PULSE, "update every", update_every);
244
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_PULSE, "update every", update_every);
245
}
246
247
usec_t step = update_every * USEC_PER_SEC;
src/database/rrdhost-labels.c
+4
-4
@@ -22,7 +22,7 @@ static bool config_label_cb(void *data __maybe_unused, const char *name, const c
22
}
23
24
static void rrdhost_load_config_labels(void) {
25
- int status = config_load(NULL, 1, CONFIG_SECTION_HOST_LABEL);
25
+ int status = inicfg_load(&netdata_config, NULL, 1, CONFIG_SECTION_HOST_LABEL);
26
if(!status) {
27
char *filename = CONFIG_DIR "/" CONFIG_FILENAME;
28
nd_log(NDLS_DAEMON, NDLP_WARNING,
@@ -30,7 +30,7 @@ static void rrdhost_load_config_labels(void) {
30
filename);
31
}
32
33
- appconfig_foreach_value_in_section(&netdata_config, CONFIG_SECTION_HOST_LABEL, config_label_cb, NULL);
33
+ inicfg_foreach_value_in_section(&netdata_config, CONFIG_SECTION_HOST_LABEL, config_label_cb, NULL);
34
}
35
36
static void rrdhost_load_kubernetes_labels(void) {
@@ -70,10 +70,10 @@ static void rrdhost_load_auto_labels(void) {
70
// The source should be CONF, but when it is set, these labels are exported by default ('send configured labels' in exporting.conf).
71
// Their export seems to break exporting to Graphite, see https://github.com/netdata/netdata/issues/14084.
72
73
- int is_ephemeral = appconfig_get_boolean(&netdata_config, CONFIG_SECTION_GLOBAL, "is ephemeral node", CONFIG_BOOLEAN_NO);
73
+ int is_ephemeral = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_GLOBAL, "is ephemeral node", CONFIG_BOOLEAN_NO);
74
rrdlabels_add(labels, "_is_ephemeral", is_ephemeral ? "true" : "false", RRDLABEL_SRC_AUTO);
75
76
- int has_unstable_connection = appconfig_get_boolean(&netdata_config, CONFIG_SECTION_GLOBAL, "has unstable connection", CONFIG_BOOLEAN_NO);
76
+ int has_unstable_connection = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_GLOBAL, "has unstable connection", CONFIG_BOOLEAN_NO);
77
rrdlabels_add(labels, "_has_unstable_connection", has_unstable_connection ? "true" : "false", RRDLABEL_SRC_AUTO);
78
79
rrdlabels_add(labels, "_is_parent", (stream_receivers_currently_connected() > 0) ? "true" : "false", RRDLABEL_SRC_AUTO);
src/database/sqlite/sqlite_aclk_node.c
+1
-1
@@ -73,7 +73,7 @@ static void build_node_info(RRDHOST *host)
73
node_info.data.version = host_version ? host_version : NETDATA_VERSION;
74
node_info.data.release_channel = get_release_channel();
75
node_info.data.timezone = rrdhost_abbrev_timezone(host);
76
- node_info.data.custom_info = config_get(CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
76
+ node_info.data.custom_info = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
77
node_info.data.machine_guid = host->machine_guid;
78
node_info.node_capabilities = (struct capability *)aclk_get_agent_capas();
79
node_info.data.host_labels_ptr = host->rrdlabels;
src/database/sqlite/sqlite_functions.c
+12
-12
@@ -94,40 +94,40 @@ int configure_sqlite_database(sqlite3 *database, int target_version, const char
94
// https://www.sqlite.org/pragma.html#pragma_auto_vacuum
95
// PRAGMA schema.auto_vacuum = 0 | NONE | 1 | FULL | 2 | INCREMENTAL;
96
snprintfz(buf, sizeof(buf) - 1, "PRAGMA auto_vacuum=%s", def_auto_vacuum);
97
- if (config_exists(CONFIG_SECTION_SQLITE, "auto vacuum"))
98
- snprintfz(buf, sizeof(buf) - 1, "PRAGMA auto_vacuum=%s",config_get(CONFIG_SECTION_SQLITE, "auto vacuum", def_auto_vacuum));
97
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_SQLITE, "auto vacuum"))
98
+ snprintfz(buf, sizeof(buf) - 1, "PRAGMA auto_vacuum=%s",inicfg_get(&netdata_config, CONFIG_SECTION_SQLITE, "auto vacuum", def_auto_vacuum));
99
if (init_database_batch(database, list, description))
100
return 1;
101
102
// https://www.sqlite.org/pragma.html#pragma_synchronous
103
// PRAGMA schema.synchronous = 0 | OFF | 1 | NORMAL | 2 | FULL | 3 | EXTRA;
104
snprintfz(buf, sizeof(buf) - 1, "PRAGMA synchronous=%s", def_synchronous);
105
- if (config_exists(CONFIG_SECTION_SQLITE, "synchronous"))
106
- snprintfz(buf, sizeof(buf) - 1, "PRAGMA synchronous=%s", config_get(CONFIG_SECTION_SQLITE, "synchronous", def_synchronous));
105
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_SQLITE, "synchronous"))
106
+ snprintfz(buf, sizeof(buf) - 1, "PRAGMA synchronous=%s", inicfg_get(&netdata_config, CONFIG_SECTION_SQLITE, "synchronous", def_synchronous));
107
if (init_database_batch(database, list, description))
108
return 1;
109
110
// https://www.sqlite.org/pragma.html#pragma_journal_mode
111
// PRAGMA schema.journal_mode = DELETE | TRUNCATE | PERSIST | MEMORY | WAL | OFF
112
snprintfz(buf, sizeof(buf) - 1, "PRAGMA journal_mode=%s", def_journal_mode);
113
- if (config_exists(CONFIG_SECTION_SQLITE, "journal mode"))
114
- snprintfz(buf, sizeof(buf) - 1, "PRAGMA journal_mode=%s", config_get(CONFIG_SECTION_SQLITE, "journal mode", def_journal_mode));
113
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_SQLITE, "journal mode"))
114
+ snprintfz(buf, sizeof(buf) - 1, "PRAGMA journal_mode=%s", inicfg_get(&netdata_config, CONFIG_SECTION_SQLITE, "journal mode", def_journal_mode));
115
if (init_database_batch(database, list, description))
116
return 1;
117
118
// https://www.sqlite.org/pragma.html#pragma_temp_store
119
// PRAGMA temp_store = 0 | DEFAULT | 1 | FILE | 2 | MEMORY;
120
snprintfz(buf, sizeof(buf) - 1, "PRAGMA temp_store=%s", def_temp_store);
121
- if (config_exists(CONFIG_SECTION_SQLITE, "temp store"))
122
- snprintfz(buf, sizeof(buf) - 1, "PRAGMA temp_store=%s", config_get(CONFIG_SECTION_SQLITE, "temp store", def_temp_store));
121
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_SQLITE, "temp store"))
122
+ snprintfz(buf, sizeof(buf) - 1, "PRAGMA temp_store=%s", inicfg_get(&netdata_config, CONFIG_SECTION_SQLITE, "temp store", def_temp_store));
123
if (init_database_batch(database, list, description))
124
return 1;
125
126
// https://www.sqlite.org/pragma.html#pragma_journal_size_limit
127
// PRAGMA schema.journal_size_limit = N ;
128
snprintfz(buf, sizeof(buf) - 1, "PRAGMA journal_size_limit=%lld", def_journal_size_limit);
129
- if (config_exists(CONFIG_SECTION_SQLITE, "journal size limit")) {
130
- def_journal_size_limit = config_get_number(CONFIG_SECTION_SQLITE, "journal size limit", def_journal_size_limit);
129
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_SQLITE, "journal size limit")) {
130
+ def_journal_size_limit = inicfg_get_number(&netdata_config, CONFIG_SECTION_SQLITE, "journal size limit", def_journal_size_limit);
131
snprintfz(buf, sizeof(buf) - 1, "PRAGMA journal_size_limit=%lld", def_journal_size_limit);
132
}
133
if (init_database_batch(database, list, description))
@@ -137,8 +137,8 @@ int configure_sqlite_database(sqlite3 *database, int target_version, const char
137
// PRAGMA schema.cache_size = pages;
138
// PRAGMA schema.cache_size = -kibibytes;
139
snprintfz(buf, sizeof(buf) - 1, "PRAGMA cache_size=%lld", def_cache_size);
140
- if (config_exists(CONFIG_SECTION_SQLITE, "cache size"))
141
- snprintfz(buf, sizeof(buf) - 1, "PRAGMA cache_size=%lld", config_get_number(CONFIG_SECTION_SQLITE, "cache size", def_cache_size));
140
+ if (inicfg_exists(&netdata_config, CONFIG_SECTION_SQLITE, "cache size"))
141
+ snprintfz(buf, sizeof(buf) - 1, "PRAGMA cache_size=%lld", inicfg_get_number(&netdata_config, CONFIG_SECTION_SQLITE, "cache size", def_cache_size));
142
if (init_database_batch(database, list, description))
143
return 1;
144
src/exporting/read_config.c
+22
-22
@@ -33,17 +33,17 @@ static const char *expconfig_get(struct config *root, const char *section, const
33
_CONNECTOR_INSTANCE *local_ci;
34
35
if (!strcmp(section, CONFIG_SECTION_EXPORTING))
36
- return appconfig_get(root, CONFIG_SECTION_EXPORTING, name, default_value);
36
+ return inicfg_get(root, CONFIG_SECTION_EXPORTING, name, default_value);
37
38
local_ci = find_instance(section);
39
40
if (!local_ci)
41
return NULL; // TODO: Check if it is meaningful to return default_value
42
43
- return appconfig_get(
43
+ return inicfg_get(
44
root, local_ci->instance_name, name,
45
- appconfig_get(
46
- root, local_ci->connector_name, name, appconfig_get(root, CONFIG_SECTION_EXPORTING, name, default_value)));
45
+ inicfg_get(
46
+ root, local_ci->connector_name, name, inicfg_get(root, CONFIG_SECTION_EXPORTING, name, default_value)));
47
}
48
49
int expconfig_get_boolean(struct config *root, const char *section, const char *name, int default_value)
@@ -51,18 +51,18 @@ int expconfig_get_boolean(struct config *root, const char *section, const char *
51
_CONNECTOR_INSTANCE *local_ci;
52
53
if (!strcmp(section, CONFIG_SECTION_EXPORTING))
54
- return appconfig_get_boolean(root, CONFIG_SECTION_EXPORTING, name, default_value);
54
+ return inicfg_get_boolean(root, CONFIG_SECTION_EXPORTING, name, default_value);
55
56
local_ci = find_instance(section);
57
58
if (!local_ci)
59
return 0; // TODO: Check if it is meaningful to return default_value
60
61
- return appconfig_get_boolean(
61
+ return inicfg_get_boolean(
62
root, local_ci->instance_name, name,
63
- appconfig_get_boolean(
63
+ inicfg_get_boolean(
64
root, local_ci->connector_name, name,
65
- appconfig_get_boolean(root, CONFIG_SECTION_EXPORTING, name, default_value)));
65
+ inicfg_get_boolean(root, CONFIG_SECTION_EXPORTING, name, default_value)));
66
}
67
68
long long expconfig_get_number(struct config *root, const char *section, const char *name, long long default_value)
@@ -70,18 +70,18 @@ long long expconfig_get_number(struct config *root, const char *section, const c
70
_CONNECTOR_INSTANCE *local_ci;
71
72
if (!strcmp(section, CONFIG_SECTION_EXPORTING))
73
- return appconfig_get_number(root, CONFIG_SECTION_EXPORTING, name, default_value);
73
+ return inicfg_get_number(root, CONFIG_SECTION_EXPORTING, name, default_value);
74
75
local_ci = find_instance(section);
76
77
if (!local_ci)
78
return 0; // TODO: Check if it is meaningful to return default_value
79
80
- return appconfig_get_number(
80
+ return inicfg_get_number(
81
root, local_ci->instance_name, name,
82
- appconfig_get_number(
82
+ inicfg_get_number(
83
root, local_ci->connector_name, name,
84
- appconfig_get_number(root, CONFIG_SECTION_EXPORTING, name, default_value)));
84
+ inicfg_get_number(root, CONFIG_SECTION_EXPORTING, name, default_value)));
85
}
86
87
/*
@@ -205,13 +205,13 @@ struct engine *read_exporting_config()
205
206
char *filename = filename_from_path_entry_strdupz(netdata_configured_user_config_dir, EXPORTING_CONF);
207
208
- exporting_config_exists = appconfig_load(&exporting_config, filename, 0, NULL);
208
+ exporting_config_exists = inicfg_load(&exporting_config, filename, 0, NULL);
209
if (!exporting_config_exists) {
210
netdata_log_info("CONFIG: cannot load user exporting config '%s'. Will try the stock version.", filename);
211
freez(filename);
212
213
filename = filename_from_path_entry_strdupz(netdata_configured_stock_config_dir, EXPORTING_CONF);
214
- exporting_config_exists = appconfig_load(&exporting_config, filename, 0, NULL);
214
+ exporting_config_exists = inicfg_load(&exporting_config, filename, 0, NULL);
215
if (!exporting_config_exists)
216
netdata_log_info("CONFIG: cannot load stock exporting config '%s'. Running with internal defaults.", filename);
217
}
@@ -219,17 +219,17 @@ struct engine *read_exporting_config()
219
freez(filename);
220
221
#define prometheus_config_get(name, value) \
222
- appconfig_get( \
222
+ inicfg_get( \
223
&exporting_config, CONFIG_SECTION_PROMETHEUS, name, \
224
- appconfig_get(&exporting_config, CONFIG_SECTION_EXPORTING, name, value))
224
+ inicfg_get(&exporting_config, CONFIG_SECTION_EXPORTING, name, value))
225
#define prometheus_config_get_number(name, value) \
226
- appconfig_get_number( \
226
+ inicfg_get_number( \
227
&exporting_config, CONFIG_SECTION_PROMETHEUS, name, \
228
- appconfig_get_number(&exporting_config, CONFIG_SECTION_EXPORTING, name, value))
228
+ inicfg_get_number(&exporting_config, CONFIG_SECTION_EXPORTING, name, value))
229
#define prometheus_config_get_boolean(name, value) \
230
- appconfig_get_boolean( \
230
+ inicfg_get_boolean( \
231
&exporting_config, CONFIG_SECTION_PROMETHEUS, name, \
232
- appconfig_get_boolean(&exporting_config, CONFIG_SECTION_EXPORTING, name, value))
232
+ inicfg_get_boolean(&exporting_config, CONFIG_SECTION_EXPORTING, name, value))
233
234
if (!prometheus_exporter_instance) {
235
prometheus_exporter_instance = callocz(1, sizeof(struct instance));
@@ -493,9 +493,9 @@ struct engine *read_exporting_config()
493
#endif
494
495
if (unlikely(!exporting_config_exists) && !engine->config.hostname) {
496
- engine->config.hostname = strdupz(config_get(instance_name, "hostname", netdata_configured_hostname));
496
+ engine->config.hostname = strdupz(inicfg_get(&netdata_config, instance_name, "hostname", netdata_configured_hostname));
497
engine->config.update_every =
498
- config_get_number(instance_name, EXPORTING_UPDATE_EVERY_OPTION_NAME, EXPORTING_UPDATE_EVERY_DEFAULT);
498
+ inicfg_get_number(&netdata_config, instance_name, EXPORTING_UPDATE_EVERY_OPTION_NAME, EXPORTING_UPDATE_EVERY_DEFAULT);
499
}
500
501
next_connector_instance:
src/health/health.c
+16
-16
@@ -40,47 +40,47 @@ static void health_load_config_defaults(void) {
40
char filename[FILENAME_MAX + 1];
41
42
health_globals.config.enabled =
43
- config_get_boolean(CONFIG_SECTION_HEALTH,
43
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_HEALTH,
44
"enabled",
45
health_globals.config.enabled);
46
47
health_globals.config.stock_enabled =
48
- config_get_boolean(CONFIG_SECTION_HEALTH,
48
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_HEALTH,
49
"enable stock health configuration",
50
health_globals.config.stock_enabled);
51
52
health_globals.config.use_summary_for_notifications =
53
- config_get_boolean(CONFIG_SECTION_HEALTH,
53
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_HEALTH,
54
"use summary for notifications",
55
health_globals.config.use_summary_for_notifications);
56
57
health_globals.config.default_warn_repeat_every =
58
- config_get_duration_seconds(CONFIG_SECTION_HEALTH, "default repeat warning", 0);
58
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_HEALTH, "default repeat warning", 0);
59
60
health_globals.config.default_crit_repeat_every =
61
- config_get_duration_seconds(CONFIG_SECTION_HEALTH, "default repeat critical", 0);
61
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_HEALTH, "default repeat critical", 0);
62
63
health_globals.config.health_log_entries_max =
64
- config_get_number(CONFIG_SECTION_HEALTH, "in memory max health log entries",
64
+ inicfg_get_number(&netdata_config, CONFIG_SECTION_HEALTH, "in memory max health log entries",
65
health_globals.config.health_log_entries_max);
66
67
health_globals.config.health_log_retention_s =
68
- config_get_duration_seconds(CONFIG_SECTION_HEALTH, "health log retention", HEALTH_LOG_RETENTION_DEFAULT);
68
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_HEALTH, "health log retention", HEALTH_LOG_RETENTION_DEFAULT);
69
70
snprintfz(filename, FILENAME_MAX, "%s/alarm-notify.sh", netdata_configured_primary_plugins_dir);
71
health_globals.config.default_exec =
72
- string_strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
72
+ string_strdupz(inicfg_get(&netdata_config, CONFIG_SECTION_HEALTH, "script to execute on alarm", filename));
73
74
health_globals.config.enabled_alerts =
75
- simple_pattern_create(config_get(CONFIG_SECTION_HEALTH, "enabled alarms", "*"),
75
+ simple_pattern_create(inicfg_get(&netdata_config, CONFIG_SECTION_HEALTH, "enabled alarms", "*"),
76
NULL, SIMPLE_PATTERN_EXACT, true);
77
78
health_globals.config.run_at_least_every_seconds =
79
- (int)config_get_duration_seconds(CONFIG_SECTION_HEALTH, "run at least every",
79
+ (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_HEALTH, "run at least every",
80
health_globals.config.run_at_least_every_seconds);
81
82
health_globals.config.postpone_alarms_during_hibernation_for_seconds =
83
- config_get_duration_seconds(CONFIG_SECTION_HEALTH,
83
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_HEALTH,
84
"postpone alarms during hibernation for",
85
health_globals.config.postpone_alarms_during_hibernation_for_seconds);
86
@@ -100,7 +100,7 @@ static void health_load_config_defaults(void) {
100
HEALTH_LOG_ENTRIES_MIN);
101
102
health_globals.config.health_log_entries_max = HEALTH_LOG_ENTRIES_MIN;
103
- config_set_number(CONFIG_SECTION_HEALTH, "in memory max health log entries",
103
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_HEALTH, "in memory max health log entries",
104
(long)health_globals.config.health_log_entries_max);
105
}
106
else if(health_globals.config.health_log_entries_max > HEALTH_LOG_ENTRIES_MAX) {
@@ -110,7 +110,7 @@ static void health_load_config_defaults(void) {
110
HEALTH_LOG_ENTRIES_MAX);
111
112
health_globals.config.health_log_entries_max = HEALTH_LOG_ENTRIES_MAX;
113
- config_set_number(CONFIG_SECTION_HEALTH, "in memory max health log entries",
113
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_HEALTH, "in memory max health log entries",
114
(long)health_globals.config.health_log_entries_max);
115
}
116
@@ -120,7 +120,7 @@ static void health_load_config_defaults(void) {
120
health_globals.config.health_log_retention_s, HEALTH_LOG_MINIMUM_HISTORY);
121
122
health_globals.config.health_log_retention_s = HEALTH_LOG_MINIMUM_HISTORY;
123
- config_set_duration_seconds(CONFIG_SECTION_HEALTH, "health log retention", health_globals.config.health_log_retention_s);
123
+ inicfg_set_duration_seconds(&netdata_config, CONFIG_SECTION_HEALTH, "health log retention", health_globals.config.health_log_retention_s);
124
}
125
126
nd_log(NDLS_DAEMON, NDLP_DEBUG,
@@ -131,13 +131,13 @@ static void health_load_config_defaults(void) {
131
inline const char *health_user_config_dir(void) {
132
char buffer[FILENAME_MAX + 1];
133
snprintfz(buffer, FILENAME_MAX, "%s/health.d", netdata_configured_user_config_dir);
134
- return config_get(CONFIG_SECTION_DIRECTORIES, "health config", buffer);
134
+ return inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "health config", buffer);
135
}
136
137
inline const char *health_stock_config_dir(void) {
138
char buffer[FILENAME_MAX + 1];
139
snprintfz(buffer, FILENAME_MAX, "%s/health.d", netdata_configured_stock_config_dir);
140
- return config_get(CONFIG_SECTION_DIRECTORIES, "stock health config", buffer);
140
+ return inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "stock health config", buffer);
141
}
142
143
void health_plugin_init(void) {
src/health/health_silencers.c
+1
-1
@@ -400,7 +400,7 @@ void health_set_silencers_filename(void) {
400
snprintfz(filename, FILENAME_MAX, "%s/health.silencers.json", netdata_configured_varlib_dir);
401
402
health_globals.config.silencers_filename =
403
- string_strdupz(config_get(CONFIG_SECTION_HEALTH, "silencers file", filename));
403
+ string_strdupz(inicfg_get(&netdata_config, CONFIG_SECTION_HEALTH, "silencers file", filename));
404
}
405
406
void health_silencers_init(void) {
src/libnetdata/config/appconfig_api_boolean.c
deleted
-68
@@ -1,68 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#include "appconfig_internals.h"
4
-#include "appconfig_api_boolean.h"
5
-
6
-bool appconfig_test_boolean_value(const char *s) {
7
- if(!strcasecmp(s, "yes") || !strcasecmp(s, "true") || !strcasecmp(s, "on")
8
- || !strcasecmp(s, "auto") || !strcasecmp(s, "on demand"))
9
- return true;
10
-
11
- return false;
12
-}
13
-
14
-int appconfig_get_boolean_by_section(struct config_section *sect, const char *name, int value) {
15
- struct config_option *opt = appconfig_get_raw_value_of_option_in_section(
16
- sect, name, (!value) ? "no" : "yes", CONFIG_VALUE_TYPE_BOOLEAN, NULL);
17
- if(!opt) return value;
18
-
19
- return appconfig_test_boolean_value(string2str(opt->value));
20
-}
21
-
22
-int appconfig_get_boolean(struct config *root, const char *section, const char *name, int value) {
23
- const char *s;
24
- if(value) s = "yes";
25
- else s = "no";
26
-
27
- struct config_option *opt = appconfig_get_raw_value(root, section, name, s, CONFIG_VALUE_TYPE_BOOLEAN, NULL);
28
- if(!opt) return value;
29
- s = string2str(opt->value);
30
-
31
- return appconfig_test_boolean_value(s);
32
-}
33
-
34
-int appconfig_get_boolean_ondemand(struct config *root, const char *section, const char *name, int value) {
35
- const char *s;
36
-
37
- if(value == CONFIG_BOOLEAN_AUTO)
38
- s = "auto";
39
-
40
- else if(value == CONFIG_BOOLEAN_NO)
41
- s = "no";
42
-
43
- else
44
- s = "yes";
45
-
46
- struct config_option *opt = appconfig_get_raw_value(root, section, name, s, CONFIG_VALUE_TYPE_BOOLEAN_ONDEMAND, NULL);
47
- if(!opt) return value;
48
-
49
- s = string2str(opt->value);
50
- if(!strcmp(s, "yes") || !strcmp(s, "true") || !strcmp(s, "on"))
51
- return CONFIG_BOOLEAN_YES;
52
- else if(!strcmp(s, "no") || !strcmp(s, "false") || !strcmp(s, "off"))
53
- return CONFIG_BOOLEAN_NO;
54
- else if(!strcmp(s, "auto") || !strcmp(s, "on demand"))
55
- return CONFIG_BOOLEAN_AUTO;
56
-
57
- return value;
58
-}
59
-
60
-int appconfig_set_boolean(struct config *root, const char *section, const char *name, int value) {
61
- const char *s;
62
- if(value) s = "yes";
63
- else s = "no";
64
-
65
- appconfig_set_raw_value(root, section, name, s, CONFIG_VALUE_TYPE_BOOLEAN);
66
-
67
- return value;
68
-}
src/libnetdata/config/appconfig_api_boolean.h
deleted
-24
@@ -1,24 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#ifndef NETDATA_APPCONFIG_API_BOOLEAN_H
4
-#define NETDATA_APPCONFIG_API_BOOLEAN_H
5
-
6
-#define CONFIG_BOOLEAN_INVALID 100 // an invalid value to check for validity (used as default initialization when needed)
7
-
8
-#define CONFIG_BOOLEAN_NO 0 // disabled
9
-#define CONFIG_BOOLEAN_YES 1 // enabled
10
-
11
-#ifndef CONFIG_BOOLEAN_AUTO
12
-#define CONFIG_BOOLEAN_AUTO 2 // enabled if it has useful info when enabled
13
-#endif
14
-
15
-int appconfig_get_boolean(struct config *root, const char *section, const char *name, int value);
16
-#define config_get_boolean(section, name, value) appconfig_get_boolean(&netdata_config, section, name, value)
17
-
18
-int appconfig_get_boolean_ondemand(struct config *root, const char *section, const char *name, int value);
19
-#define config_get_boolean_ondemand(section, name, value) appconfig_get_boolean_ondemand(&netdata_config, section, name, value)
20
-
21
-int appconfig_set_boolean(struct config *root, const char *section, const char *name, int value);
22
-#define config_set_boolean(section, name, value) appconfig_set_boolean(&netdata_config, section, name, value)
23
-
24
-#endif //NETDATA_APPCONFIG_API_BOOLEAN_H
src/libnetdata/config/appconfig_api_durations.c
deleted
-134
@@ -1,134 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#include "appconfig_internals.h"
4
-#include "appconfig_api_durations.h"
5
-
6
-
7
-static STRING *reformat_duration_seconds(STRING *value) {
8
- int result = 0;
9
- if(!duration_parse_seconds(string2str(value), &result))
10
- return value;
11
-
12
- char buf[128];
13
- if(duration_snprintf_time_t(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
14
- string_freez(value);
15
- return string_strdupz(buf);
16
- }
17
-
18
- return value;
19
-}
20
-
21
-time_t appconfig_get_duration_seconds(struct config *root, const char *section, const char *name, time_t default_value) {
22
- char default_str[128];
23
- duration_snprintf_time_t(default_str, sizeof(default_str), default_value);
24
-
25
- struct config_option *opt = appconfig_get_raw_value(
26
- root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_SECS, reformat_duration_seconds);
27
- if(!opt)
28
- return default_value;
29
-
30
- const char *s = string2str(opt->value);
31
-
32
- int result = 0;
33
- if(!duration_parse_seconds(s, &result)) {
34
- appconfig_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_SECS);
35
- netdata_log_error("config option '[%s].%s = %s' is configured with an invalid duration", section, name, s);
36
- return default_value;
37
- }
38
-
39
- return ABS(result);
40
-}
41
-
42
-time_t appconfig_set_duration_seconds(struct config *root, const char *section, const char *name, time_t value) {
43
- char str[128];
44
- duration_snprintf_time_t(str, sizeof(str), value);
45
-
46
- appconfig_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_DURATION_IN_SECS);
47
- return value;
48
-}
49
-
50
-static STRING *reformat_duration_ms(STRING *value) {
51
- int64_t result = 0;
52
- if(!duration_parse_msec_t(string2str(value), &result))
53
- return value;
54
-
55
- char buf[128];
56
- if(duration_snprintf_msec_t(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
57
- string_freez(value);
58
- return string_strdupz(buf);
59
- }
60
-
61
- return value;
62
-}
63
-
64
-msec_t appconfig_get_duration_ms(struct config *root, const char *section, const char *name, msec_t default_value) {
65
- char default_str[128];
66
- duration_snprintf_msec_t(default_str, sizeof(default_str), default_value);
67
-
68
- struct config_option *opt = appconfig_get_raw_value(
69
- root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_MS, reformat_duration_ms);
70
- if(!opt)
71
- return default_value;
72
-
73
- const char *s = string2str(opt->value);
74
-
75
- smsec_t result = 0;
76
- if(!duration_parse_msec_t(s, &result)) {
77
- appconfig_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_MS);
78
- netdata_log_error("config option '[%s].%s = %s' is configured with an invalid duration", section, name, s);
79
- return default_value;
80
- }
81
-
82
- return ABS(result);
83
-}
84
-
85
-msec_t appconfig_set_duration_ms(struct config *root, const char *section, const char *name, msec_t value) {
86
- char str[128];
87
- duration_snprintf_msec_t(str, sizeof(str), (smsec_t)value);
88
-
89
- appconfig_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_DURATION_IN_MS);
90
- return value;
91
-}
92
-
93
-static STRING *reformat_duration_days(STRING *value) {
94
- int64_t result = 0;
95
- if(!duration_parse_days(string2str(value), &result))
96
- return value;
97
-
98
- char buf[128];
99
- if(duration_snprintf_days(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
100
- string_freez(value);
101
- return string_strdupz(buf);
102
- }
103
-
104
- return value;
105
-}
106
-
107
-unsigned appconfig_get_duration_days(struct config *root, const char *section, const char *name, unsigned default_value) {
108
- char default_str[128];
109
- duration_snprintf_days(default_str, sizeof(default_str), (int)default_value);
110
-
111
- struct config_option *opt = appconfig_get_raw_value(
112
- root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_DAYS, reformat_duration_days);
113
- if(!opt)
114
- return default_value;
115
-
116
- const char *s = string2str(opt->value);
117
-
118
- int64_t result = 0;
119
- if(!duration_parse_days(s, &result)) {
120
- appconfig_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_DAYS);
121
- netdata_log_error("config option '[%s].%s = %s' is configured with an invalid duration", section, name, s);
122
- return default_value;
123
- }
124
-
125
- return (unsigned)ABS(result);
126
-}
127
-
128
-unsigned appconfig_set_duration_days(struct config *root, const char *section, const char *name, unsigned value) {
129
- char str[128];
130
- duration_snprintf_days(str, sizeof(str), value);
131
- appconfig_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_DURATION_IN_DAYS);
132
- return value;
133
-}
134
-
src/libnetdata/config/appconfig_api_durations.h
deleted
-21
@@ -1,21 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#ifndef NETDATA_APPCONFIG_API_DURATIONS_H
4
-#define NETDATA_APPCONFIG_API_DURATIONS_H
5
-
6
-msec_t appconfig_get_duration_ms(struct config *root, const char *section, const char *name, msec_t default_value);
7
-msec_t appconfig_set_duration_ms(struct config *root, const char *section, const char *name, msec_t value);
8
-#define config_get_duration_ms(section, name, value) appconfig_get_duration_ms(&netdata_config, section, name, value)
9
-#define config_set_duration_ms(section, name, value) appconfig_set_duration_ms(&netdata_config, section, name, value)
10
-
11
-time_t appconfig_get_duration_seconds(struct config *root, const char *section, const char *name, time_t default_value);
12
-time_t appconfig_set_duration_seconds(struct config *root, const char *section, const char *name, time_t value);
13
-#define config_get_duration_seconds(section, name, value) appconfig_get_duration_seconds(&netdata_config, section, name, value)
14
-#define config_set_duration_seconds(section, name, value) appconfig_set_duration_seconds(&netdata_config, section, name, value)
15
-
16
-unsigned appconfig_get_duration_days(struct config *root, const char *section, const char *name, unsigned default_value);
17
-unsigned appconfig_set_duration_days(struct config *root, const char *section, const char *name, unsigned value);
18
-#define config_get_duration_days(section, name, value) appconfig_get_duration_days(&netdata_config, section, name, value)
19
-#define config_set_duration_days(section, name, value) appconfig_set_duration_days(&netdata_config, section, name, value)
20
-
21
-#endif //NETDATA_APPCONFIG_API_DURATIONS_H
src/libnetdata/config/appconfig_api_numbers.c
deleted
-43
@@ -1,43 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#include "appconfig_internals.h"
4
-#include "appconfig_api_numbers.h"
5
-
6
-long long appconfig_get_number(struct config *root, const char *section, const char *name, long long value) {
7
- char buffer[100];
8
- sprintf(buffer, "%lld", value);
9
-
10
- struct config_option *opt = appconfig_get_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_INTEGER, NULL);
11
- if(!opt) return value;
12
-
13
- const char *s = string2str(opt->value);
14
- return strtoll(s, NULL, 0);
15
-}
16
-
17
-NETDATA_DOUBLE appconfig_get_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value) {
18
- char buffer[100];
19
- sprintf(buffer, "%0.5" NETDATA_DOUBLE_MODIFIER, value);
20
-
21
- struct config_option *opt = appconfig_get_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_DOUBLE, NULL);
22
- if(!opt) return value;
23
-
24
- const char *s = string2str(opt->value);
25
- return str2ndd(s, NULL);
26
-}
27
-
28
-long long appconfig_set_number(struct config *root, const char *section, const char *name, long long value) {
29
- char buffer[100];
30
- sprintf(buffer, "%lld", value);
31
-
32
- appconfig_set_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_INTEGER);
33
- return value;
34
-}
35
-
36
-NETDATA_DOUBLE appconfig_set_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value) {
37
- char buffer[100];
38
- sprintf(buffer, "%0.5" NETDATA_DOUBLE_MODIFIER, value);
39
-
40
- appconfig_set_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_DOUBLE);
41
- return value;
42
-}
43
-
src/libnetdata/config/appconfig_api_numbers.h
deleted
-16
@@ -1,16 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#ifndef NETDATA_APPCONFIG_API_NUMBERS_H
4
-#define NETDATA_APPCONFIG_API_NUMBERS_H
5
-
6
-long long appconfig_get_number(struct config *root, const char *section, const char *name, long long value);
7
-long long appconfig_set_number(struct config *root, const char *section, const char *name, long long value);
8
-#define config_get_number(section, name, value) appconfig_get_number(&netdata_config, section, name, value)
9
-#define config_set_number(section, name, value) appconfig_set_number(&netdata_config, section, name, value)
10
-
11
-NETDATA_DOUBLE appconfig_get_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value);
12
-NETDATA_DOUBLE appconfig_set_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value);
13
-#define config_get_double(section, name, value) appconfig_get_double(&netdata_config, section, name, value)
14
-#define config_set_double(section, name, value) appconfig_set_float(&netdata_config, section, name, value)
15
-
16
-#endif //NETDATA_APPCONFIG_API_NUMBERS_H
src/libnetdata/config/appconfig_api_sizes.c
deleted
-86
@@ -1,86 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#include "appconfig_internals.h"
4
-#include "appconfig_api_sizes.h"
5
-
6
-static STRING *reformat_size_bytes(STRING *value) {
7
- uint64_t result = 0;
8
- if(!size_parse_bytes(string2str(value), &result))
9
- return value;
10
-
11
- char buf[128];
12
- if(size_snprintf_bytes(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
13
- string_freez(value);
14
- return string_strdupz(buf);
15
- }
16
-
17
- return value;
18
-}
19
-
20
-uint64_t appconfig_get_size_bytes(struct config *root, const char *section, const char *name, uint64_t default_value) {
21
- char default_str[128];
22
- size_snprintf_bytes(default_str, sizeof(default_str), default_value);
23
-
24
- struct config_option *opt =
25
- appconfig_get_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_BYTES, reformat_size_bytes);
26
- if(!opt)
27
- return default_value;
28
-
29
- const char *s = string2str(opt->value);
30
- uint64_t result = 0;
31
- if(!size_parse_bytes(s, &result)) {
32
- appconfig_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_BYTES);
33
- netdata_log_error("config option '[%s].%s = %s' is configured with an invalid size", section, name, s);
34
- return default_value;
35
- }
36
-
37
- return result;
38
-}
39
-
40
-uint64_t appconfig_set_size_bytes(struct config *root, const char *section, const char *name, uint64_t value) {
41
- char str[128];
42
- size_snprintf_bytes(str, sizeof(str), value);
43
- appconfig_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_SIZE_IN_BYTES);
44
- return value;
45
-}
46
-
47
-static STRING *reformat_size_mb(STRING *value) {
48
- uint64_t result = 0;
49
- if(!size_parse_mb(string2str(value), &result))
50
- return value;
51
-
52
- char buf[128];
53
- if(size_snprintf_mb(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
54
- string_freez(value);
55
- return string_strdupz(buf);
56
- }
57
-
58
- return value;
59
-}
60
-
61
-uint64_t appconfig_get_size_mb(struct config *root, const char *section, const char *name, uint64_t default_value) {
62
- char default_str[128];
63
- size_snprintf_mb(default_str, sizeof(default_str), default_value);
64
-
65
- struct config_option *opt =
66
- appconfig_get_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_MB, reformat_size_mb);
67
- if(!opt)
68
- return default_value;
69
-
70
- const char *s = string2str(opt->value);
71
- uint64_t result = 0;
72
- if(!size_parse_mb(s, &result)) {
73
- appconfig_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_MB);
74
- netdata_log_error("config option '[%s].%s = %s' is configured with an invalid size", section, name, s);
75
- return default_value;
76
- }
77
-
78
- return (unsigned)result;
79
-}
80
-
81
-uint64_t appconfig_set_size_mb(struct config *root, const char *section, const char *name, uint64_t value) {
82
- char str[128];
83
- size_snprintf_mb(str, sizeof(str), value);
84
- appconfig_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_SIZE_IN_MB);
85
- return value;
86
-}
src/libnetdata/config/appconfig_api_sizes.h
deleted
-16
@@ -1,16 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#ifndef NETDATA_APPCONFIG_API_SIZES_H
4
-#define NETDATA_APPCONFIG_API_SIZES_H
5
-
6
-uint64_t appconfig_get_size_bytes(struct config *root, const char *section, const char *name, uint64_t default_value);
7
-uint64_t appconfig_set_size_bytes(struct config *root, const char *section, const char *name, uint64_t value);
8
-#define config_get_size_bytes(section, name, value) appconfig_get_size_bytes(&netdata_config, section, name, value)
9
-#define config_set_size_bytes(section, name, value) appconfig_set_size_bytes(&netdata_config, section, name, value)
10
-
11
-uint64_t appconfig_get_size_mb(struct config *root, const char *section, const char *name, uint64_t default_value);
12
-uint64_t appconfig_set_size_mb(struct config *root, const char *section, const char *name, uint64_t value);
13
-#define config_get_size_mb(section, name, value) appconfig_get_size_mb(&netdata_config, section, name, value)
14
-#define config_set_size_mb(section, name, value) appconfig_set_size_mb(&netdata_config, section, name, value)
15
-
16
-#endif //NETDATA_APPCONFIG_API_SIZES_H
src/libnetdata/config/appconfig_api_text.c
deleted
-17
@@ -1,17 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#include "appconfig_internals.h"
4
-#include "appconfig_api_text.h"
5
-
6
-const char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value) {
7
- struct config_option *opt = appconfig_get_raw_value(root, section, name, default_value, CONFIG_VALUE_TYPE_TEXT, NULL);
8
- if(!opt)
9
- return default_value;
10
-
11
- return string2str(opt->value);
12
-}
13
-
14
-const char *appconfig_set(struct config *root, const char *section, const char *name, const char *value) {
15
- struct config_option *opt = appconfig_set_raw_value(root, section, name, value, CONFIG_VALUE_TYPE_TEXT);
16
- return string2str(opt->value);
17
-}
src/libnetdata/config/appconfig_api_text.h
deleted
-12
@@ -1,12 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-
3
-#ifndef NETDATA_APPCONFIG_API_TEXT_H
4
-#define NETDATA_APPCONFIG_API_TEXT_H
5
-
6
-const char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value);
7
-const char *appconfig_set(struct config *root, const char *section, const char *name, const char *value);
8
-#define config_get(section, name, default_value) appconfig_get(&netdata_config, section, name, default_value)
9
-#define config_set(section, name, default_value) appconfig_set(&netdata_config, section, name, default_value)
10
-
11
-
12
-#endif //NETDATA_APPCONFIG_API_TEXT_H
src/libnetdata/config/config.h
new
+9
@@ -0,0 +1,9 @@
1
+// SPDX-License-Identifier: GPL-3.0-or-later
2
+
3
+#ifndef LIBNETDATA_CONFIG_H
4
+#define LIBNETDATA_CONFIG_H
5
+
6
+#include "../inicfg/dyncfg.h"
7
+#include "../inicfg/inicfg.h"
8
+
9
+#endif /* LIBNETDATA_CONFIG_H */
src/libnetdata/inicfg/README.md
renamed
src/libnetdata/inicfg/dyncfg.c
renamed
src/libnetdata/inicfg/dyncfg.h
renamed
src/libnetdata/inicfg/inicfg.c
renamed
+17
-25
@@ -1,27 +1,29 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
-int appconfig_exists(struct config *root, const char *section, const char *name) {
6
- struct config_section *sect = appconfig_section_find(root, section);
5
+struct config netdata_config = APPCONFIG_INITIALIZER;
6
+
7
+int inicfg_exists(struct config *root, const char *section, const char *name) {
8
+ struct config_section *sect = inicfg_section_find(root, section);
9
if(!sect) return 0;
10
9
- struct config_option *opt = appconfig_option_find(sect, name);
11
+ struct config_option *opt = inicfg_option_find(sect, name);
12
if(!opt) return 0;
13
14
return 1;
15
}
16
15
-void appconfig_set_default_raw_value(struct config *root, const char *section, const char *name, const char *value) {
16
- struct config_section *sect = appconfig_section_find(root, section);
17
+void inicfg_set_default_raw_value(struct config *root, const char *section, const char *name, const char *value) {
18
+ struct config_section *sect = inicfg_section_find(root, section);
19
if(!sect) {
18
- appconfig_set_raw_value(root, section, name, value, CONFIG_VALUE_TYPE_UNKNOWN);
20
+ inicfg_set_raw_value(root, section, name, value, CONFIG_VALUE_TYPE_UNKNOWN);
21
return;
22
}
23
22
- struct config_option *opt = appconfig_option_find(sect, name);
24
+ struct config_option *opt = inicfg_option_find(sect, name);
25
if(!opt) {
24
- appconfig_set_raw_value(root, section, name, value, CONFIG_VALUE_TYPE_UNKNOWN);
26
+ inicfg_set_raw_value(root, section, name, value, CONFIG_VALUE_TYPE_UNKNOWN);
27
return;
28
}
29
@@ -47,11 +49,11 @@ bool stream_conf_needs_dbengine(struct config *root) {
49
if(string_strcmp(sect->name, "stream") == 0)
50
continue; // the first section is not relevant
51
50
- struct config_option *opt = appconfig_get_raw_value_of_option_in_section(sect, "enabled", NULL, CONFIG_VALUE_TYPE_UNKNOWN, NULL);
51
- if(!opt || !appconfig_test_boolean_value(string2str(opt->value)))
52
+ struct config_option *opt = inicfg_get_raw_value_of_option_in_section(sect, "enabled", NULL, CONFIG_VALUE_TYPE_UNKNOWN, NULL);
53
+ if(!opt || !inicfg_test_boolean_value(string2str(opt->value)))
54
continue;
55
54
- opt = appconfig_get_raw_value_of_option_in_section(sect, "db", NULL, CONFIG_VALUE_TYPE_UNKNOWN, NULL);
56
+ opt = inicfg_get_raw_value_of_option_in_section(sect, "db", NULL, CONFIG_VALUE_TYPE_UNKNOWN, NULL);
57
if(opt && string_strcmp(opt->value, "dbengine") == 0) {
58
ret = true;
59
break;
@@ -74,14 +76,14 @@ bool stream_conf_has_api_enabled(struct config *root) {
76
if (uuid_parse(string2str(sect->name), uuid) != 0)
77
continue;
78
77
- opt = appconfig_option_find(sect, "type");
79
+ opt = inicfg_option_find(sect, "type");
80
// when the 'type' is missing, we assume it is 'api'
81
if(opt && string_strcmp(opt->value, "api") != 0)
82
continue;
83
82
- opt = appconfig_option_find(sect, "enabled");
84
+ opt = inicfg_option_find(sect, "enabled");
85
// when the 'enabled' is missing, we assume it is 'false'
84
- if(!opt || !appconfig_test_boolean_value(string2str(opt->value)))
86
+ if(!opt || !inicfg_test_boolean_value(string2str(opt->value)))
87
continue;
88
89
is_parent = true;
@@ -91,13 +93,3 @@ bool stream_conf_has_api_enabled(struct config *root) {
93
94
return is_parent;
95
}
94
-
95
-void appconfig_foreach_section(struct config *root, void (*cb)(struct config *root, const char *name, void *data), void *data) {
96
- struct config_section *sect = NULL;
97
-
98
- APPCONFIG_LOCK(root);
99
- for (sect = root->sections; sect; sect = sect->next) {
100
- cb(root, string2str(sect->name), data);
101
- }
102
- APPCONFIG_UNLOCK(root);
103
-}
src/libnetdata/inicfg/inicfg.h
renamed
+48
-30
@@ -1,5 +1,8 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
+#ifndef LIBNETDATA_INICFG_H
4
+#define LIBNETDATA_INICFG_H
5
+
6
/*
7
* This section manages ini config files, like netdata.conf and stream.conf
8
*
@@ -75,9 +78,6 @@
78
* a method to allocate only the dynamic option names.
79
*/
80
78
-#ifndef NETDATA_CONFIG_H
79
-#define NETDATA_CONFIG_H 1
80
-
81
#include "../libnetdata.h"
82
83
#define CONFIG_FILENAME "netdata.conf"
@@ -126,29 +126,29 @@ struct config {
126
.index = { \
127
.avl_tree = { \
128
.root = NULL, \
129
- .compar = appconfig_section_compare, \
129
+ .compar = inicfg_section_compare, \
130
}, \
131
.rwlock = AVL_LOCK_INITIALIZER, \
132
}, \
133
}
134
135
-int appconfig_load(struct config *root, char *filename, int overwrite_used, const char *section_name);
135
+int inicfg_load(struct config *root, char *filename, int overwrite_used, const char *section_name);
136
137
-typedef bool (*appconfig_foreach_value_cb_t)(void *data, const char *name, const char *value);
138
-size_t appconfig_foreach_value_in_section(struct config *root, const char *section, appconfig_foreach_value_cb_t cb, void *data);
137
+typedef bool (*inicfg_foreach_value_cb_t)(void *data, const char *name, const char *value);
138
+size_t inicfg_foreach_value_in_section(struct config *root, const char *section, inicfg_foreach_value_cb_t cb, void *data);
139
140
// sets a raw value, only if it is not loaded from the config
141
-void appconfig_set_default_raw_value(struct config *root, const char *section, const char *name, const char *value);
141
+void inicfg_set_default_raw_value(struct config *root, const char *section, const char *name, const char *value);
142
143
-int appconfig_exists(struct config *root, const char *section, const char *name);
144
-int appconfig_move(struct config *root, const char *section_old, const char *name_old, const char *section_new, const char *name_new);
145
-int appconfig_move_everywhere(struct config *root, const char *name_old, const char *name_new);
143
+int inicfg_exists(struct config *root, const char *section, const char *name);
144
+int inicfg_move(struct config *root, const char *section_old, const char *name_old, const char *section_new, const char *name_new);
145
+int inicfg_move_everywhere(struct config *root, const char *name_old, const char *name_new);
146
147
-void appconfig_generate(struct config *root, BUFFER *wb, int only_changed, bool netdata_conf);
147
+void inicfg_generate(struct config *root, BUFFER *wb, int only_changed, bool netdata_conf);
148
149
-int appconfig_section_compare(void *a, void *b);
149
+int inicfg_section_compare(void *a, void *b);
150
151
-bool appconfig_test_boolean_value(const char *s);
151
+bool inicfg_test_boolean_value(const char *s);
152
153
struct connector_instance {
154
char instance_name[CONFIG_MAX_NAME + 1];
@@ -168,27 +168,45 @@ _CONNECTOR_INSTANCE *add_connector_instance(struct config_section *connector, st
168
// ----------------------------------------------------------------------------
169
// shortcuts for the default netdata configuration
170
171
-#define config_load(filename, overwrite_used, section) appconfig_load(&netdata_config, filename, overwrite_used, section)
171
+extern struct config netdata_config;
172
173
-#define config_set_default_raw_value(section, name, value) appconfig_set_default_raw_value(&netdata_config, section, name, value)
173
+bool stream_conf_needs_dbengine(struct config *root);
174
+bool stream_conf_has_api_enabled(struct config *root);
175
175
-#define config_exists(section, name) appconfig_exists(&netdata_config, section, name)
176
-#define config_move(section_old, name_old, section_new, name_new) appconfig_move(&netdata_config, section_old, name_old, section_new, name_new)
176
+const char *inicfg_get(struct config *root, const char *section, const char *name, const char *default_value);
177
+const char *inicfg_set(struct config *root, const char *section, const char *name, const char *value);
178
178
-#define netdata_conf_generate(buffer, only_changed) appconfig_generate(&netdata_config, buffer, only_changed, true)
179
+long long inicfg_get_number(struct config *root, const char *section, const char *name, long long value);
180
+long long inicfg_set_number(struct config *root, const char *section, const char *name, long long value);
181
+NETDATA_DOUBLE inicfg_get_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value);
182
+NETDATA_DOUBLE inicfg_set_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value);
183
180
-#define config_section_destroy(section) appconfig_section_destroy_non_loaded(&netdata_config, section)
181
-#define config_section_option_destroy(section, name) appconfig_section_option_destroy_non_loaded(&netdata_config, section, name)
184
+// disabled
185
+#define CONFIG_BOOLEAN_NO 0
186
+// enabled
187
+#define CONFIG_BOOLEAN_YES 1
188
+// enabled if it has useful info when enabled
189
+#define CONFIG_BOOLEAN_AUTO 2
190
+// an invalid value to check for validity (used as default initialization when needed)
191
+#define CONFIG_BOOLEAN_INVALID 100
192
183
-bool stream_conf_needs_dbengine(struct config *root);
184
-bool stream_conf_has_api_enabled(struct config *root);
193
+int inicfg_get_boolean(struct config *root, const char *section, const char *name, int value);
194
+int inicfg_get_boolean_ondemand(struct config *root, const char *section, const char *name, int value);
195
+int inicfg_set_boolean(struct config *root, const char *section, const char *name, int value);
196
+
197
+uint64_t inicfg_get_size_bytes(struct config *root, const char *section, const char *name, uint64_t default_value);
198
+uint64_t inicfg_set_size_bytes(struct config *root, const char *section, const char *name, uint64_t value);
199
+
200
+uint64_t inicfg_get_size_mb(struct config *root, const char *section, const char *name, uint64_t default_value);
201
+uint64_t inicfg_set_size_mb(struct config *root, const char *section, const char *name, uint64_t value);
202
+
203
+msec_t inicfg_get_duration_ms(struct config *root, const char *section, const char *name, msec_t default_value);
204
+msec_t inicfg_set_duration_ms(struct config *root, const char *section, const char *name, msec_t value);
205
186
-void appconfig_foreach_section(struct config *root, void (*cb)(struct config *root, const char *name, void *data), void *data);
206
+time_t inicfg_get_duration_seconds(struct config *root, const char *section, const char *name, time_t default_value);
207
+time_t inicfg_set_duration_seconds(struct config *root, const char *section, const char *name, time_t value);
208
188
-#include "appconfig_api_text.h"
189
-#include "appconfig_api_numbers.h"
190
-#include "appconfig_api_boolean.h"
191
-#include "appconfig_api_sizes.h"
192
-#include "appconfig_api_durations.h"
209
+unsigned inicfg_get_duration_days(struct config *root, const char *section, const char *name, unsigned default_value);
210
+unsigned inicfg_set_duration_days(struct config *root, const char *section, const char *name, unsigned value);
211
194
-#endif // NETDATA_CONFIG_H
212
+#endif // LIBNETDATA_INICFG_H
src/libnetdata/inicfg/inicfg_api.c
new
+328
@@ -0,0 +1,328 @@
1
+// SPDX-License-Identifier: GPL-3.0-or-later
2
+
3
+#include "inicfg_internals.h"
4
+
5
+const char *inicfg_get(struct config *root, const char *section, const char *name, const char *default_value) {
6
+ struct config_option *opt = inicfg_get_raw_value(root, section, name, default_value, CONFIG_VALUE_TYPE_TEXT, NULL);
7
+ if(!opt)
8
+ return default_value;
9
+
10
+ return string2str(opt->value);
11
+}
12
+
13
+const char *inicfg_set(struct config *root, const char *section, const char *name, const char *value) {
14
+ struct config_option *opt = inicfg_set_raw_value(root, section, name, value, CONFIG_VALUE_TYPE_TEXT);
15
+ return string2str(opt->value);
16
+}
17
+
18
+bool inicfg_test_boolean_value(const char *s) {
19
+ if(!strcasecmp(s, "yes") || !strcasecmp(s, "true") || !strcasecmp(s, "on")
20
+ || !strcasecmp(s, "auto") || !strcasecmp(s, "on demand"))
21
+ return true;
22
+
23
+ return false;
24
+}
25
+
26
+int inicfg_get_boolean_by_section(struct config_section *sect, const char *name, int value) {
27
+ struct config_option *opt = inicfg_get_raw_value_of_option_in_section(
28
+ sect, name, (!value) ? "no" : "yes", CONFIG_VALUE_TYPE_BOOLEAN, NULL);
29
+ if(!opt) return value;
30
+
31
+ return inicfg_test_boolean_value(string2str(opt->value));
32
+}
33
+
34
+int inicfg_get_boolean(struct config *root, const char *section, const char *name, int value) {
35
+ const char *s;
36
+ if(value) s = "yes";
37
+ else s = "no";
38
+
39
+ struct config_option *opt = inicfg_get_raw_value(root, section, name, s, CONFIG_VALUE_TYPE_BOOLEAN, NULL);
40
+ if(!opt) return value;
41
+ s = string2str(opt->value);
42
+
43
+ return inicfg_test_boolean_value(s);
44
+}
45
+
46
+int inicfg_get_boolean_ondemand(struct config *root, const char *section, const char *name, int value) {
47
+ const char *s;
48
+
49
+ if(value == CONFIG_BOOLEAN_AUTO)
50
+ s = "auto";
51
+
52
+ else if(value == CONFIG_BOOLEAN_NO)
53
+ s = "no";
54
+
55
+ else
56
+ s = "yes";
57
+
58
+ struct config_option *opt = inicfg_get_raw_value(root, section, name, s, CONFIG_VALUE_TYPE_BOOLEAN_ONDEMAND, NULL);
59
+ if(!opt) return value;
60
+
61
+ s = string2str(opt->value);
62
+ if(!strcmp(s, "yes") || !strcmp(s, "true") || !strcmp(s, "on"))
63
+ return CONFIG_BOOLEAN_YES;
64
+ else if(!strcmp(s, "no") || !strcmp(s, "false") || !strcmp(s, "off"))
65
+ return CONFIG_BOOLEAN_NO;
66
+ else if(!strcmp(s, "auto") || !strcmp(s, "on demand"))
67
+ return CONFIG_BOOLEAN_AUTO;
68
+
69
+ return value;
70
+}
71
+
72
+int inicfg_set_boolean(struct config *root, const char *section, const char *name, int value) {
73
+ const char *s;
74
+ if(value) s = "yes";
75
+ else s = "no";
76
+
77
+ inicfg_set_raw_value(root, section, name, s, CONFIG_VALUE_TYPE_BOOLEAN);
78
+
79
+ return value;
80
+}
81
+
82
+static STRING *reformat_duration_seconds(STRING *value) {
83
+ int result = 0;
84
+ if(!duration_parse_seconds(string2str(value), &result))
85
+ return value;
86
+
87
+ char buf[128];
88
+ if(duration_snprintf_time_t(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
89
+ string_freez(value);
90
+ return string_strdupz(buf);
91
+ }
92
+
93
+ return value;
94
+}
95
+
96
+time_t inicfg_get_duration_seconds(struct config *root, const char *section, const char *name, time_t default_value) {
97
+ char default_str[128];
98
+ duration_snprintf_time_t(default_str, sizeof(default_str), default_value);
99
+
100
+ struct config_option *opt = inicfg_get_raw_value(
101
+ root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_SECS, reformat_duration_seconds);
102
+ if(!opt)
103
+ return default_value;
104
+
105
+ const char *s = string2str(opt->value);
106
+
107
+ int result = 0;
108
+ if(!duration_parse_seconds(s, &result)) {
109
+ inicfg_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_SECS);
110
+ netdata_log_error("config option '[%s].%s = %s' is configured with an invalid duration", section, name, s);
111
+ return default_value;
112
+ }
113
+
114
+ return ABS(result);
115
+}
116
+
117
+time_t inicfg_set_duration_seconds(struct config *root, const char *section, const char *name, time_t value) {
118
+ char str[128];
119
+ duration_snprintf_time_t(str, sizeof(str), value);
120
+
121
+ inicfg_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_DURATION_IN_SECS);
122
+ return value;
123
+}
124
+
125
+static STRING *reformat_duration_ms(STRING *value) {
126
+ int64_t result = 0;
127
+ if(!duration_parse_msec_t(string2str(value), &result))
128
+ return value;
129
+
130
+ char buf[128];
131
+ if(duration_snprintf_msec_t(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
132
+ string_freez(value);
133
+ return string_strdupz(buf);
134
+ }
135
+
136
+ return value;
137
+}
138
+
139
+msec_t inicfg_get_duration_ms(struct config *root, const char *section, const char *name, msec_t default_value) {
140
+ char default_str[128];
141
+ duration_snprintf_msec_t(default_str, sizeof(default_str), default_value);
142
+
143
+ struct config_option *opt = inicfg_get_raw_value(
144
+ root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_MS, reformat_duration_ms);
145
+ if(!opt)
146
+ return default_value;
147
+
148
+ const char *s = string2str(opt->value);
149
+
150
+ smsec_t result = 0;
151
+ if(!duration_parse_msec_t(s, &result)) {
152
+ inicfg_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_MS);
153
+ netdata_log_error("config option '[%s].%s = %s' is configured with an invalid duration", section, name, s);
154
+ return default_value;
155
+ }
156
+
157
+ return ABS(result);
158
+}
159
+
160
+msec_t inicfg_set_duration_ms(struct config *root, const char *section, const char *name, msec_t value) {
161
+ char str[128];
162
+ duration_snprintf_msec_t(str, sizeof(str), (smsec_t)value);
163
+
164
+ inicfg_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_DURATION_IN_MS);
165
+ return value;
166
+}
167
+
168
+static STRING *reformat_duration_days(STRING *value) {
169
+ int64_t result = 0;
170
+ if(!duration_parse_days(string2str(value), &result))
171
+ return value;
172
+
173
+ char buf[128];
174
+ if(duration_snprintf_days(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
175
+ string_freez(value);
176
+ return string_strdupz(buf);
177
+ }
178
+
179
+ return value;
180
+}
181
+
182
+unsigned inicfg_get_duration_days(struct config *root, const char *section, const char *name, unsigned default_value) {
183
+ char default_str[128];
184
+ duration_snprintf_days(default_str, sizeof(default_str), (int)default_value);
185
+
186
+ struct config_option *opt = inicfg_get_raw_value(
187
+ root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_DAYS, reformat_duration_days);
188
+ if(!opt)
189
+ return default_value;
190
+
191
+ const char *s = string2str(opt->value);
192
+
193
+ int64_t result = 0;
194
+ if(!duration_parse_days(s, &result)) {
195
+ inicfg_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_DURATION_IN_DAYS);
196
+ netdata_log_error("config option '[%s].%s = %s' is configured with an invalid duration", section, name, s);
197
+ return default_value;
198
+ }
199
+
200
+ return (unsigned)ABS(result);
201
+}
202
+
203
+unsigned inicfg_set_duration_days(struct config *root, const char *section, const char *name, unsigned value) {
204
+ char str[128];
205
+ duration_snprintf_days(str, sizeof(str), value);
206
+ inicfg_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_DURATION_IN_DAYS);
207
+ return value;
208
+}
209
+
210
+long long inicfg_get_number(struct config *root, const char *section, const char *name, long long value) {
211
+ char buffer[100];
212
+ sprintf(buffer, "%lld", value);
213
+
214
+ struct config_option *opt = inicfg_get_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_INTEGER, NULL);
215
+ if(!opt) return value;
216
+
217
+ const char *s = string2str(opt->value);
218
+ return strtoll(s, NULL, 0);
219
+}
220
+
221
+NETDATA_DOUBLE inicfg_get_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value) {
222
+ char buffer[100];
223
+ sprintf(buffer, "%0.5" NETDATA_DOUBLE_MODIFIER, value);
224
+
225
+ struct config_option *opt = inicfg_get_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_DOUBLE, NULL);
226
+ if(!opt) return value;
227
+
228
+ const char *s = string2str(opt->value);
229
+ return str2ndd(s, NULL);
230
+}
231
+
232
+long long inicfg_set_number(struct config *root, const char *section, const char *name, long long value) {
233
+ char buffer[100];
234
+ sprintf(buffer, "%lld", value);
235
+
236
+ inicfg_set_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_INTEGER);
237
+ return value;
238
+}
239
+
240
+NETDATA_DOUBLE inicfg_set_double(struct config *root, const char *section, const char *name, NETDATA_DOUBLE value) {
241
+ char buffer[100];
242
+ sprintf(buffer, "%0.5" NETDATA_DOUBLE_MODIFIER, value);
243
+
244
+ inicfg_set_raw_value(root, section, name, buffer, CONFIG_VALUE_TYPE_DOUBLE);
245
+ return value;
246
+}
247
+
248
+static STRING *reformat_size_bytes(STRING *value) {
249
+ uint64_t result = 0;
250
+ if(!size_parse_bytes(string2str(value), &result))
251
+ return value;
252
+
253
+ char buf[128];
254
+ if(size_snprintf_bytes(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
255
+ string_freez(value);
256
+ return string_strdupz(buf);
257
+ }
258
+
259
+ return value;
260
+}
261
+
262
+uint64_t inicfg_get_size_bytes(struct config *root, const char *section, const char *name, uint64_t default_value) {
263
+ char default_str[128];
264
+ size_snprintf_bytes(default_str, sizeof(default_str), default_value);
265
+
266
+ struct config_option *opt =
267
+ inicfg_get_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_BYTES, reformat_size_bytes);
268
+ if(!opt)
269
+ return default_value;
270
+
271
+ const char *s = string2str(opt->value);
272
+ uint64_t result = 0;
273
+ if(!size_parse_bytes(s, &result)) {
274
+ inicfg_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_BYTES);
275
+ netdata_log_error("config option '[%s].%s = %s' is configured with an invalid size", section, name, s);
276
+ return default_value;
277
+ }
278
+
279
+ return result;
280
+}
281
+
282
+uint64_t inicfg_set_size_bytes(struct config *root, const char *section, const char *name, uint64_t value) {
283
+ char str[128];
284
+ size_snprintf_bytes(str, sizeof(str), value);
285
+ inicfg_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_SIZE_IN_BYTES);
286
+ return value;
287
+}
288
+
289
+static STRING *reformat_size_mb(STRING *value) {
290
+ uint64_t result = 0;
291
+ if(!size_parse_mb(string2str(value), &result))
292
+ return value;
293
+
294
+ char buf[128];
295
+ if(size_snprintf_mb(buf, sizeof(buf), result) > 0 && string_strcmp(value, buf) != 0) {
296
+ string_freez(value);
297
+ return string_strdupz(buf);
298
+ }
299
+
300
+ return value;
301
+}
302
+
303
+uint64_t inicfg_get_size_mb(struct config *root, const char *section, const char *name, uint64_t default_value) {
304
+ char default_str[128];
305
+ size_snprintf_mb(default_str, sizeof(default_str), default_value);
306
+
307
+ struct config_option *opt =
308
+ inicfg_get_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_MB, reformat_size_mb);
309
+ if(!opt)
310
+ return default_value;
311
+
312
+ const char *s = string2str(opt->value);
313
+ uint64_t result = 0;
314
+ if(!size_parse_mb(s, &result)) {
315
+ inicfg_set_raw_value(root, section, name, default_str, CONFIG_VALUE_TYPE_SIZE_IN_MB);
316
+ netdata_log_error("config option '[%s].%s = %s' is configured with an invalid size", section, name, s);
317
+ return default_value;
318
+ }
319
+
320
+ return (unsigned)result;
321
+}
322
+
323
+uint64_t inicfg_set_size_mb(struct config *root, const char *section, const char *name, uint64_t value) {
324
+ char str[128];
325
+ size_snprintf_mb(str, sizeof(str), value);
326
+ inicfg_set_raw_value(root, section, name, str, CONFIG_VALUE_TYPE_SIZE_IN_MB);
327
+ return value;
328
+}
src/libnetdata/inicfg/inicfg_cleanup.c
renamed
+9
-9
@@ -1,15 +1,15 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
-void appconfig_section_destroy_non_loaded(struct config *root, const char *section)
5
+void inicfg_section_destroy_non_loaded(struct config *root, const char *section)
6
{
7
struct config_section *sect;
8
struct config_option *opt;
9
10
netdata_log_debug(D_CONFIG, "Destroying section '%s'.", section);
11
12
- sect = appconfig_section_find(root, section);
12
+ sect = inicfg_section_find(root, section);
13
if(!sect) {
14
netdata_log_error("Could not destroy section '%s'. Not found.", section);
15
return;
@@ -27,12 +27,12 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti
27
}
28
29
// no option is loaded, free them all
30
- appconfig_section_remove_and_delete(root, sect, false, true);
30
+ inicfg_section_remove_and_delete(root, sect, false, true);
31
}
32
33
-void appconfig_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name) {
33
+void inicfg_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name) {
34
struct config_section *sect;
35
- sect = appconfig_section_find(root, section);
35
+ sect = inicfg_section_find(root, section);
36
if (!sect) {
37
netdata_log_error("Could not destroy section option '%s -> %s'. The section not found.", section, name);
38
return;
@@ -40,13 +40,13 @@ void appconfig_section_option_destroy_non_loaded(struct config *root, const char
40
41
SECTION_LOCK(sect);
42
43
- struct config_option *opt = appconfig_option_find(sect, name);
43
+ struct config_option *opt = inicfg_option_find(sect, name);
44
if (opt && opt->flags & CONFIG_VALUE_LOADED) {
45
SECTION_UNLOCK(sect);
46
return;
47
}
48
49
- if (unlikely(!(opt && appconfig_option_del(sect, opt)))) {
49
+ if (unlikely(!(opt && inicfg_option_del(sect, opt)))) {
50
SECTION_UNLOCK(sect);
51
netdata_log_error("Could not destroy section option '%s -> %s'. The option not found.", section, name);
52
return;
@@ -54,7 +54,7 @@ void appconfig_section_option_destroy_non_loaded(struct config *root, const char
54
55
DOUBLE_LINKED_LIST_REMOVE_ITEM_UNSAFE(sect->values, opt, prev, next);
56
57
- appconfig_option_free(opt);
57
+ inicfg_option_free(opt);
58
SECTION_UNLOCK(sect);
59
}
60
src/libnetdata/inicfg/inicfg_conf_file.c
renamed
+13
-13
@@ -1,6 +1,6 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
ENUM_STR_MAP_DEFINE(CONFIG_VALUE_TYPES) = {
6
{ .id = CONFIG_VALUE_TYPE_UNKNOWN, .name ="unknown", },
@@ -30,7 +30,7 @@ ENUM_STR_DEFINE_FUNCTIONS(CONFIG_VALUE_TYPES, CONFIG_VALUE_TYPE_UNKNOWN, "unknow
30
// ----------------------------------------------------------------------------
31
// config load/save
32
33
-int appconfig_load(struct config *root, char *filename, int overwrite_used, const char *section_name) {
33
+int inicfg_load(struct config *root, char *filename, int overwrite_used, const char *section_name) {
34
int line = 0;
35
struct config_section *sect = NULL;
36
int is_exporter_config = 0;
@@ -89,7 +89,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
89
}
90
strncpyz(working_instance, s, CONFIG_MAX_NAME);
91
working_connector_section = NULL;
92
- if (unlikely(appconfig_section_find(root, working_instance))) {
92
+ if (unlikely(inicfg_section_find(root, working_instance))) {
93
netdata_log_error("Instance (%s) already exists", working_instance);
94
sect = NULL;
95
continue;
@@ -103,15 +103,15 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
103
}
104
}
105
106
- sect = appconfig_section_find(root, s);
106
+ sect = inicfg_section_find(root, s);
107
if(!sect)
108
- sect = appconfig_section_create(root, s);
108
+ sect = inicfg_section_create(root, s);
109
110
if(sect && section_string && overwrite_used && section_string == sect->name) {
111
SECTION_LOCK(sect);
112
113
while(sect->values)
114
- appconfig_option_remove_and_delete(sect, sect->values, true);
114
+ inicfg_option_remove_and_delete(sect, sect->values, true);
115
116
SECTION_UNLOCK(sect);
117
}
@@ -147,15 +147,15 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
147
148
if(!value) value = "";
149
150
- struct config_option *opt = appconfig_option_find(sect, name);
150
+ struct config_option *opt = inicfg_option_find(sect, name);
151
152
if (!opt) {
153
- opt = appconfig_option_create(sect, name, value);
153
+ opt = inicfg_option_create(sect, name, value);
154
if (likely(is_exporter_config) && unlikely(!global_exporting_section)) {
155
if (unlikely(!working_connector_section)) {
156
- working_connector_section = appconfig_section_find(root, working_connector);
156
+ working_connector_section = inicfg_section_find(root, working_connector);
157
if (!working_connector_section)
158
- working_connector_section = appconfig_section_create(root, working_connector);
158
+ working_connector_section = inicfg_section_create(root, working_connector);
159
if (likely(working_connector_section)) {
160
add_connector_instance(working_connector_section, sect);
161
}
@@ -176,7 +176,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
176
return 1;
177
}
178
179
-void appconfig_generate(struct config *root, BUFFER *wb, int only_changed, bool netdata_conf)
179
+void inicfg_generate(struct config *root, BUFFER *wb, int only_changed, bool netdata_conf)
180
{
181
int i, pri;
182
struct config_section *sect;
@@ -189,8 +189,8 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed, bool
189
found_host_labels = 1;
190
191
if(netdata_conf && !found_host_labels) {
192
- appconfig_section_create(root, CONFIG_SECTION_HOST_LABEL);
193
- appconfig_get_raw_value(root, CONFIG_SECTION_HOST_LABEL, "name", "value", CONFIG_VALUE_TYPE_TEXT, NULL);
192
+ inicfg_section_create(root, CONFIG_SECTION_HOST_LABEL);
193
+ inicfg_get_raw_value(root, CONFIG_SECTION_HOST_LABEL, "name", "value", CONFIG_VALUE_TYPE_TEXT, NULL);
194
}
195
}
196
src/libnetdata/inicfg/inicfg_exporters.c
renamed
+1
-1
@@ -1,6 +1,6 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
/*
6
* @Input:
src/libnetdata/inicfg/inicfg_internals.h
renamed
+28
-28
@@ -1,9 +1,9 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#ifndef NETDATA_APPCONFIG_INTERNALS_H
4
-#define NETDATA_APPCONFIG_INTERNALS_H
3
+#ifndef LIBNETDATA_INICFG_INTERNALS_H
4
+#define LIBNETDATA_INICFG_INTERNALS_H
5
6
-#include "appconfig.h"
6
+#include "inicfg.h"
7
8
typedef enum __attribute__((packed)) {
9
CONFIG_VALUE_TYPE_UNKNOWN = 0,
@@ -46,7 +46,7 @@ struct config_option {
46
STRING *value;
47
48
STRING *value_original; // the original value of this option (the first value it got, independently on how it got it)
49
- STRING *value_default; // the internal default value of this option (the first value it got, from appconfig_get_XXX())
49
+ STRING *value_default; // the internal default value of this option (the first value it got, from inicfg_get_XXX())
50
51
// when we move options around, this is where we keep the original
52
// section and name (of the first migration)
@@ -79,41 +79,41 @@ struct config_section {
79
#define SECTION_UNLOCK(sect) spinlock_unlock(&((sect)->spinlock));
80
81
// config sections
82
-void appconfig_section_free(struct config_section *sect);
83
-void appconfig_section_remove_and_delete(struct config *root, struct config_section *sect, bool have_root_lock, bool have_sect_lock);
84
-#define appconfig_section_add(root, cfg) (struct config_section *)avl_insert_lock(&(root)->index, (avl_t *)(cfg))
85
-#define appconfig_section_del(root, cfg) (struct config_section *)avl_remove_lock(&(root)->index, (avl_t *)(cfg))
86
-struct config_section *appconfig_section_find(struct config *root, const char *name);
87
-struct config_section *appconfig_section_create(struct config *root, const char *section);
82
+void inicfg_section_free(struct config_section *sect);
83
+void inicfg_section_remove_and_delete(struct config *root, struct config_section *sect, bool have_root_lock, bool have_sect_lock);
84
+#define inicfg_section_add(root, cfg) (struct config_section *)avl_insert_lock(&(root)->index, (avl_t *)(cfg))
85
+#define inicfg_section_del(root, cfg) (struct config_section *)avl_remove_lock(&(root)->index, (avl_t *)(cfg))
86
+struct config_section *inicfg_section_find(struct config *root, const char *name);
87
+struct config_section *inicfg_section_create(struct config *root, const char *section);
88
89
// config options
90
-void appconfig_option_cleanup(struct config_option *opt);
91
-void appconfig_option_free(struct config_option *opt);
92
-void appconfig_option_remove_and_delete(struct config_section *sect, struct config_option *opt, bool have_sect_lock);
93
-void appconfig_option_remove_and_delete_all(struct config_section *sect, bool have_sect_lock);
94
-int appconfig_option_compare(void *a, void *b);
95
-#define appconfig_option_add(co, cv) (struct config_option *)avl_insert_lock(&((co)->values_index), (avl_t *)(cv))
96
-#define appconfig_option_del(co, cv) (struct config_option *)avl_remove_lock(&((co)->values_index), (avl_t *)(cv))
97
-struct config_option *appconfig_option_find(struct config_section *sect, const char *name);
98
-struct config_option *appconfig_option_create(struct config_section *sect, const char *name, const char *value);
90
+void inicfg_option_cleanup(struct config_option *opt);
91
+void inicfg_option_free(struct config_option *opt);
92
+void inicfg_option_remove_and_delete(struct config_section *sect, struct config_option *opt, bool have_sect_lock);
93
+void inicfg_option_remove_and_delete_all(struct config_section *sect, bool have_sect_lock);
94
+int inicfg_option_compare(void *a, void *b);
95
+#define inicfg_option_add(co, cv) (struct config_option *)avl_insert_lock(&((co)->values_index), (avl_t *)(cv))
96
+#define inicfg_option_del(co, cv) (struct config_option *)avl_remove_lock(&((co)->values_index), (avl_t *)(cv))
97
+struct config_option *inicfg_option_find(struct config_section *sect, const char *name);
98
+struct config_option *inicfg_option_create(struct config_section *sect, const char *name, const char *value);
99
100
// lookup
101
-int appconfig_get_boolean_by_section(struct config_section *sect, const char *name, int value);
101
+int inicfg_get_boolean_by_section(struct config_section *sect, const char *name, int value);
102
103
typedef STRING *(*reformat_t)(STRING *value);
104
-struct config_option *appconfig_get_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb);
105
-struct config_option *appconfig_get_raw_value(struct config *root, const char *section, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb);
104
+struct config_option *inicfg_get_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb);
105
+struct config_option *inicfg_get_raw_value(struct config *root, const char *section, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb);
106
107
-void appconfig_set_raw_value_of_option(struct config_option *opt, const char *value, CONFIG_VALUE_TYPES type);
108
-struct config_option *appconfig_set_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *value, CONFIG_VALUE_TYPES type);
109
-struct config_option *appconfig_set_raw_value(struct config *root, const char *section, const char *option, const char *value, CONFIG_VALUE_TYPES type);
107
+void inicfg_set_raw_value_of_option(struct config_option *opt, const char *value, CONFIG_VALUE_TYPES type);
108
+struct config_option *inicfg_set_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *value, CONFIG_VALUE_TYPES type);
109
+struct config_option *inicfg_set_raw_value(struct config *root, const char *section, const char *option, const char *value, CONFIG_VALUE_TYPES type);
110
111
// cleanup
112
-void appconfig_section_destroy_non_loaded(struct config *root, const char *section);
113
-void appconfig_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name);
112
+void inicfg_section_destroy_non_loaded(struct config *root, const char *section);
113
+void inicfg_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name);
114
115
// exporters
116
_CONNECTOR_INSTANCE *add_connector_instance(struct config_section *connector, struct config_section *instance);
117
int is_valid_connector(char *type, int check_reserved);
118
119
-#endif //NETDATA_APPCONFIG_INTERNALS_H
119
+#endif /* LIBNETDATA_INICFG_INTERNALS_H */
src/libnetdata/inicfg/inicfg_migrate.c
renamed
+11
-11
@@ -1,30 +1,30 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
-int appconfig_move(struct config *root, const char *section_old, const char *name_old, const char *section_new, const char *name_new) {
5
+int inicfg_move(struct config *root, const char *section_old, const char *name_old, const char *section_new, const char *name_new) {
6
struct config_option *opt_old, *opt_new;
7
int ret = -1;
8
9
netdata_log_debug(D_CONFIG, "request to rename config in section '%s', old name '%s', to section '%s', new name '%s'", section_old, name_old, section_new, name_new);
10
11
- struct config_section *sect_old = appconfig_section_find(root, section_old);
11
+ struct config_section *sect_old = inicfg_section_find(root, section_old);
12
if(!sect_old) return ret;
13
14
- struct config_section *sect_new = appconfig_section_find(root, section_new);
15
- if(!sect_new) sect_new = appconfig_section_create(root, section_new);
14
+ struct config_section *sect_new = inicfg_section_find(root, section_new);
15
+ if(!sect_new) sect_new = inicfg_section_create(root, section_new);
16
17
SECTION_LOCK(sect_old);
18
if(sect_old != sect_new)
19
SECTION_LOCK(sect_new);
20
21
- opt_old = appconfig_option_find(sect_old, name_old);
21
+ opt_old = inicfg_option_find(sect_old, name_old);
22
if(!opt_old) goto cleanup;
23
24
- opt_new = appconfig_option_find(sect_new, name_new);
24
+ opt_new = inicfg_option_find(sect_new, name_new);
25
if(opt_new) goto cleanup;
26
27
- if(unlikely(appconfig_option_del(sect_old, opt_old) != opt_old))
27
+ if(unlikely(inicfg_option_del(sect_old, opt_old) != opt_old))
28
netdata_log_error("INTERNAL ERROR: deletion of config '%s' from section '%s', deleted the wrong config entry.",
29
string2str(opt_old->name), string2str(sect_old->name));
30
@@ -68,7 +68,7 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
68
DOUBLE_LINKED_LIST_INSERT_ITEM_AFTER_UNSAFE(sect_new->values, t, opt_new, prev, next);
69
}
70
71
- if(unlikely(appconfig_option_add(sect_new, opt_old) != opt_old))
71
+ if(unlikely(inicfg_option_add(sect_new, opt_old) != opt_old))
72
netdata_log_error("INTERNAL ERROR: re-indexing of config '%s' in section '%s', already exists.",
73
string2str(opt_old->name), string2str(sect_new->name));
74
@@ -81,12 +81,12 @@ cleanup:
81
return ret;
82
}
83
84
-int appconfig_move_everywhere(struct config *root, const char *name_old, const char *name_new) {
84
+int inicfg_move_everywhere(struct config *root, const char *name_old, const char *name_new) {
85
int ret = -1;
86
APPCONFIG_LOCK(root);
87
struct config_section *sect;
88
for(sect = root->sections; sect; sect = sect->next) {
89
- if(appconfig_move(root, string2str(sect->name), name_old, string2str(sect->name), name_new) == 0)
89
+ if(inicfg_move(root, string2str(sect->name), name_old, string2str(sect->name), name_new) == 0)
90
ret = 0;
91
}
92
APPCONFIG_UNLOCK(root);
src/libnetdata/inicfg/inicfg_options.c
renamed
+33
-33
@@ -1,31 +1,31 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
// ----------------------------------------------------------------------------
6
// config options index
7
8
-int appconfig_option_compare(void *a, void *b) {
8
+int inicfg_option_compare(void *a, void *b) {
9
if(((struct config_option *)a)->name < ((struct config_option *)b)->name) return -1;
10
else if(((struct config_option *)a)->name > ((struct config_option *)b)->name) return 1;
11
else return string_cmp(((struct config_option *)a)->name, ((struct config_option *)b)->name);
12
}
13
14
-struct config_option *appconfig_option_find(struct config_section *sect, const char *name) {
14
+struct config_option *inicfg_option_find(struct config_section *sect, const char *name) {
15
struct config_option opt_tmp = {
16
.name = string_strdupz(name),
17
};
18
19
struct config_option *rc = (struct config_option *)avl_search_lock(&(sect->values_index), (avl_t *) &opt_tmp);
20
21
- appconfig_option_cleanup(&opt_tmp);
21
+ inicfg_option_cleanup(&opt_tmp);
22
return rc;
23
}
24
25
// ----------------------------------------------------------------------------
26
// config options methods
27
28
-void appconfig_option_cleanup(struct config_option *opt) {
28
+void inicfg_option_cleanup(struct config_option *opt) {
29
string_freez(opt->value);
30
string_freez(opt->name);
31
string_freez(opt->migrated.section);
@@ -41,23 +41,23 @@ void appconfig_option_cleanup(struct config_option *opt) {
41
opt->value_default = NULL;
42
}
43
44
-void appconfig_option_free(struct config_option *opt) {
45
- appconfig_option_cleanup(opt);
44
+void inicfg_option_free(struct config_option *opt) {
45
+ inicfg_option_cleanup(opt);
46
freez(opt);
47
}
48
49
-struct config_option *appconfig_option_create(struct config_section *sect, const char *name, const char *value) {
49
+struct config_option *inicfg_option_create(struct config_section *sect, const char *name, const char *value) {
50
struct config_option *opt = callocz(1, sizeof(struct config_option));
51
opt->name = string_strdupz(name);
52
opt->value = string_strdupz(value);
53
opt->value_original = string_dup(opt->value);
54
55
- struct config_option *opt_found = appconfig_option_add(sect, opt);
55
+ struct config_option *opt_found = inicfg_option_add(sect, opt);
56
if(opt_found != opt) {
57
nd_log(NDLS_DAEMON, NDLP_INFO,
58
"CONFIG: config '%s' in section '%s': already exists - using the existing one.",
59
string2str(opt->name), string2str(sect->name));
60
- appconfig_option_free(opt);
60
+ inicfg_option_free(opt);
61
return opt_found;
62
}
63
@@ -68,8 +68,8 @@ struct config_option *appconfig_option_create(struct config_section *sect, const
68
return opt;
69
}
70
71
-void appconfig_option_remove_and_delete(struct config_section *sect, struct config_option *opt, bool have_sect_lock) {
72
- struct config_option *opt_found = appconfig_option_del(sect, opt);
71
+void inicfg_option_remove_and_delete(struct config_section *sect, struct config_option *opt, bool have_sect_lock) {
72
+ struct config_option *opt_found = inicfg_option_del(sect, opt);
73
if(opt_found != opt) {
74
nd_log(NDLS_DAEMON, NDLP_ERR,
75
"INTERNAL ERROR: Cannot remove '%s' from section '%s', it was not inserted before.",
@@ -85,21 +85,21 @@ void appconfig_option_remove_and_delete(struct config_section *sect, struct conf
85
if(!have_sect_lock)
86
SECTION_UNLOCK(sect);
87
88
- appconfig_option_free(opt);
88
+ inicfg_option_free(opt);
89
}
90
91
-void appconfig_option_remove_and_delete_all(struct config_section *sect, bool have_sect_lock) {
91
+void inicfg_option_remove_and_delete_all(struct config_section *sect, bool have_sect_lock) {
92
if(!have_sect_lock)
93
SECTION_LOCK(sect);
94
95
while(sect->values)
96
- appconfig_option_remove_and_delete(sect, sect->values, true);
96
+ inicfg_option_remove_and_delete(sect, sect->values, true);
97
98
if(!have_sect_lock)
99
SECTION_UNLOCK(sect);
100
}
101
102
-void appconfig_get_raw_value_of_option(struct config_option *opt, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb) {
102
+void inicfg_get_raw_value_of_option(struct config_option *opt, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb) {
103
opt->flags |= CONFIG_VALUE_USED;
104
105
if(type != CONFIG_VALUE_TYPE_UNKNOWN)
@@ -127,31 +127,31 @@ void appconfig_get_raw_value_of_option(struct config_option *opt, const char *de
127
opt->value_default = string_strdupz(default_value);
128
}
129
130
-struct config_option *appconfig_get_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb) {
130
+struct config_option *inicfg_get_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb) {
131
// Only calls internal to this file check for a NULL result, and they do not supply a NULL arg.
132
// External caller should treat NULL as an error case.
133
- struct config_option *opt = appconfig_option_find(sect, option);
133
+ struct config_option *opt = inicfg_option_find(sect, option);
134
if (!opt) {
135
if (!default_value) return NULL;
136
- opt = appconfig_option_create(sect, option, default_value);
136
+ opt = inicfg_option_create(sect, option, default_value);
137
if (!opt) return NULL;
138
}
139
140
- appconfig_get_raw_value_of_option(opt, default_value, type, cb);
140
+ inicfg_get_raw_value_of_option(opt, default_value, type, cb);
141
return opt;
142
}
143
144
-struct config_option *appconfig_get_raw_value(struct config *root, const char *section, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb) {
145
- struct config_section *sect = appconfig_section_find(root, section);
144
+struct config_option *inicfg_get_raw_value(struct config *root, const char *section, const char *option, const char *default_value, CONFIG_VALUE_TYPES type, reformat_t cb) {
145
+ struct config_section *sect = inicfg_section_find(root, section);
146
if(!sect) {
147
if(!default_value) return NULL;
148
- sect = appconfig_section_create(root, section);
148
+ sect = inicfg_section_create(root, section);
149
}
150
151
- return appconfig_get_raw_value_of_option_in_section(sect, option, default_value, type, cb);
151
+ return inicfg_get_raw_value_of_option_in_section(sect, option, default_value, type, cb);
152
}
153
154
-void appconfig_set_raw_value_of_option(struct config_option *opt, const char *value, CONFIG_VALUE_TYPES type) {
154
+void inicfg_set_raw_value_of_option(struct config_option *opt, const char *value, CONFIG_VALUE_TYPES type) {
155
opt->flags |= CONFIG_VALUE_USED;
156
157
if(opt->type == CONFIG_VALUE_TYPE_UNKNOWN)
@@ -165,19 +165,19 @@ void appconfig_set_raw_value_of_option(struct config_option *opt, const char *va
165
}
166
}
167
168
-struct config_option *appconfig_set_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *value, CONFIG_VALUE_TYPES type) {
169
- struct config_option *opt = appconfig_option_find(sect, option);
168
+struct config_option *inicfg_set_raw_value_of_option_in_section(struct config_section *sect, const char *option, const char *value, CONFIG_VALUE_TYPES type) {
169
+ struct config_option *opt = inicfg_option_find(sect, option);
170
if(!opt)
171
- opt = appconfig_option_create(sect, option, value);
171
+ opt = inicfg_option_create(sect, option, value);
172
173
- appconfig_set_raw_value_of_option(opt, value, type);
173
+ inicfg_set_raw_value_of_option(opt, value, type);
174
return opt;
175
}
176
177
-struct config_option *appconfig_set_raw_value(struct config *root, const char *section, const char *option, const char *value, CONFIG_VALUE_TYPES type) {
178
- struct config_section *sect = appconfig_section_find(root, section);
177
+struct config_option *inicfg_set_raw_value(struct config *root, const char *section, const char *option, const char *value, CONFIG_VALUE_TYPES type) {
178
+ struct config_section *sect = inicfg_section_find(root, section);
179
if(!sect)
180
- sect = appconfig_section_create(root, section);
180
+ sect = inicfg_section_create(root, section);
181
182
- return appconfig_set_raw_value_of_option_in_section(sect, option, value, type);
182
+ return inicfg_set_raw_value_of_option_in_section(sect, option, value, type);
183
}
src/libnetdata/inicfg/inicfg_sections.c
renamed
+12
-12
@@ -1,17 +1,17 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
// ----------------------------------------------------------------------------
6
// config sections index
7
8
-int appconfig_section_compare(void *a, void *b) {
8
+int inicfg_section_compare(void *a, void *b) {
9
if(((struct config_section *)a)->name < ((struct config_section *)b)->name) return -1;
10
else if(((struct config_section *)a)->name > ((struct config_section *)b)->name) return 1;
11
else return string_cmp(((struct config_section *)a)->name, ((struct config_section *)b)->name);
12
}
13
14
-struct config_section *appconfig_section_find(struct config *root, const char *name) {
14
+struct config_section *inicfg_section_find(struct config *root, const char *name) {
15
struct config_section sect_tmp = {
16
.name = string_strdupz(name),
17
};
@@ -24,14 +24,14 @@ struct config_section *appconfig_section_find(struct config *root, const char *n
24
// ----------------------------------------------------------------------------
25
// config section methods
26
27
-void appconfig_section_free(struct config_section *sect) {
27
+void inicfg_section_free(struct config_section *sect) {
28
avl_destroy_lock(§->values_index);
29
string_freez(sect->name);
30
freez(sect);
31
}
32
33
-void appconfig_section_remove_and_delete(struct config *root, struct config_section *sect, bool have_root_lock, bool have_sect_lock) {
34
- struct config_section *sect_found = appconfig_section_del(root, sect);
33
+void inicfg_section_remove_and_delete(struct config *root, struct config_section *sect, bool have_root_lock, bool have_sect_lock) {
34
+ struct config_section *sect_found = inicfg_section_del(root, sect);
35
if(sect_found != sect) {
36
nd_log(NDLS_DAEMON, NDLP_ERR,
37
"INTERNAL ERROR: Cannot remove section '%s', it was not inserted before.",
@@ -39,7 +39,7 @@ void appconfig_section_remove_and_delete(struct config *root, struct config_sect
39
return;
40
}
41
42
- appconfig_option_remove_and_delete_all(sect, have_sect_lock);
42
+ inicfg_option_remove_and_delete_all(sect, have_sect_lock);
43
44
if(!have_root_lock)
45
APPCONFIG_LOCK(root);
@@ -53,22 +53,22 @@ void appconfig_section_remove_and_delete(struct config *root, struct config_sect
53
if(have_sect_lock)
54
SECTION_UNLOCK(sect);
55
56
- appconfig_section_free(sect);
56
+ inicfg_section_free(sect);
57
}
58
59
-struct config_section *appconfig_section_create(struct config *root, const char *section) {
59
+struct config_section *inicfg_section_create(struct config *root, const char *section) {
60
struct config_section *sect = callocz(1, sizeof(struct config_section));
61
sect->name = string_strdupz(section);
62
spinlock_init(§->spinlock);
63
64
- avl_init_lock(§->values_index, appconfig_option_compare);
64
+ avl_init_lock(§->values_index, inicfg_option_compare);
65
66
- struct config_section *sect_found = appconfig_section_add(root, sect);
66
+ struct config_section *sect_found = inicfg_section_add(root, sect);
67
if(sect_found != sect) {
68
nd_log(NDLS_DAEMON, NDLP_ERR,
69
"CONFIG: section '%s', already exists, using existing.",
70
string2str(sect->name));
71
- appconfig_section_free(sect);
71
+ inicfg_section_free(sect);
72
return sect_found;
73
}
74
src/libnetdata/inicfg/inicfg_traversal.c
renamed
+3
-3
@@ -1,10 +1,10 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
-#include "appconfig_internals.h"
3
+#include "inicfg_internals.h"
4
5
-size_t appconfig_foreach_value_in_section(struct config *root, const char *section, appconfig_foreach_value_cb_t cb, void *data) {
5
+size_t inicfg_foreach_value_in_section(struct config *root, const char *section, inicfg_foreach_value_cb_t cb, void *data) {
6
size_t used = 0;
7
- struct config_section *co = appconfig_section_find(root, section);
7
+ struct config_section *co = inicfg_section_find(root, section);
8
if(co) {
9
SECTION_LOCK(co);
10
struct config_option *cv;
src/libnetdata/libnetdata.h
+1
-2
@@ -115,8 +115,7 @@ extern const char *netdata_configured_host_prefix;
115
#include "datetime/rfc7231.h"
116
#include "sanitizers/sanitizers.h"
117
118
-#include "config/dyncfg.h"
119
-#include "config/appconfig.h"
118
+#include "config/config.h"
119
#include "spawn_server/spawn_server.h"
120
#include "spawn_server/spawn_popen.h"
121
#include "procfile/procfile.h"
src/libnetdata/socket/listen-sockets.c
+4
-4
@@ -523,20 +523,20 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
523
int listen_sockets_setup(LISTEN_SOCKETS *sockets) {
524
listen_sockets_init(sockets);
525
526
- sockets->backlog = (int) appconfig_get_number(sockets->config, sockets->config_section, "listen backlog", sockets->backlog);
526
+ sockets->backlog = (int) inicfg_get_number(sockets->config, sockets->config_section, "listen backlog", sockets->backlog);
527
528
long long int old_port = sockets->default_port;
529
- long long int new_port = appconfig_get_number(sockets->config, sockets->config_section, "default port", sockets->default_port);
529
+ long long int new_port = inicfg_get_number(sockets->config, sockets->config_section, "default port", sockets->default_port);
530
if(new_port < 1 || new_port > 65535) {
531
nd_log(NDLS_DAEMON, NDLP_ERR,
532
"LISTENER: Invalid listen port %lld given. Defaulting to %lld.",
533
new_port, old_port);
534
535
- sockets->default_port = (uint16_t) appconfig_set_number(sockets->config, sockets->config_section, "default port", old_port);
535
+ sockets->default_port = (uint16_t) inicfg_set_number(sockets->config, sockets->config_section, "default port", old_port);
536
}
537
else sockets->default_port = (uint16_t)new_port;
538
539
- const char *s = appconfig_get(sockets->config, sockets->config_section, "bind to", sockets->default_bind_to);
539
+ const char *s = inicfg_get(sockets->config, sockets->config_section, "bind to", sockets->default_bind_to);
540
while(*s) {
541
const char *e = s;
542
src/ml/ml_config.cc
+24
-24
@@ -19,46 +19,46 @@ static T clamp(const T& Value, const T& Min, const T& Max) {
19
void ml_config_load(ml_config_t *cfg) {
20
const char *config_section_ml = CONFIG_SECTION_ML;
21
22
- int enable_anomaly_detection = config_get_boolean_ondemand(config_section_ml, "enabled", CONFIG_BOOLEAN_AUTO);
22
+ int enable_anomaly_detection = inicfg_get_boolean_ondemand(&netdata_config, config_section_ml, "enabled", CONFIG_BOOLEAN_AUTO);
23
24
/*
25
* Read values
26
*/
27
28
- unsigned max_train_samples = config_get_number(config_section_ml, "maximum num samples to train", 6 * 3600);
29
- unsigned min_train_samples = config_get_number(config_section_ml, "minimum num samples to train", 1 * 900);
30
- unsigned train_every = config_get_duration_seconds(config_section_ml, "train every", 3 * 3600);
28
+ unsigned max_train_samples = inicfg_get_number(&netdata_config, config_section_ml, "maximum num samples to train", 6 * 3600);
29
+ unsigned min_train_samples = inicfg_get_number(&netdata_config, config_section_ml, "minimum num samples to train", 1 * 900);
30
+ unsigned train_every = inicfg_get_duration_seconds(&netdata_config, config_section_ml, "train every", 3 * 3600);
31
32
- unsigned num_models_to_use = config_get_number(config_section_ml, "number of models per dimension", 18);
33
- unsigned delete_models_older_than = config_get_duration_seconds(config_section_ml, "delete models older than", 60 * 60 * 24 * 7);
32
+ unsigned num_models_to_use = inicfg_get_number(&netdata_config, config_section_ml, "number of models per dimension", 18);
33
+ unsigned delete_models_older_than = inicfg_get_duration_seconds(&netdata_config, config_section_ml, "delete models older than", 60 * 60 * 24 * 7);
34
35
- unsigned diff_n = config_get_number(config_section_ml, "num samples to diff", 1);
36
- unsigned smooth_n = config_get_number(config_section_ml, "num samples to smooth", 3);
37
- unsigned lag_n = config_get_number(config_section_ml, "num samples to lag", 5);
35
+ unsigned diff_n = inicfg_get_number(&netdata_config, config_section_ml, "num samples to diff", 1);
36
+ unsigned smooth_n = inicfg_get_number(&netdata_config, config_section_ml, "num samples to smooth", 3);
37
+ unsigned lag_n = inicfg_get_number(&netdata_config, config_section_ml, "num samples to lag", 5);
38
39
- double random_sampling_ratio = config_get_double(config_section_ml, "random sampling ratio", 1.0 / 5.0 /* default lag_n */);
40
- unsigned max_kmeans_iters = config_get_number(config_section_ml, "maximum number of k-means iterations", 1000);
39
+ double random_sampling_ratio = inicfg_get_double(&netdata_config, config_section_ml, "random sampling ratio", 1.0 / 5.0 /* default lag_n */);
40
+ unsigned max_kmeans_iters = inicfg_get_number(&netdata_config, config_section_ml, "maximum number of k-means iterations", 1000);
41
42
- double dimension_anomaly_rate_threshold = config_get_double(config_section_ml, "dimension anomaly score threshold", 0.99);
42
+ double dimension_anomaly_rate_threshold = inicfg_get_double(&netdata_config, config_section_ml, "dimension anomaly score threshold", 0.99);
43
44
- double host_anomaly_rate_threshold = config_get_double(config_section_ml, "host anomaly rate threshold", 1.0);
45
- std::string anomaly_detection_grouping_method = config_get(config_section_ml, "anomaly detection grouping method", "average");
46
- time_t anomaly_detection_query_duration = config_get_duration_seconds(config_section_ml, "anomaly detection grouping duration", 5 * 60);
44
+ double host_anomaly_rate_threshold = inicfg_get_double(&netdata_config, config_section_ml, "host anomaly rate threshold", 1.0);
45
+ std::string anomaly_detection_grouping_method = inicfg_get(&netdata_config, config_section_ml, "anomaly detection grouping method", "average");
46
+ time_t anomaly_detection_query_duration = inicfg_get_duration_seconds(&netdata_config, config_section_ml, "anomaly detection grouping duration", 5 * 60);
47
48
size_t num_worker_threads = netdata_conf_is_parent() ? netdata_conf_cpus() / 4 : 1;
49
if (num_worker_threads < 1) num_worker_threads = 1;
50
else if (num_worker_threads > 256) num_worker_threads = 256;
51
- num_worker_threads = config_get_number(config_section_ml, "num training threads", num_worker_threads);
51
+ num_worker_threads = inicfg_get_number(&netdata_config, config_section_ml, "num training threads", num_worker_threads);
52
53
- size_t flush_models_batch_size = config_get_number(config_section_ml, "flush models batch size", 256);
53
+ size_t flush_models_batch_size = inicfg_get_number(&netdata_config, config_section_ml, "flush models batch size", 256);
54
55
size_t suppression_window =
56
- config_get_duration_seconds(config_section_ml, "dimension anomaly rate suppression window", 900);
56
+ inicfg_get_duration_seconds(&netdata_config, config_section_ml, "dimension anomaly rate suppression window", 900);
57
58
size_t suppression_threshold =
59
- config_get_number(config_section_ml, "dimension anomaly rate suppression threshold", suppression_window / 2);
59
+ inicfg_get_number(&netdata_config, config_section_ml, "dimension anomaly rate suppression threshold", suppression_window / 2);
60
61
- bool enable_statistics_charts = config_get_boolean(config_section_ml, "enable statistics charts", true);
61
+ bool enable_statistics_charts = inicfg_get_boolean(&netdata_config, config_section_ml, "enable statistics charts", true);
62
63
/*
64
* Clamp
@@ -126,15 +126,15 @@ void ml_config_load(ml_config_t *cfg) {
126
cfg->anomaly_detection_query_duration = anomaly_detection_query_duration;
127
cfg->dimension_anomaly_score_threshold = dimension_anomaly_rate_threshold;
128
129
- cfg->hosts_to_skip = config_get(config_section_ml, "hosts to skip from training", "!*");
129
+ cfg->hosts_to_skip = inicfg_get(&netdata_config, config_section_ml, "hosts to skip from training", "!*");
130
cfg->sp_host_to_skip = simple_pattern_create(cfg->hosts_to_skip.c_str(), NULL, SIMPLE_PATTERN_EXACT, true);
131
132
// Always exclude anomaly_detection charts from training.
133
cfg->charts_to_skip = "anomaly_detection.* ";
134
- cfg->charts_to_skip += config_get(config_section_ml, "charts to skip from training", "netdata.*");
134
+ cfg->charts_to_skip += inicfg_get(&netdata_config, config_section_ml, "charts to skip from training", "netdata.*");
135
cfg->sp_charts_to_skip = simple_pattern_create(cfg->charts_to_skip.c_str(), NULL, SIMPLE_PATTERN_EXACT, true);
136
137
- cfg->stream_anomaly_detection_charts = config_get_boolean(config_section_ml, "stream anomaly detection charts", true);
137
+ cfg->stream_anomaly_detection_charts = inicfg_get_boolean(&netdata_config, config_section_ml, "stream anomaly detection charts", true);
138
139
cfg->num_worker_threads = num_worker_threads;
140
cfg->flush_models_batch_size = flush_models_batch_size;
@@ -146,7 +146,7 @@ void ml_config_load(ml_config_t *cfg) {
146
147
if (cfg->enable_anomaly_detection == CONFIG_BOOLEAN_AUTO && default_rrd_memory_mode != RRD_DB_MODE_DBENGINE) {
148
Cfg.enable_anomaly_detection = 0;
149
- config_set_boolean(config_section_ml, "enabled", CONFIG_BOOLEAN_NO);
149
+ inicfg_set_boolean(&netdata_config, config_section_ml, "enabled", CONFIG_BOOLEAN_NO);
150
return;
151
}
152
}
src/plugins.d/plugins_d.c
+8
-8
@@ -24,7 +24,7 @@ inline size_t pluginsd_initialize_plugin_directories()
24
// Get the configuration entry
25
if (likely(!plugins_dir_list)) {
26
snprintfz(plugins_dirs, FILENAME_MAX * 2, "\"%s\" \"%s/custom-plugins.d\"", PLUGINS_DIR, CONFIG_DIR);
27
- plugins_dir_list = strdupz(config_get(CONFIG_SECTION_DIRECTORIES, "plugins", plugins_dirs));
27
+ plugins_dir_list = strdupz(inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "plugins", plugins_dirs));
28
}
29
30
// Parse it and store it to plugin directories
@@ -261,18 +261,18 @@ static bool is_plugin(char *dst, size_t dst_size, const char *filename) {
261
void *pluginsd_main(void *ptr) {
262
CLEANUP_FUNCTION_REGISTER(pluginsd_main_cleanup) cleanup_ptr = ptr;
263
264
- int automatic_run = config_get_boolean(CONFIG_SECTION_PLUGINS, "enable running new plugins", 1);
265
- int scan_frequency = (int)config_get_duration_seconds(CONFIG_SECTION_PLUGINS, "check for new plugins every", 60);
264
+ int automatic_run = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGINS, "enable running new plugins", 1);
265
+ int scan_frequency = (int)inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_PLUGINS, "check for new plugins every", 60);
266
if (scan_frequency < 1)
267
scan_frequency = 1;
268
269
// disable some plugins by default
270
- config_get_boolean(CONFIG_SECTION_PLUGINS, "slabinfo", CONFIG_BOOLEAN_NO);
270
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGINS, "slabinfo", CONFIG_BOOLEAN_NO);
271
// it crashes (both threads) on Alpine after we made it multi-threaded
272
// works with "--device /dev/ipmi0", but this is not default
273
// see https://github.com/netdata/netdata/pull/15564 for details
274
if (getenv("NETDATA_LISTENER_PORT"))
275
- config_get_boolean(CONFIG_SECTION_PLUGINS, "freeipmi", CONFIG_BOOLEAN_NO);
275
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGINS, "freeipmi", CONFIG_BOOLEAN_NO);
276
277
// store the errno for each plugins directory
278
// so that we don't log broken directories on each loop
@@ -312,7 +312,7 @@ void *pluginsd_main(void *ptr) {
312
continue;
313
}
314
315
- int enabled = config_get_boolean(CONFIG_SECTION_PLUGINS, pluginname, automatic_run);
315
+ int enabled = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_PLUGINS, pluginname, automatic_run);
316
if (unlikely(!enabled)) {
317
netdata_log_debug(D_PLUGINSD, "plugin '%s' is not enabled", file->d_name);
318
continue;
@@ -356,7 +356,7 @@ void *pluginsd_main(void *ptr) {
356
cd->unsafe.enabled = enabled;
357
cd->unsafe.running = false;
358
359
- cd->update_every = (int)config_get_duration_seconds(string2str(cd->id), "update every", localhost->rrd_update_every);
359
+ cd->update_every = (int)inicfg_get_duration_seconds(&netdata_config, string2str(cd->id), "update every", localhost->rrd_update_every);
360
cd->started_t = now_realtime_sec();
361
362
{
@@ -365,7 +365,7 @@ void *pluginsd_main(void *ptr) {
365
366
snprintfz(
367
buf, sizeof(buf), "exec %s %d %s", string2str(cd->fullfilename),
368
- cd->update_every, config_get(string2str(cd->id), "command options", def));
368
+ cd->update_every, inicfg_get(&netdata_config, string2str(cd->id), "command options", def));
369
370
string_freez(cd->cmd);
371
cd->cmd = string_strdupz(buf);
src/plugins.d/pluginsd_parser.c
+1
-1
@@ -609,7 +609,7 @@ static inline PARSER_RC pluginsd_label(char **words, size_t num_words, PARSER *p
609
parser->user.new_host_labels = rrdlabels_create();
610
611
if (strcmp(name,HOST_LABEL_IS_EPHEMERAL) == 0) {
612
- int is_ephemeral = appconfig_test_boolean_value((char *) value);
612
+ int is_ephemeral = inicfg_test_boolean_value((char *) value);
613
RRDHOST *host = pluginsd_require_scope_host(parser, PLUGINSD_KEYWORD_LABEL);
614
if (host) {
615
if (is_ephemeral)
src/registry/registry_init.c
+18
-18
@@ -67,56 +67,56 @@ int registry_init(void) {
67
68
// registry enabled?
69
if(web_server_mode != WEB_SERVER_MODE_NONE) {
70
- registry.enabled = config_get_boolean(CONFIG_SECTION_REGISTRY, "enabled", 0);
70
+ registry.enabled = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_REGISTRY, "enabled", 0);
71
}
72
else {
73
netdata_log_info("Registry is disabled - use the central netdata");
74
- config_set_boolean(CONFIG_SECTION_REGISTRY, "enabled", 0);
74
+ inicfg_set_boolean(&netdata_config, CONFIG_SECTION_REGISTRY, "enabled", 0);
75
registry.enabled = 0;
76
}
77
78
// path names
79
snprintfz(filename, FILENAME_MAX, "%s/registry", netdata_configured_varlib_dir);
80
- registry.pathname = config_get(CONFIG_SECTION_DIRECTORIES, "registry", filename);
80
+ registry.pathname = inicfg_get(&netdata_config, CONFIG_SECTION_DIRECTORIES, "registry", filename);
81
if(mkdir(registry.pathname, 0770) == -1 && errno != EEXIST)
82
fatal("Cannot create directory '%s'.", registry.pathname);
83
84
// filenames
85
snprintfz(filename, FILENAME_MAX, "%s/netdata.public.unique.id", registry.pathname);
86
- registry.machine_guid_filename = config_get(CONFIG_SECTION_REGISTRY, "netdata unique id file", filename);
86
+ registry.machine_guid_filename = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "netdata unique id file", filename);
87
88
snprintfz(filename, FILENAME_MAX, "%s/registry.db", registry.pathname);
89
- registry.db_filename = config_get(CONFIG_SECTION_REGISTRY, "registry db file", filename);
89
+ registry.db_filename = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "registry db file", filename);
90
91
snprintfz(filename, FILENAME_MAX, "%s/registry-log.db", registry.pathname);
92
- registry.log_filename = config_get(CONFIG_SECTION_REGISTRY, "registry log file", filename);
92
+ registry.log_filename = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "registry log file", filename);
93
94
// configuration options
95
- registry.save_registry_every_entries = (unsigned long long)config_get_number(CONFIG_SECTION_REGISTRY, "registry save db every new entries", 1000000);
96
- registry.persons_expiration = config_get_duration_days(CONFIG_SECTION_REGISTRY, "registry expire idle persons", 365) * 86400;
97
- registry.registry_domain = config_get(CONFIG_SECTION_REGISTRY, "registry domain", "");
98
- registry.registry_to_announce = config_get(CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io");
99
- registry.hostname = config_get(CONFIG_SECTION_REGISTRY, "registry hostname", netdata_configured_hostname);
100
- registry.verify_cookies_redirects = config_get_boolean(CONFIG_SECTION_REGISTRY, "verify browser cookies support", 1);
101
- registry.enable_cookies_samesite_secure = config_get_boolean(CONFIG_SECTION_REGISTRY, "enable cookies SameSite and Secure", 1);
95
+ registry.save_registry_every_entries = (unsigned long long)inicfg_get_number(&netdata_config, CONFIG_SECTION_REGISTRY, "registry save db every new entries", 1000000);
96
+ registry.persons_expiration = inicfg_get_duration_days(&netdata_config, CONFIG_SECTION_REGISTRY, "registry expire idle persons", 365) * 86400;
97
+ registry.registry_domain = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "registry domain", "");
98
+ registry.registry_to_announce = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "registry to announce", "https://registry.my-netdata.io");
99
+ registry.hostname = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "registry hostname", netdata_configured_hostname);
100
+ registry.verify_cookies_redirects = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_REGISTRY, "verify browser cookies support", 1);
101
+ registry.enable_cookies_samesite_secure = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_REGISTRY, "enable cookies SameSite and Secure", 1);
102
103
registry_update_cloud_base_url();
104
nd_setenv("NETDATA_REGISTRY_HOSTNAME", registry.hostname, 1);
105
nd_setenv("NETDATA_REGISTRY_URL", registry.registry_to_announce, 1);
106
107
- registry.max_url_length = (size_t)config_get_number(CONFIG_SECTION_REGISTRY, "max URL length", 1024);
107
+ registry.max_url_length = (size_t)inicfg_get_number(&netdata_config, CONFIG_SECTION_REGISTRY, "max URL length", 1024);
108
if(registry.max_url_length < 10) {
109
registry.max_url_length = 10;
110
- config_set_number(CONFIG_SECTION_REGISTRY, "max URL length", (long long)registry.max_url_length);
110
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_REGISTRY, "max URL length", (long long)registry.max_url_length);
111
}
112
113
- registry.max_name_length = (size_t)config_get_number(CONFIG_SECTION_REGISTRY, "max URL name length", 50);
113
+ registry.max_name_length = (size_t)inicfg_get_number(&netdata_config, CONFIG_SECTION_REGISTRY, "max URL name length", 50);
114
if(registry.max_name_length < 10) {
115
registry.max_name_length = 10;
116
- config_set_number(CONFIG_SECTION_REGISTRY, "max URL name length", (long long)registry.max_name_length);
116
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_REGISTRY, "max URL name length", (long long)registry.max_name_length);
117
}
118
119
- bool use_mmap = config_get_boolean(CONFIG_SECTION_REGISTRY, "use mmap", false);
119
+ bool use_mmap = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_REGISTRY, "use mmap", false);
120
121
// initialize entries counters
122
registry.persons_count = 0;
src/streaming/stream-conf.c
+77
-77
@@ -66,42 +66,42 @@ void stream_conf_set_sender_compression_levels(ND_COMPRESSION_PROFILE profile) {
66
static void stream_conf_load_internal() {
67
errno_clear();
68
char *filename = filename_from_path_entry_strdupz(netdata_configured_user_config_dir, "stream.conf");
69
- if(!appconfig_load(&stream_config, filename, 0, NULL)) {
69
+ if(!inicfg_load(&stream_config, filename, 0, NULL)) {
70
nd_log_daemon(NDLP_NOTICE, "CONFIG: cannot load user config '%s'. Will try stock config.", filename);
71
freez(filename);
72
73
filename = filename_from_path_entry_strdupz(netdata_configured_stock_config_dir, "stream.conf");
74
- if(!appconfig_load(&stream_config, filename, 0, NULL))
74
+ if(!inicfg_load(&stream_config, filename, 0, NULL))
75
nd_log_daemon(NDLP_NOTICE, "CONFIG: cannot load stock config '%s'. Running with internal defaults.", filename);
76
}
77
78
freez(filename);
79
80
- appconfig_move(&stream_config,
80
+ inicfg_move(&stream_config,
81
CONFIG_SECTION_STREAM, "timeout seconds",
82
CONFIG_SECTION_STREAM, "timeout");
83
84
- appconfig_move(&stream_config,
84
+ inicfg_move(&stream_config,
85
CONFIG_SECTION_STREAM, "reconnect delay seconds",
86
CONFIG_SECTION_STREAM, "reconnect delay");
87
88
- appconfig_move_everywhere(&stream_config, "default memory mode", "db");
89
- appconfig_move_everywhere(&stream_config, "memory mode", "db");
90
- appconfig_move_everywhere(&stream_config, "db mode", "db");
91
- appconfig_move_everywhere(&stream_config, "default history", "retention");
92
- appconfig_move_everywhere(&stream_config, "history", "retention");
93
- appconfig_move_everywhere(&stream_config, "default proxy enabled", "proxy enabled");
94
- appconfig_move_everywhere(&stream_config, "default proxy destination", "proxy destination");
95
- appconfig_move_everywhere(&stream_config, "default proxy api key", "proxy api key");
96
- appconfig_move_everywhere(&stream_config, "default proxy send charts matching", "proxy send charts matching");
97
- appconfig_move_everywhere(&stream_config, "default health log history", "health log retention");
98
- appconfig_move_everywhere(&stream_config, "health log history", "health log retention");
99
- appconfig_move_everywhere(&stream_config, "seconds to replicate", "replication period");
100
- appconfig_move_everywhere(&stream_config, "seconds per replication step", "replication step");
101
- appconfig_move_everywhere(&stream_config, "default postpone alarms on connect seconds", "postpone alerts on connect");
102
- appconfig_move_everywhere(&stream_config, "postpone alarms on connect seconds", "postpone alerts on connect");
103
- appconfig_move_everywhere(&stream_config, "health enabled by default", "health enabled");
104
- appconfig_move_everywhere(&stream_config, "buffer size bytes", "buffer size");
88
+ inicfg_move_everywhere(&stream_config, "default memory mode", "db");
89
+ inicfg_move_everywhere(&stream_config, "memory mode", "db");
90
+ inicfg_move_everywhere(&stream_config, "db mode", "db");
91
+ inicfg_move_everywhere(&stream_config, "default history", "retention");
92
+ inicfg_move_everywhere(&stream_config, "history", "retention");
93
+ inicfg_move_everywhere(&stream_config, "default proxy enabled", "proxy enabled");
94
+ inicfg_move_everywhere(&stream_config, "default proxy destination", "proxy destination");
95
+ inicfg_move_everywhere(&stream_config, "default proxy api key", "proxy api key");
96
+ inicfg_move_everywhere(&stream_config, "default proxy send charts matching", "proxy send charts matching");
97
+ inicfg_move_everywhere(&stream_config, "default health log history", "health log retention");
98
+ inicfg_move_everywhere(&stream_config, "health log history", "health log retention");
99
+ inicfg_move_everywhere(&stream_config, "seconds to replicate", "replication period");
100
+ inicfg_move_everywhere(&stream_config, "seconds per replication step", "replication step");
101
+ inicfg_move_everywhere(&stream_config, "default postpone alarms on connect seconds", "postpone alerts on connect");
102
+ inicfg_move_everywhere(&stream_config, "postpone alarms on connect seconds", "postpone alerts on connect");
103
+ inicfg_move_everywhere(&stream_config, "health enabled by default", "health enabled");
104
+ inicfg_move_everywhere(&stream_config, "buffer size bytes", "buffer size");
105
}
106
107
bool stream_conf_receiver_needs_dbengine(void) {
@@ -117,88 +117,88 @@ void stream_conf_load() {
117
check_local_streaming_capabilities();
118
119
stream_send.enabled =
120
- appconfig_get_boolean(&stream_config, CONFIG_SECTION_STREAM, "enabled", stream_send.enabled);
120
+ inicfg_get_boolean(&stream_config, CONFIG_SECTION_STREAM, "enabled", stream_send.enabled);
121
122
stream_send.parents.destination =
123
- string_strdupz(appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "destination", ""));
123
+ string_strdupz(inicfg_get(&stream_config, CONFIG_SECTION_STREAM, "destination", ""));
124
125
stream_send.api_key =
126
- string_strdupz(appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "api key", ""));
126
+ string_strdupz(inicfg_get(&stream_config, CONFIG_SECTION_STREAM, "api key", ""));
127
128
stream_send.send_charts_matching =
129
- string_strdupz(appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "send charts matching", "*"));
129
+ string_strdupz(inicfg_get(&stream_config, CONFIG_SECTION_STREAM, "send charts matching", "*"));
130
131
stream_receive.replication.enabled =
132
- config_get_boolean(CONFIG_SECTION_DB, "enable replication",
132
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_DB, "enable replication",
133
stream_receive.replication.enabled);
134
135
stream_receive.replication.period =
136
- config_get_duration_seconds(CONFIG_SECTION_DB, "replication period",
136
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "replication period",
137
stream_receive.replication.period);
138
139
stream_receive.replication.step =
140
- config_get_duration_seconds(CONFIG_SECTION_DB, "replication step",
140
+ inicfg_get_duration_seconds(&netdata_config, CONFIG_SECTION_DB, "replication step",
141
stream_receive.replication.step);
142
143
- stream_send.buffer_max_size = (size_t)appconfig_get_size_bytes(
143
+ stream_send.buffer_max_size = (size_t)inicfg_get_size_bytes(
144
&stream_config, CONFIG_SECTION_STREAM, "buffer size",
145
stream_send.buffer_max_size);
146
147
- stream_send.parents.reconnect_delay_s = (unsigned int)appconfig_get_duration_seconds(
147
+ stream_send.parents.reconnect_delay_s = (unsigned int)inicfg_get_duration_seconds(
148
&stream_config, CONFIG_SECTION_STREAM, "reconnect delay",
149
stream_send.parents.reconnect_delay_s);
150
if(stream_send.parents.reconnect_delay_s < SENDER_MIN_RECONNECT_DELAY)
151
stream_send.parents.reconnect_delay_s = SENDER_MIN_RECONNECT_DELAY;
152
153
stream_send.compression.enabled =
154
- appconfig_get_boolean(&stream_config, CONFIG_SECTION_STREAM, "enable compression",
154
+ inicfg_get_boolean(&stream_config, CONFIG_SECTION_STREAM, "enable compression",
155
stream_send.compression.enabled);
156
157
- stream_send.compression.levels[COMPRESSION_ALGORITHM_BROTLI] = (int)appconfig_get_number(
157
+ stream_send.compression.levels[COMPRESSION_ALGORITHM_BROTLI] = (int)inicfg_get_number(
158
&stream_config, CONFIG_SECTION_STREAM, "brotli compression level",
159
stream_send.compression.levels[COMPRESSION_ALGORITHM_BROTLI]);
160
161
- stream_send.compression.levels[COMPRESSION_ALGORITHM_ZSTD] = (int)appconfig_get_number(
161
+ stream_send.compression.levels[COMPRESSION_ALGORITHM_ZSTD] = (int)inicfg_get_number(
162
&stream_config, CONFIG_SECTION_STREAM, "zstd compression level",
163
stream_send.compression.levels[COMPRESSION_ALGORITHM_ZSTD]);
164
165
- stream_send.compression.levels[COMPRESSION_ALGORITHM_LZ4] = (int)appconfig_get_number(
165
+ stream_send.compression.levels[COMPRESSION_ALGORITHM_LZ4] = (int)inicfg_get_number(
166
&stream_config, CONFIG_SECTION_STREAM, "lz4 compression acceleration",
167
stream_send.compression.levels[COMPRESSION_ALGORITHM_LZ4]);
168
169
- stream_send.compression.levels[COMPRESSION_ALGORITHM_GZIP] = (int)appconfig_get_number(
169
+ stream_send.compression.levels[COMPRESSION_ALGORITHM_GZIP] = (int)inicfg_get_number(
170
&stream_config, CONFIG_SECTION_STREAM, "gzip compression level",
171
stream_send.compression.levels[COMPRESSION_ALGORITHM_GZIP]);
172
173
- stream_send.parents.h2o = appconfig_get_boolean(
173
+ stream_send.parents.h2o = inicfg_get_boolean(
174
&stream_config, CONFIG_SECTION_STREAM, "parent using h2o",
175
stream_send.parents.h2o);
176
177
- stream_send.parents.timeout_s = (int)appconfig_get_duration_seconds(
177
+ stream_send.parents.timeout_s = (int)inicfg_get_duration_seconds(
178
&stream_config, CONFIG_SECTION_STREAM, "timeout",
179
stream_send.parents.timeout_s);
180
181
- stream_send.buffer_max_size = (size_t)appconfig_get_number(
181
+ stream_send.buffer_max_size = (size_t)inicfg_get_number(
182
&stream_config, CONFIG_SECTION_STREAM, "buffer size bytes",
183
stream_send.buffer_max_size);
184
185
- stream_send.parents.default_port = (int)appconfig_get_number(
185
+ stream_send.parents.default_port = (int)inicfg_get_number(
186
&stream_config, CONFIG_SECTION_STREAM, "default port",
187
stream_send.parents.default_port);
188
189
- stream_send.initial_clock_resync_iterations = (unsigned int)appconfig_get_number(
189
+ stream_send.initial_clock_resync_iterations = (unsigned int)inicfg_get_number(
190
&stream_config, CONFIG_SECTION_STREAM, "initial clock resync iterations",
191
stream_send.initial_clock_resync_iterations); // TODO: REMOVE FOR SLEW / GAPFILLING
192
193
- netdata_ssl_validate_certificate_sender = !appconfig_get_boolean(
193
+ netdata_ssl_validate_certificate_sender = !inicfg_get_boolean(
194
&stream_config, CONFIG_SECTION_STREAM, "ssl skip certificate verification",
195
!netdata_ssl_validate_certificate);
196
197
if(!netdata_ssl_validate_certificate_sender)
198
nd_log_daemon(NDLP_NOTICE, "SSL: streaming senders will skip SSL certificates verification.");
199
200
- stream_send.parents.ssl_ca_path = string_strdupz(appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "CApath", NULL));
201
- stream_send.parents.ssl_ca_file = string_strdupz(appconfig_get(&stream_config, CONFIG_SECTION_STREAM, "CAfile", NULL));
200
+ stream_send.parents.ssl_ca_path = string_strdupz(inicfg_get(&stream_config, CONFIG_SECTION_STREAM, "CApath", NULL));
201
+ stream_send.parents.ssl_ca_file = string_strdupz(inicfg_get(&stream_config, CONFIG_SECTION_STREAM, "CAfile", NULL));
202
203
if(stream_send.enabled && (!stream_send.parents.destination || !stream_send.api_key)) {
204
nd_log_daemon(
@@ -229,8 +229,8 @@ bool stream_conf_is_child(void) {
229
230
void stream_conf_receiver_config(struct receiver_state *rpt, struct stream_receiver_config *config, const char *api_key, const char *machine_guid) {
231
config->mode = rrd_memory_mode_id(
232
- appconfig_get(&stream_config, machine_guid, "db",
233
- appconfig_get(&stream_config, api_key, "db",
232
+ inicfg_get(&stream_config, machine_guid, "db",
233
+ inicfg_get(&stream_config, api_key, "db",
234
rrd_memory_mode_name(default_rrd_memory_mode))));
235
236
if (unlikely(config->mode == RRD_DB_MODE_DBENGINE && !dbengine_enabled)) {
@@ -242,96 +242,96 @@ void stream_conf_receiver_config(struct receiver_state *rpt, struct stream_recei
242
}
243
244
config->history = (int)
245
- appconfig_get_number(&stream_config, machine_guid, "retention",
246
- appconfig_get_number(&stream_config, api_key, "retention",
245
+ inicfg_get_number(&stream_config, machine_guid, "retention",
246
+ inicfg_get_number(&stream_config, api_key, "retention",
247
default_rrd_history_entries));
248
if(config->history < 5) config->history = 5;
249
250
config->health.enabled =
251
- appconfig_get_boolean_ondemand(&stream_config, machine_guid, "health enabled",
252
- appconfig_get_boolean_ondemand(&stream_config, api_key, "health enabled",
251
+ inicfg_get_boolean_ondemand(&stream_config, machine_guid, "health enabled",
252
+ inicfg_get_boolean_ondemand(&stream_config, api_key, "health enabled",
253
health_plugin_enabled()));
254
255
config->health.delay =
256
- appconfig_get_duration_seconds(&stream_config, machine_guid, "postpone alerts on connect",
257
- appconfig_get_duration_seconds(&stream_config, api_key, "postpone alerts on connect",
256
+ inicfg_get_duration_seconds(&stream_config, machine_guid, "postpone alerts on connect",
257
+ inicfg_get_duration_seconds(&stream_config, api_key, "postpone alerts on connect",
258
60));
259
260
- config->update_every = (int)appconfig_get_duration_seconds(&stream_config, machine_guid, "update every", config->update_every);
260
+ config->update_every = (int)inicfg_get_duration_seconds(&stream_config, machine_guid, "update every", config->update_every);
261
if(config->update_every < 0) config->update_every = 1;
262
263
config->health.history =
264
- appconfig_get_duration_seconds(&stream_config, machine_guid, "health log retention",
265
- appconfig_get_duration_seconds(&stream_config, api_key, "health log retention",
264
+ inicfg_get_duration_seconds(&stream_config, machine_guid, "health log retention",
265
+ inicfg_get_duration_seconds(&stream_config, api_key, "health log retention",
266
HEALTH_LOG_RETENTION_DEFAULT));
267
268
config->send.enabled =
269
- appconfig_get_boolean(&stream_config, machine_guid, "proxy enabled",
270
- appconfig_get_boolean(&stream_config, api_key, "proxy enabled",
269
+ inicfg_get_boolean(&stream_config, machine_guid, "proxy enabled",
270
+ inicfg_get_boolean(&stream_config, api_key, "proxy enabled",
271
stream_send.enabled));
272
273
config->send.parents = string_strdupz(
274
- appconfig_get(&stream_config, machine_guid, "proxy destination",
275
- appconfig_get(&stream_config, api_key, "proxy destination",
274
+ inicfg_get(&stream_config, machine_guid, "proxy destination",
275
+ inicfg_get(&stream_config, api_key, "proxy destination",
276
string2str(stream_send.parents.destination))));
277
278
config->send.api_key = string_strdupz(
279
- appconfig_get(&stream_config, machine_guid, "proxy api key",
280
- appconfig_get(&stream_config, api_key, "proxy api key",
279
+ inicfg_get(&stream_config, machine_guid, "proxy api key",
280
+ inicfg_get(&stream_config, api_key, "proxy api key",
281
string2str(stream_send.api_key))));
282
283
config->send.charts_matching = string_strdupz(
284
- appconfig_get(&stream_config, machine_guid, "proxy send charts matching",
285
- appconfig_get(&stream_config, api_key, "proxy send charts matching",
284
+ inicfg_get(&stream_config, machine_guid, "proxy send charts matching",
285
+ inicfg_get(&stream_config, api_key, "proxy send charts matching",
286
string2str(stream_send.send_charts_matching))));
287
288
config->replication.enabled =
289
- appconfig_get_boolean(&stream_config, machine_guid, "enable replication",
290
- appconfig_get_boolean(&stream_config, api_key, "enable replication",
289
+ inicfg_get_boolean(&stream_config, machine_guid, "enable replication",
290
+ inicfg_get_boolean(&stream_config, api_key, "enable replication",
291
stream_receive.replication.enabled));
292
293
config->replication.period =
294
- appconfig_get_duration_seconds(&stream_config, machine_guid, "replication period",
295
- appconfig_get_duration_seconds(&stream_config, api_key, "replication period",
294
+ inicfg_get_duration_seconds(&stream_config, machine_guid, "replication period",
295
+ inicfg_get_duration_seconds(&stream_config, api_key, "replication period",
296
stream_receive.replication.period));
297
298
config->replication.step =
299
- appconfig_get_number(&stream_config, machine_guid, "replication step",
300
- appconfig_get_number(&stream_config, api_key, "replication step",
299
+ inicfg_get_number(&stream_config, machine_guid, "replication step",
300
+ inicfg_get_number(&stream_config, api_key, "replication step",
301
stream_receive.replication.step));
302
303
config->compression.enabled =
304
- appconfig_get_boolean(&stream_config, machine_guid, "enable compression",
305
- appconfig_get_boolean(&stream_config, api_key, "enable compression",
304
+ inicfg_get_boolean(&stream_config, machine_guid, "enable compression",
305
+ inicfg_get_boolean(&stream_config, api_key, "enable compression",
306
stream_send.compression.enabled));
307
308
if(config->compression.enabled) {
309
stream_parse_compression_order(
310
config,
311
- appconfig_get(
311
+ inicfg_get(
312
&stream_config, machine_guid, "compression algorithms order",
313
- appconfig_get(&stream_config, api_key, "compression algorithms order", STREAM_COMPRESSION_ALGORITHMS_ORDER)));
313
+ inicfg_get(&stream_config, api_key, "compression algorithms order", STREAM_COMPRESSION_ALGORITHMS_ORDER)));
314
}
315
316
config->ephemeral =
317
- appconfig_get_boolean(&stream_config, machine_guid, "is ephemeral node",
318
- appconfig_get_boolean(&stream_config, api_key, "is ephemeral node",
317
+ inicfg_get_boolean(&stream_config, machine_guid, "is ephemeral node",
318
+ inicfg_get_boolean(&stream_config, api_key, "is ephemeral node",
319
CONFIG_BOOLEAN_NO));
320
}
321
322
bool stream_conf_is_key_type(const char *api_key, const char *type) {
323
- const char *api_key_type = appconfig_get(&stream_config, api_key, "type", type);
323
+ const char *api_key_type = inicfg_get(&stream_config, api_key, "type", type);
324
if(!api_key_type || !*api_key_type) api_key_type = "unknown";
325
return strcmp(api_key_type, type) == 0;
326
}
327
328
bool stream_conf_api_key_is_enabled(const char *api_key, bool enabled) {
329
- return appconfig_get_boolean(&stream_config, api_key, "enabled", enabled);
329
+ return inicfg_get_boolean(&stream_config, api_key, "enabled", enabled);
330
}
331
332
bool stream_conf_api_key_allows_client(const char *api_key, const char *client_ip) {
333
SIMPLE_PATTERN *key_allow_from = simple_pattern_create(
334
- appconfig_get(&stream_config, api_key, "allow from", "*"),
334
+ inicfg_get(&stream_config, api_key, "allow from", "*"),
335
NULL, SIMPLE_PATTERN_EXACT, true);
336
337
bool rc = true;
src/streaming/stream-replication-sender.c
+3
-3
@@ -1736,16 +1736,16 @@ void *replication_thread_main(void *ptr) {
1736
if (threads < 1) threads = 1;
1737
else if (threads > MAX_REPLICATION_THREADS) threads = MAX_REPLICATION_THREADS;
1738
1739
- threads = config_get_number(CONFIG_SECTION_DB, "replication threads", threads);
1739
+ threads = inicfg_get_number(&netdata_config, CONFIG_SECTION_DB, "replication threads", threads);
1740
if(threads < 1) {
1741
netdata_log_error("replication threads given %zu is invalid, resetting to 1", threads);
1742
threads = 1;
1743
- config_set_number(CONFIG_SECTION_DB, "replication threads", threads);
1743
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "replication threads", threads);
1744
}
1745
else if(threads > MAX_REPLICATION_THREADS) {
1746
netdata_log_error("replication threads given %zu is invalid, resetting to %d", threads, (int)MAX_REPLICATION_THREADS);
1747
threads = MAX_REPLICATION_THREADS;
1748
- config_set_number(CONFIG_SECTION_DB, "replication threads", threads);
1748
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_DB, "replication threads", threads);
1749
}
1750
1751
if(--threads) {
src/web/api/formatters/charts2json.c
+1
-1
@@ -44,7 +44,7 @@ void charts2json(RRDHOST *host, BUFFER *wb) {
44
time_t now = now_realtime_sec();
45
46
if(unlikely(!custom_dashboard_info_js_filename))
47
- custom_dashboard_info_js_filename = config_get(CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
47
+ custom_dashboard_info_js_filename = inicfg_get(&netdata_config, CONFIG_SECTION_WEB, "custom dashboard_info.js", "");
48
49
buffer_json_initialize(wb, "\"", "\"", 0, true, BUFFER_JSON_OPTIONS_DEFAULT);
50
src/web/api/http_auth.c
+1
-1
@@ -330,7 +330,7 @@ bool web_client_bearer_token_auth(struct web_client *w, const char *v) {
330
331
void bearer_tokens_init(void) {
332
netdata_is_protected_by_bearer =
333
- config_get_boolean(CONFIG_SECTION_WEB, "bearer token protection", netdata_is_protected_by_bearer);
333
+ inicfg_get_boolean(&netdata_config, CONFIG_SECTION_WEB, "bearer token protection", netdata_is_protected_by_bearer);
334
335
netdata_authorized_bearers = dictionary_create_advanced(
336
DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_FIXED_SIZE,
src/web/api/queries/des/des.h
+2
-2
@@ -21,9 +21,9 @@ struct tg_des {
21
static size_t tg_des_max_window_size = 15;
22
23
static inline void tg_des_init(void) {
24
- long long ret = config_get_number(CONFIG_SECTION_WEB, "des max tg_des_window", (long long)tg_des_max_window_size);
24
+ long long ret = inicfg_get_number(&netdata_config, CONFIG_SECTION_WEB, "des max tg_des_window", (long long)tg_des_max_window_size);
25
if(ret <= 1) {
26
- config_set_number(CONFIG_SECTION_WEB, "des max tg_des_window", (long long)tg_des_max_window_size);
26
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_WEB, "des max tg_des_window", (long long)tg_des_max_window_size);
27
}
28
else {
29
tg_des_max_window_size = (size_t) ret;
src/web/api/queries/ses/ses.h
+2
-2
@@ -16,9 +16,9 @@ struct tg_ses {
16
static size_t tg_ses_max_window_size = 15;
17
18
static inline void tg_ses_init(void) {
19
- long long ret = config_get_number(CONFIG_SECTION_WEB, "ses max tg_des_window", (long long)tg_ses_max_window_size);
19
+ long long ret = inicfg_get_number(&netdata_config, CONFIG_SECTION_WEB, "ses max tg_des_window", (long long)tg_ses_max_window_size);
20
if(ret <= 1) {
21
- config_set_number(CONFIG_SECTION_WEB, "ses max tg_des_window", (long long)tg_ses_max_window_size);
21
+ inicfg_set_number(&netdata_config, CONFIG_SECTION_WEB, "ses max tg_des_window", (long long)tg_ses_max_window_size);
22
}
23
else {
24
tg_ses_max_window_size = (size_t) ret;
src/web/api/tests/valid_urls.c
+2
-2
@@ -72,7 +72,7 @@ void __wrap_finished_web_request_statistics(
72
(void)compressed_content_size;
73
}
74
75
-char *__wrap_config_get(struct config *root, const char *section, const char *name, const char *default_value)
75
+char *__wrap_inicfg_get(&netdata_config, struct config *root, const char *section, const char *name, const char *default_value)
76
{
77
(void)root;
78
(void)section;
@@ -196,7 +196,7 @@ RRDHOST *localhost = NULL;
196
struct config netdata_config = { .first_section = NULL,
197
.last_section = NULL,
198
.mutex = NETDATA_MUTEX_INITIALIZER,
199
- .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare },
199
+ .index = { .avl_tree = { .root = NULL, .compar = inicfg_section_compare },
200
.rwlock = AVL_LOCK_INITIALIZER } };
201
202
/* Note: this is not a CMocka group_test_setup/teardown pair. This is performed per-test.
src/web/api/tests/web_api.c
+2
-2
@@ -72,7 +72,7 @@ void __wrap_finished_web_request_statistics(
72
(void)compressed_content_size;
73
}
74
75
-char *__wrap_config_get(struct config *root, const char *section, const char *name, const char *default_value)
75
+char *__wrap_inicfg_get(&netdata_config, struct config *root, const char *section, const char *name, const char *default_value)
76
{
77
(void)root;
78
(void)section;
@@ -198,7 +198,7 @@ RRDHOST *localhost = NULL;
198
struct config netdata_config = { .first_section = NULL,
199
.last_section = NULL,
200
.mutex = NETDATA_MUTEX_INITIALIZER,
201
- .index = { .avl_tree = { .root = NULL, .compar = appconfig_section_compare },
201
+ .index = { .avl_tree = { .root = NULL, .compar = inicfg_section_compare },
202
.rwlock = AVL_LOCK_INITIALIZER } };
203
204
const char *http_headers[] = { "Host: 254.254.0.1",
src/web/api/v1/api_v1_manage.c
+1
-1
@@ -7,7 +7,7 @@ char *api_secret;
7
static char *get_mgmt_api_key(void) {
8
char filename[FILENAME_MAX + 1];
9
snprintfz(filename, FILENAME_MAX, "%s/netdata.api.key", netdata_configured_varlib_dir);
10
- const char *api_key_filename = config_get(CONFIG_SECTION_REGISTRY, "netdata management api key file", filename);
10
+ const char *api_key_filename = inicfg_get(&netdata_config, CONFIG_SECTION_REGISTRY, "netdata management api key file", filename);
11
static char guid[GUID_LEN + 1] = "";
12
13
if(likely(guid[0]))
src/web/rtc/webrtc.c
+4
-4
@@ -142,7 +142,7 @@ static void webrtc_config_ice_servers(void) {
142
webrtc_base.iceServersCount = i;
143
internal_error(true, "WEBRTC: there are %d default ice servers: '%s'", webrtc_base.iceServersCount, buffer_tostring(wb));
144
145
- const char *servers = config_get(CONFIG_SECTION_WEBRTC, "ice servers", buffer_tostring(wb));
145
+ const char *servers = inicfg_get(&netdata_config, CONFIG_SECTION_WEBRTC, "ice servers", buffer_tostring(wb));
146
147
webrtc_base.iceServersCount = 0;
148
char tmp[strlen(servers) + 1];
@@ -174,18 +174,18 @@ static void webrtc_config_ice_servers(void) {
174
}
175
176
void webrtc_initialize() {
177
- webrtc_base.enabled = config_get_boolean(CONFIG_SECTION_WEBRTC, "enabled", webrtc_base.enabled);
177
+ webrtc_base.enabled = inicfg_get_boolean(&netdata_config, CONFIG_SECTION_WEBRTC, "enabled", webrtc_base.enabled);
178
internal_error(true, "WEBRTC: is %s", webrtc_base.enabled ? "enabled" : "disabled");
179
180
webrtc_config_ice_servers();
181
182
- webrtc_base.proxyServer = config_get(CONFIG_SECTION_WEBRTC, "proxy server", webrtc_base.proxyServer ? webrtc_base.proxyServer : "");
182
+ webrtc_base.proxyServer = inicfg_get(&netdata_config, CONFIG_SECTION_WEBRTC, "proxy server", webrtc_base.proxyServer ? webrtc_base.proxyServer : "");
183
if(!webrtc_base.proxyServer || !*webrtc_base.proxyServer)
184
webrtc_base.proxyServer = NULL;
185
186
internal_error(true, "WEBRTC: proxy server is: '%s'", webrtc_base.proxyServer ? webrtc_base.proxyServer : "");
187
188
- webrtc_base.bindAddress = config_get(CONFIG_SECTION_WEBRTC, "bind address", webrtc_base.bindAddress ? webrtc_base.bindAddress : "");
188
+ webrtc_base.bindAddress = inicfg_get(&netdata_config, CONFIG_SECTION_WEBRTC, "bind address", webrtc_base.bindAddress ? webrtc_base.bindAddress : "");
189
if(!webrtc_base.bindAddress || !*webrtc_base.bindAddress)
190
webrtc_base.bindAddress = NULL;
191
src/web/server/h2o/http_server.c
+7
-7
@@ -70,16 +70,16 @@ static int create_listener(const char *ip, int port)
70
71
static int ssl_init()
72
{
73
- if (!config_get_boolean(HTTPD_CONFIG_SECTION, "ssl", false))
73
+ if (!inicfg_get_boolean(&netdata_config, HTTPD_CONFIG_SECTION, "ssl", false))
74
return 0;
75
76
char default_fn[FILENAME_MAX + 1];
77
78
snprintfz(default_fn, FILENAME_MAX, "%s/ssl/key.pem", netdata_configured_user_config_dir);
79
- const char *key_fn = config_get(HTTPD_CONFIG_SECTION, "ssl key", default_fn);
79
+ const char *key_fn = inicfg_get(&netdata_config, HTTPD_CONFIG_SECTION, "ssl key", default_fn);
80
81
snprintfz(default_fn, FILENAME_MAX, "%s/ssl/cert.pem", netdata_configured_user_config_dir);
82
- const char *cert_fn = config_get(HTTPD_CONFIG_SECTION, "ssl certificate", default_fn);
82
+ const char *cert_fn = inicfg_get(&netdata_config, HTTPD_CONFIG_SECTION, "ssl certificate", default_fn);
83
84
#if OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_110
85
accept_ctx.ssl_ctx = SSL_CTX_new(SSLv23_server_method());
@@ -321,7 +321,7 @@ static int hdl_netdata_conf(h2o_handler_t *self, h2o_req_t *req)
321
return -1;
322
323
BUFFER *buf = buffer_create(NBUF_INITIAL_SIZE_RESP, NULL);
324
- netdata_conf_generate(buf, 0);
324
+ inicfg_generate(&netdata_config, buf, 0, true);
325
326
void *managed = h2o_mem_alloc_shared(&req->pool, buf->len, NULL);
327
memcpy(managed, buf->buffer, buf->len);
@@ -370,8 +370,8 @@ void *h2o_main(void *ptr) {
370
h2o_pathconf_t *pathconf;
371
h2o_hostconf_t *hostconf;
372
373
- const char *bind_addr = config_get(HTTPD_CONFIG_SECTION, "bind to", "127.0.0.1");
374
- int bind_port = config_get_number(HTTPD_CONFIG_SECTION, "port", 19998);
373
+ const char *bind_addr = inicfg_get(&netdata_config, HTTPD_CONFIG_SECTION, "bind to", "127.0.0.1");
374
+ int bind_port = inicfg_get_number(&netdata_config, HTTPD_CONFIG_SECTION, "port", 19998);
375
376
h2o_config_init(&config);
377
hostconf = h2o_config_register_host(&config, h2o_iovec_init(H2O_STRLIT("default")), bind_port);
@@ -424,5 +424,5 @@ void *h2o_main(void *ptr) {
424
}
425
426
bool httpd_is_enabled() {
427
- return config_get_boolean(HTTPD_CONFIG_SECTION, "enabled", HTTPD_ENABLED_DEFAULT);
427
+ return inicfg_get_boolean(&netdata_config, HTTPD_CONFIG_SECTION, "enabled", HTTPD_ENABLED_DEFAULT);
428
}
src/web/server/static/static-threaded.c
+2
-2
@@ -361,7 +361,7 @@ void *socket_listen_main_static_threaded(void *ptr) {
361
if(!api_sockets.opened)
362
fatal("LISTENER: no listen sockets available.");
363
364
- netdata_ssl_validate_certificate = !config_get_boolean(CONFIG_SECTION_WEB, "ssl skip certificate verification", !netdata_ssl_validate_certificate);
364
+ netdata_ssl_validate_certificate = !inicfg_get_boolean(&netdata_config, CONFIG_SECTION_WEB, "ssl skip certificate verification", !netdata_ssl_validate_certificate);
365
366
if(!netdata_ssl_validate_certificate_sender)
367
netdata_log_info("SSL: web server will skip SSL certificates verification.");
@@ -370,7 +370,7 @@ void *socket_listen_main_static_threaded(void *ptr) {
370
371
static_threaded_workers_count = netdata_conf_web_query_threads();
372
373
- size_t max_sockets = (size_t)config_get_number(CONFIG_SECTION_WEB, "web server max sockets",
373
+ size_t max_sockets = (size_t)inicfg_get_number(&netdata_config, CONFIG_SECTION_WEB, "web server max sockets",
374
(long long int)(rlimit_nofile.rlim_cur / 4));
375
376
static_workers_private_data = callocz((size_t)static_threaded_workers_count,
src/web/server/web_client.c
+2
-1
@@ -1173,7 +1173,8 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
1173
netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: generating netdata.conf ...", w->id);
1174
w->response.data->content_type = CT_TEXT_PLAIN;
1175
buffer_flush(w->response.data);
1176
- netdata_conf_generate(w->response.data, 0);
1176
+
1177
+ inicfg_generate(&netdata_config, w->response.data, 0, true);
1178
return HTTP_RESP_OK;
1179
}
1180
#ifdef NETDATA_INTERNAL_CHECKS