@cryptotaxi247 / netdata-1 / commits / 1c83a5097

added more debugging info in cgroups; added /sys/fs/cgroups/devices as a candidate for cgroups

Costa Tsaousis (ktsaou) committed Jul 12, 2016 at 16:38 UTC 1c83a5097405870ca28210906d41761211a9c9e3
1 file changed +17
src/sys_fs_cgroup.c
+17
@@ -24,12 +24,14 @@
24 static int cgroup_enable_cpuacct_stat = CONFIG_ONDEMAND_ONDEMAND;
25 static int cgroup_enable_cpuacct_usage = CONFIG_ONDEMAND_ONDEMAND;
26 static int cgroup_enable_memory = CONFIG_ONDEMAND_ONDEMAND;
27 +static int cgroup_enable_devices = CONFIG_ONDEMAND_ONDEMAND;
28 static int cgroup_enable_blkio = CONFIG_ONDEMAND_ONDEMAND;
29 static int cgroup_enable_new_cgroups_detected_at_runtime = 1;
30 static int cgroup_check_for_new_every = 10;
31 static char *cgroup_cpuacct_base = NULL;
32 static char *cgroup_blkio_base = NULL;
33 static char *cgroup_memory_base = NULL;
34 +static char *cgroup_devices_base = NULL;
35
36 static int cgroup_root_count = 0;
37 static int cgroup_root_max = 500;
@@ -76,6 +78,16 @@ void read_cgroup_plugin_configuration() {
78 snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
79 cgroup_memory_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/memory", filename);
80
81 + mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup", "devices");
82 + if(!mi) mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "devices");
83 + if(!mi) {
84 + error("Cannot find cgroup devices mountinfo. Assuming default: /sys/fs/cgroup/devices");
85 + s = "/sys/fs/cgroup/devices";
86 + }
87 + else s = mi->mount_point;
88 + snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
89 + cgroup_devices_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/devices", filename);
90 +
91 cgroup_root_max = config_get_number("plugin:cgroups", "max cgroups to allow", cgroup_root_max);
92 cgroup_max_depth = config_get_number("plugin:cgroups", "max cgroups depth to monitor", cgroup_max_depth);
93
@@ -797,6 +809,8 @@ void found_subdir_in_dir(const char *dir) {
809 }
810
811 void find_dir_in_subdirs(const char *base, const char *this, void (*callback)(const char *)) {
812 + debug(D_CGROUP, "searching for directories in '%s'", base);
813 +
814 int enabled = -1;
815 if(!this) this = base;
816 size_t dirlen = strlen(this), baselen = strlen(base);
@@ -898,6 +912,9 @@ void find_all_cgroups() {
912 if(cgroup_enable_memory)
913 find_dir_in_subdirs(cgroup_memory_base, NULL, found_subdir_in_dir);
914
915 + if(cgroup_enable_devices)
916 + find_dir_in_subdirs(cgroup_devices_base, NULL, found_subdir_in_dir);
917 +
918 // remove any non-existing cgroups
919 cleanup_all_cgroups();
920