diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2024-06-20 18:27:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 18:27:29 +0300 |
commit | 4b01a5a836a620d8fdc72f4ce909666bc6799260 (patch) | |
tree | 30121aad310d31b0b377803e7c7ffa7d94cf63cd /src | |
parent | 55b2fe8dc8d956f8a793d00abdc5c28b27ff3642 (diff) |
cgroups: bring back "use unified cgroups" option (#17969)
Diffstat (limited to 'src')
-rw-r--r-- | src/collectors/cgroups.plugin/cgroup-internals.h | 2 | ||||
-rw-r--r-- | src/collectors/cgroups.plugin/sys_fs_cgroup.c | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/collectors/cgroups.plugin/cgroup-internals.h b/src/collectors/cgroups.plugin/cgroup-internals.h index d026b7a9ba..e0d53dc93e 100644 --- a/src/collectors/cgroups.plugin/cgroup-internals.h +++ b/src/collectors/cgroups.plugin/cgroup-internals.h @@ -283,7 +283,7 @@ void cgroup_discovery_worker(void *ptr); extern bool is_inside_k8s; extern long system_page_size; -extern bool cgroup_use_unified_cgroups; +extern int cgroup_use_unified_cgroups; extern bool cgroup_unified_exist; extern bool cgroup_enable_cpuacct; diff --git a/src/collectors/cgroups.plugin/sys_fs_cgroup.c b/src/collectors/cgroups.plugin/sys_fs_cgroup.c index 8148489653..592152401b 100644 --- a/src/collectors/cgroups.plugin/sys_fs_cgroup.c +++ b/src/collectors/cgroups.plugin/sys_fs_cgroup.c @@ -13,7 +13,7 @@ unsigned long long host_ram_total = 0; bool is_inside_k8s = false; long system_page_size = 4096; // system will be queried via sysconf() in configuration() -bool cgroup_use_unified_cgroups = false; +int cgroup_use_unified_cgroups = CONFIG_BOOLEAN_AUTO; bool cgroup_unified_exist = true; bool cgroup_enable_blkio = true; @@ -170,6 +170,9 @@ static enum cgroups_type cgroups_try_detect_version() if ((systemd_setting = cgroups_detect_systemd("systemd --version")) == SYSTEMD_CGROUP_ERR) systemd_setting = cgroups_detect_systemd(SYSTEMD_CMD_RHEL); + if(systemd_setting == SYSTEMD_CGROUP_ERR) + return CGROUPS_AUTODETECT_FAIL; + if(systemd_setting == SYSTEMD_CGROUP_LEGACY || systemd_setting == SYSTEMD_CGROUP_HYBRID) { // currently we prefer V1 if HYBRID is set as it seems to be more feature complete // in the future we might want to continue here if SYSTEMD_CGROUP_HYBRID @@ -230,7 +233,9 @@ void read_cgroup_plugin_configuration() { if(cgroup_check_for_new_every < cgroup_update_every) cgroup_check_for_new_every = cgroup_update_every; - cgroup_use_unified_cgroups = (cgroups_try_detect_version() == CGROUPS_V2); + cgroup_use_unified_cgroups = config_get_boolean_ondemand("plugin:cgroups", "use unified cgroups", CONFIG_BOOLEAN_AUTO); + if (cgroup_use_unified_cgroups == CONFIG_BOOLEAN_AUTO) + cgroup_use_unified_cgroups = (cgroups_try_detect_version() == CGROUPS_V2); collector_info("use unified cgroups %s", cgroup_use_unified_cgroups ? "true" : "false"); char filename[FILENAME_MAX + 1], *s; |