summaryrefslogtreecommitdiffstats
path: root/collectors/cgroups.plugin/sys_fs_cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/cgroups.plugin/sys_fs_cgroup.c')
-rw-r--r--collectors/cgroups.plugin/sys_fs_cgroup.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c
index ceffffe92..eea4d9ae7 100644
--- a/collectors/cgroups.plugin/sys_fs_cgroup.c
+++ b/collectors/cgroups.plugin/sys_fs_cgroup.c
@@ -142,7 +142,7 @@ static enum cgroups_type cgroups_try_detect_version()
enum cgroups_systemd_setting systemd_setting;
int cgroups2_available = 0;
- // 1. check if cgroups2 availible on system at all
+ // 1. check if cgroups2 available on system at all
FILE *f = mypopen("grep cgroup /proc/filesystems", &command_pid);
if (!f) {
error("popen failed");
@@ -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);
@@ -168,13 +181,13 @@ static enum cgroups_type cgroups_try_detect_version()
return CGROUPS_AUTODETECT_FAIL;
if(systemd_setting == SYSTEMD_CGROUP_LEGACY || systemd_setting == SYSTEMD_CGROUP_HYBRID) {
- // curently we prefer V1 if HYBRID is set as it seems to be more feature complete
+ // 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
// and go ahead with V2
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) {
@@ -1300,6 +1313,12 @@ static inline char *cgroup_chart_id_strdupz(const char *s) {
char *r = strdupz(s);
netdata_fix_chart_id(r);
+ // dots are used to distinguish chart type and id in streaming, so we should replace them
+ for (char *d = r; *d; d++) {
+ if (*d == '.')
+ *d = '-';
+ }
+
return r;
}
@@ -1469,7 +1488,7 @@ static inline struct cgroup *cgroup_add(const char *id) {
}
if(user_configurable) {
- // allow the user to enable/disable this individualy
+ // allow the user to enable/disable this individually
char option[FILENAME_MAX + 1];
snprintfz(option, FILENAME_MAX, "enable cgroup %s", cg->chart_title);
cg->enabled = (char) config_get_boolean("plugin:cgroups", option, def);
@@ -3996,9 +4015,10 @@ static void cgroup_main_cleanup(void *ptr) {
uv_mutex_unlock(&discovery_thread.mutex);
}
+ info("waiting for discovery thread to finish...");
+
while (!discovery_thread.exited && max > 0) {
max -= step;
- info("waiting for discovery thread to finish...");
sleep_usec(step);
}
@@ -4077,7 +4097,7 @@ void *cgroups_main(void *ptr) {
, NULL
, "cgroups"
, NULL
- , "NetData CGroups Plugin CPU usage"
+ , "Netdata CGroups Plugin CPU usage"
, "milliseconds/s"
, PLUGIN_CGROUPS_NAME
, "stats"