}
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) {
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) {
// ----------------------------------------------------------------------------
// 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();
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;
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;
}