1
0
mirror of https://github.com/netdata/netdata.git synced 2021-06-06 23:03:21 +03:00

Check the version of the default cgroup mountpoint (#11102)

This commit is contained in:
Vladimir Kobal
2021-05-06 17:02:02 +03:00
committed by GitHub
parent d9dd28f85b
commit b1ce4fa3b6
3 changed files with 20 additions and 2 deletions

View File

@@ -160,7 +160,20 @@ static enum cgroups_type cgroups_try_detect_version()
if(!cgroups2_available)
return CGROUPS_V1;
// 2. check systemd compiletime setting
#if defined CGROUP2_SUPER_MAGIC
// 2. check filesystem type for the default mountpoint
char filename[FILENAME_MAX + 1];
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/sys/fs/cgroup");
struct statfs fsinfo;
if (!statfs(filename, &fsinfo)) {
if (fsinfo.f_type == CGROUP2_SUPER_MAGIC)
return CGROUPS_V2;
if (fsinfo.f_type == CGROUP_SUPER_MAGIC)
return CGROUPS_V1;
}
#endif
// 3. check systemd compiletime setting
if ((systemd_setting = cgroups_detect_systemd("systemd --version")) == SYSTEMD_CGROUP_ERR)
systemd_setting = cgroups_detect_systemd(SYSTEMD_CMD_RHEL);
@@ -174,7 +187,7 @@ static enum cgroups_type cgroups_try_detect_version()
return CGROUPS_V1;
}
// 3. if we are unified as on Fedora (default cgroups2 only mode)
// 4. if we are unified as on Fedora (default cgroups2 only mode)
// check kernel command line flag that can override that setting
f = fopen("/proc/cmdline", "r");
if (!f) {

View File

@@ -249,6 +249,7 @@ AC_HEADER_RESOLV
AC_CHECK_HEADERS_ONCE([sys/prctl.h])
AC_CHECK_HEADERS_ONCE([sys/vfs.h])
AC_CHECK_HEADERS_ONCE([sys/statfs.h])
AC_CHECK_HEADERS_ONCE([linux/magic.h])
AC_CHECK_HEADERS_ONCE([sys/statvfs.h])
AC_CHECK_HEADERS_ONCE([sys/mount.h])

View File

@@ -118,6 +118,10 @@ extern "C" {
#include <sys/statfs.h>
#endif
#ifdef HAVE_LINUX_MAGIC_H
#include <linux/magic.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif