]> arthur.barton.de Git - netdata.git/blobdiff - src/sys_fs_cgroup.c
dns_query_time plugin: replace "." with "_" in dimensions
[netdata.git] / src / sys_fs_cgroup.c
index 248f3d626fd5838ef1e396d8b54d36c41abbeca7..b15c6fc42677f4697731e599540584f63a88a19d 100644 (file)
@@ -51,6 +51,8 @@ static SIMPLE_PATTERN *systemd_services_cgroups = NULL;
 
 static char *cgroups_rename_script = NULL;
 
+static int cgroups_check = 0;
+
 static uint32_t Read_hash = 0;
 static uint32_t Write_hash = 0;
 static uint32_t user_hash = 0;
@@ -145,10 +147,17 @@ void read_cgroup_plugin_configuration() {
 
     enabled_cgroup_patterns = simple_pattern_create(
             config_get("plugin:cgroups", "enable by default cgroups matching",
-                    " /system.slice/docker-*.scope "
+            // ----------------------------------------------------------------
+
+                    " !*/init.scope "                      // ignore init.scope
+                    " *.scope "                            // we need all *.scope for sure
+
+            // ----------------------------------------------------------------
+
+                    " !*/vcpu* "                           // libvirtd adds these sub-cgroups
+                    " !*/emulator "                        // libvirtd adds these sub-cgroups
                     " !*.mount "
                     " !*.partition "
-                    " !*.scope "
                     " !*.service "
                     " !*.slice "
                     " !*.swap "
@@ -157,18 +166,19 @@ void read_cgroup_plugin_configuration() {
                     " !/docker "
                     " !/libvirt "
                     " !/lxc "
-                    " !/lxc/*/ns "         //  #1397
+                    " !/lxc/*/ns "                         //  #1397
                     " !/machine "
                     " !/qemu "
                     " !/system "
                     " !/systemd "
                     " !/user "
-                    " * "                  // enable anything else
+                    " * "                                  // enable anything else
             ), SIMPLE_PATTERN_EXACT);
 
     enabled_cgroup_paths = simple_pattern_create(
             config_get("plugin:cgroups", "search for cgroups in subpaths matching",
-                    " !*-qemu "            //  #345
+                    " !*/init.scope "                      // ignore init.scope
+                    " !*-qemu "                            //  #345
                     " !/init.scope "
                     " !/system "
                     " !/systemd "
@@ -182,12 +192,13 @@ void read_cgroup_plugin_configuration() {
 
     enabled_cgroup_renames = simple_pattern_create(
             config_get("plugin:cgroups", "run script to rename cgroups matching",
+                    " *.scope "
                     " *docker* "
                     " *lxc* "
+                    " *qemu* "
                     " !/ "
                     " !*.mount "
                     " !*.partition "
-                    " !*.scope "
                     " !*.service "
                     " !*.slice "
                     " !*.swap "
@@ -407,12 +418,14 @@ static inline void cgroup_read_cpuacct_stat(struct cpuacct_stat *cp) {
         ff = procfile_reopen(ff, cp->filename, NULL, PROCFILE_FLAG_DEFAULT);
         if(unlikely(!ff)) {
             cp->updated = 0;
+            cgroups_check = 1;
             return;
         }
 
         ff = procfile_readall(ff);
         if(unlikely(!ff)) {
             cp->updated = 0;
+            cgroups_check = 1;
             return;
         }
 
@@ -449,12 +462,14 @@ static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
         ff = procfile_reopen(ff, ca->filename, NULL, PROCFILE_FLAG_DEFAULT);
         if(unlikely(!ff)) {
             ca->updated = 0;
+            cgroups_check = 1;
             return;
         }
 
         ff = procfile_readall(ff);
         if(unlikely(!ff)) {
             ca->updated = 0;
+            cgroups_check = 1;
             return;
         }
 
@@ -466,8 +481,8 @@ static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
 
         unsigned long i = procfile_linewords(ff, 0);
         if(unlikely(i == 0)) {
-            return;
             ca->updated = 0;
+            return;
         }
 
         // we may have 1 more CPU reported
@@ -509,12 +524,14 @@ static inline void cgroup_read_blkio(struct blkio *io) {
         ff = procfile_reopen(ff, io->filename, NULL, PROCFILE_FLAG_DEFAULT);
         if(unlikely(!ff)) {
             io->updated = 0;
+            cgroups_check = 1;
             return;
         }
 
         ff = procfile_readall(ff);
         if(unlikely(!ff)) {
             io->updated = 0;
+            cgroups_check = 1;
             return;
         }
 
@@ -580,12 +597,14 @@ static inline void cgroup_read_memory(struct memory *mem) {
         ff = procfile_reopen(ff, mem->filename_detailed, NULL, PROCFILE_FLAG_DEFAULT);
         if(unlikely(!ff)) {
             mem->updated_detailed = 0;
+            cgroups_check = 1;
             goto memory_next;
         }
 
         ff = procfile_readall(ff);
         if(unlikely(!ff)) {
             mem->updated_detailed = 0;
+            cgroups_check = 1;
             goto memory_next;
         }
 
@@ -2113,7 +2132,7 @@ void update_cgroup_charts(int update_every) {
                 );
 
                 for(i = 0; i < cg->cpuacct_usage.cpus; i++) {
-                    snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
+                    snprintfz(id, RRD_ID_LENGTH_MAX, "cpu%u", i);
                     rrddim_add(cg->st_cpu_per_core, id, NULL, 100, 1000000000, RRD_ALGORITHM_INCREMENTAL);
                 }
             }
@@ -2121,7 +2140,7 @@ void update_cgroup_charts(int update_every) {
                 rrdset_next(cg->st_cpu_per_core);
 
             for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
-                snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
+                snprintfz(id, RRD_ID_LENGTH_MAX, "cpu%u", i);
                 rrddim_set(cg->st_cpu_per_core, id, cg->cpuacct_usage.cpu_percpu[i]);
             }
             rrdset_done(cg->st_cpu_per_core);
@@ -2516,9 +2535,10 @@ void *cgroups_main(void *ptr) {
         // BEGIN -- the job to be done
 
         find_dt += hb_dt;
-        if(unlikely(find_dt >= find_every)) {
+        if(unlikely(find_dt >= find_every || cgroups_check)) {
             find_all_cgroups();
             find_dt = 0;
+            cgroups_check = 0;
         }
 
         read_all_cgroups(cgroup_root);