X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fsys_fs_cgroup.c;h=a42178efc3188d14f406880460a712d7a62e7d2d;hb=3b8cfeecd6ee3d94452315a5bb6525ddea06caff;hp=a0f8a9982bbf2f4de7c1954a9e94bf80a7b69679;hpb=453e1d01fd32ce5ff1948e202669f9d71a827d47;p=netdata.git diff --git a/src/sys_fs_cgroup.c b/src/sys_fs_cgroup.c index a0f8a998..a42178ef 100644 --- a/src/sys_fs_cgroup.c +++ b/src/sys_fs_cgroup.c @@ -269,7 +269,7 @@ void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) { } unsigned long i = procfile_linewords(ff, 0); - if(i <= 0) return; + if(i == 0) return; // we may have 1 more CPU reported while(i > 0) { @@ -875,13 +875,20 @@ int find_dir_in_subdirs(const char *base, const char *this, void (*callback)(con if(*r == '\0') r = "/"; else if (*r == '/') r++; + // do not decent in directories we are not interested + // https://github.com/firehol/netdata/issues/345 + int def = 1; + size_t len = strlen(r); + if(len > 5 && !strncmp(&r[len - 5], "-qemu", 5)) + def = 0; + // we check for this option here // so that the config will not have settings // for leaf directories char option[FILENAME_MAX + 1]; snprintfz(option, FILENAME_MAX, "search for cgroups under %s", r); option[FILENAME_MAX] = '\0'; - enabled = config_get_boolean("plugin:cgroups", option, 1); + enabled = config_get_boolean("plugin:cgroups", option, def); } if(enabled) { @@ -1384,12 +1391,12 @@ void update_cgroup_charts(int update_every) { // ---------------------------------------------------------------------------- // cgroups main -int do_sys_fs_cgroup(int update_every, unsigned long long dt) { +int do_sys_fs_cgroup(int update_every, usec_t dt) { (void)dt; static int cgroup_global_config_read = 0; static time_t last_run = 0; - time_t now = time(NULL); + time_t now = now_realtime_sec(); if(unlikely(!cgroup_global_config_read)) { read_cgroup_plugin_configuration(); @@ -1426,24 +1433,24 @@ void *cgroups_main(void *ptr) int vdo_cpu_netdata = !config_get_boolean("plugin:cgroups", "cgroups plugin resources", 1); // keep track of the time each module was called - unsigned long long sutime_sys_fs_cgroup = 0ULL; + usec_t sutime_sys_fs_cgroup = 0ULL; // the next time we will run - aligned properly - unsigned long long sunext = (time(NULL) - (time(NULL) % rrd_update_every) + rrd_update_every) * 1000000ULL; - unsigned long long sunow; + usec_t sunext = (now_realtime_sec() - (now_realtime_sec() % rrd_update_every) + rrd_update_every) * USEC_PER_SEC; RRDSET *stcpu_thread = NULL; for(;;) { + usec_t sunow; if(unlikely(netdata_exit)) break; // delay until it is our time to run - while((sunow = time_usec()) < sunext) + while((sunow = now_realtime_usec()) < sunext) sleep_usec(sunext - sunow); // find the next time we need to run - while(time_usec() > sunext) - sunext += rrd_update_every * 1000000ULL; + while(now_realtime_usec() > sunext) + sunext += rrd_update_every * USEC_PER_SEC; if(unlikely(netdata_exit)) break; @@ -1451,7 +1458,7 @@ void *cgroups_main(void *ptr) if(!vdo_sys_fs_cgroup) { debug(D_PROCNETDEV_LOOP, "PROCNETDEV: calling do_sys_fs_cgroup()."); - sunow = time_usec(); + sunow = now_realtime_usec(); vdo_sys_fs_cgroup = do_sys_fs_cgroup(rrd_update_every, (sutime_sys_fs_cgroup > 0)?sunow - sutime_sys_fs_cgroup:0ULL); sutime_sys_fs_cgroup = sunow; }