@cryptotaxi247 / netdata-1 / commits / 002080996

cgroups: disable by default certain cgroups #340

Costa Tsaousis (ktsaou) committed May 1, 2016 at 04:11 UTC 002080996b86c70e65738e0d87318c60c71b8ed4
1 file changed +21 -12
src/sys_fs_cgroup.c
+21 -12
@@ -639,23 +639,32 @@ struct cgroup *cgroup_add(const char *id) {
639 if(!*chart_id) {
640 chart_id = "/";
641
642 - // disable by default the host cgroup
642 + // disable by default the root cgroup
643 def = 0;
644 - debug(D_CGROUP, "cgroup '%s' is the host container (by default %s)", id, (def)?"enabled":"disabled");
644 + debug(D_CGROUP, "cgroup '%s' is the root container (by default %s)", id, (def)?"enabled":"disabled");
645 }
646 else {
647 if(*chart_id == '/') chart_id++;
648
649 + size_t len = strlen(chart_id);
650 +
651 // disable by default the parent cgroup
652 // for known cgroup managers
653 if(!strcmp(chart_id, "lxc") ||
654 !strcmp(chart_id, "docker") ||
655 + !strcmp(chart_id, "libvirt") ||
656 + !strcmp(chart_id, "qemu") ||
657 !strcmp(chart_id, "systemd") ||
654 - !strncmp(chart_id, "user.slice", 10) ||
655 - !strncmp(chart_id, "system.slice", 12)
658 + !strcmp(chart_id, "user.slice") ||
659 + !strcmp(chart_id, "system.slice") ||
660 + !strcmp(chart_id, "user") ||
661 + !strcmp(chart_id, "system") ||
662 + (len > 5 && !strncmp(&chart_id[len - 5], ".user", 5)) ||
663 + (len > 6 && !strncmp(&chart_id[len - 6], ".scope", 6)) ||
664 + (len > 10 && !strncmp(&chart_id[len - 10], ".partition", 10))
665 ) {
666 def = 0;
658 - debug(D_CGROUP, "cgroup '%s' is container manager (by default %s)", id, (def)?"enabled":"disabled");
667 + debug(D_CGROUP, "cgroup '%s' is cgroup parent (by default %s)", id, (def)?"enabled":"disabled");
668 }
669 }
670
@@ -699,11 +708,7 @@ struct cgroup *cgroup_add(const char *id) {
708 }
709
710 void cgroup_free(struct cgroup *cg) {
702 - debug(D_CGROUP, "removing cgroup '%s'", cg->id);
703 -
704 - // FIXME
705 - // switch this to debug(D_CGROUP, ...
706 - info("Removing cgroup '%s' with chart id '%s' (was %s and %s)", cg->id, cg->chart_id, (cg->enabled)?"enabled":"disabled", (cg->available)?"available":"not available");
711 + debug(D_CGROUP, "Removing cgroup '%s' with chart id '%s' (was %s and %s)", cg->id, cg->chart_id, (cg->enabled)?"enabled":"disabled", (cg->available)?"available":"not available");
712
713 free(cg->cpuacct_usage.cpu_percpu);
714
@@ -801,8 +806,12 @@ void find_dir_in_subdirs(const char *base, const char *this, void (*callback)(co
806 snprintf(option, FILENAME_MAX, "search for cgroups under %s", (*relative_path == '\0')?"/":relative_path);
807
808 int def = 1;
804 - if(!strcmp(this, "system.slice") ||
809 + size_t len = strlen(this);
810 + if((len > 5 && !strncmp(&this[len - 5], ".user", 5)) ||
811 + !strcmp(this, "system.slice") ||
812 !strcmp(this, "user.slice") ||
813 + !strcmp(this, "system") ||
814 + !strcmp(this, "user") ||
815 !strcmp(this, "systemd"))
816 def = 0;
817
@@ -961,7 +970,7 @@ void update_cgroup_charts(int update_every) {
970 continue;
971
972 if(cg->id[0] == '\0')
964 - strcpy(type, "cgroup_host");
973 + strcpy(type, "cgroup_root");
974 else if(cg->id[0] == '/')
975 snprintf(type, RRD_ID_LENGTH_MAX, "cgroup_%s", cg->chart_id);
976 else