static SIMPLE_PATTERN *enabled_cgroup_renames = NULL;
static SIMPLE_PATTERN *systemd_services_cgroups = NULL;
-static char *cgroups_rename_script = PLUGINS_DIR "/cgroup-name.sh";
+static char *cgroups_rename_script = NULL;
static uint32_t Read_hash = 0;
static uint32_t Write_hash = 0;
s = "/sys/fs/cgroup/cpuacct";
}
else s = mi->mount_point;
- snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, s);
cgroup_cpuacct_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/cpuacct", filename);
mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "blkio");
s = "/sys/fs/cgroup/blkio";
}
else s = mi->mount_point;
- snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, s);
cgroup_blkio_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/blkio", filename);
mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "memory");
s = "/sys/fs/cgroup/memory";
}
else s = mi->mount_point;
- snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, s);
cgroup_memory_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/memory", filename);
mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "devices");
s = "/sys/fs/cgroup/devices";
}
else s = mi->mount_point;
- snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
+ snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, s);
cgroup_devices_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/devices", filename);
cgroup_root_max = (int)config_get_number("plugin:cgroups", "max cgroups to allow", cgroup_root_max);
enabled_cgroup_patterns = simple_pattern_create(
config_get("plugin:cgroups", "enable by default cgroups matching",
+ " /system.slice/docker-*.scope "
" !*.mount "
" !*.partition "
" !*.scope "
" * "
), SIMPLE_PATTERN_EXACT);
- cgroups_rename_script = config_get("plugin:cgroups", "script to get cgroup names", cgroups_rename_script);
+ snprintfz(filename, FILENAME_MAX, "%s/cgroup-name.sh", netdata_configured_plugins_dir);
+ cgroups_rename_script = config_get("plugin:cgroups", "script to get cgroup names", filename);
enabled_cgroup_renames = simple_pattern_create(
config_get("plugin:cgroups", "run script to rename cgroups matching",
+ " *docker* "
+ " *lxc* "
" !/ "
" !*.mount "
" !*.partition "
char *s = procfile_lineword(ff, i, 0);
uint32_t hash = simple_hash(s);
- if(unlikely(hash == user_hash && !strsame(s, "user")))
+ if(unlikely(hash == user_hash && !strcmp(s, "user")))
cp->user = str2ull(procfile_lineword(ff, i, 1));
- else if(unlikely(hash == system_hash && !strsame(s, "system")))
+ else if(unlikely(hash == system_hash && !strcmp(s, "system")))
cp->system = str2ull(procfile_lineword(ff, i, 1));
}
char *s = procfile_lineword(ff, i, 1);
uint32_t hash = simple_hash(s);
- if(unlikely(hash == Read_hash && !strsame(s, "Read")))
+ if(unlikely(hash == Read_hash && !strcmp(s, "Read")))
io->Read += str2ull(procfile_lineword(ff, i, 2));
- else if(unlikely(hash == Write_hash && !strsame(s, "Write")))
+ else if(unlikely(hash == Write_hash && !strcmp(s, "Write")))
io->Write += str2ull(procfile_lineword(ff, i, 2));
/*
- else if(unlikely(hash == Sync_hash && !strsame(s, "Sync")))
+ else if(unlikely(hash == Sync_hash && !strcmp(s, "Sync")))
io->Sync += str2ull(procfile_lineword(ff, i, 2));
- else if(unlikely(hash == Async_hash && !strsame(s, "Async")))
+ else if(unlikely(hash == Async_hash && !strcmp(s, "Async")))
io->Async += str2ull(procfile_lineword(ff, i, 2));
- else if(unlikely(hash == Total_hash && !strsame(s, "Total")))
+ else if(unlikely(hash == Total_hash && !strcmp(s, "Total")))
io->Total += str2ull(procfile_lineword(ff, i, 2));
*/
}
}
if(unlikely(!mem->arl_base)) {
- mem->arl_base = arl_create(NULL, 60);
+ mem->arl_base = arl_create("cgroup/memory", NULL, 60);
arl_expect(mem->arl_base, "cache", &mem->cache);
arl_expect(mem->arl_base, "rss", &mem->rss);
if(cg->enabled) {
struct cgroup *t;
for (t = cgroup_root; t; t = t->next) {
- if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
+ if (t != cg && t->enabled && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
if (!strncmp(t->chart_id, "/system.slice/", 14) && !strncmp(cg->chart_id, "/init.scope/system.slice/", 25)) {
error("Control group with chart id '%s' already exists with id '%s' and is enabled. Swapping them by enabling cgroup with id '%s' and disabling cgroup with id '%s'.",
cg->chart_id, t->id, cg->id, t->id);
struct cgroup *cg;
for(cg = cgroup_root; cg ; cg = cg->next) {
- if(hash == cg->hash && strsame(id, cg->id) == 0)
+ if(hash == cg->hash && strcmp(id, cg->id) == 0)
break;
}
{
struct cgroup *t;
for(t = cgroup_root; t ; t = t->next) {
- if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strsame(t->chart_id, cg->chart_id)) {
+ if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
debug(D_CGROUP, "Enabling duplicate of cgroup '%s' with id '%s', because the original with id '%s' stopped.", t->chart_id, t->id, cg->id);
t->enabled = 1;
t->options &= ~CGROUP_OPTIONS_DISABLED_DUPLICATE;
RRDSET *stcpu_thread = NULL;
+ heartbeat_t hb;
+ heartbeat_init(&hb);
usec_t step = cgroup_update_every * USEC_PER_SEC;
- usec_t find_every = cgroup_check_for_new_every * USEC_PER_SEC, find_next = 0;
+ usec_t find_every = cgroup_check_for_new_every * USEC_PER_SEC, find_dt = 0;
for(;;) {
- usec_t now = now_monotonic_usec();
- usec_t next = now - (now % step) + step;
-
- while(now < next) {
- sleep_usec(next - now);
- now = now_monotonic_usec();
- }
-
+ usec_t hb_dt = heartbeat_next(&hb, step);
if(unlikely(netdata_exit)) break;
// BEGIN -- the job to be done
- if(unlikely(now >= find_next)) {
+ find_dt += hb_dt;
+ if(unlikely(find_dt >= find_every)) {
find_all_cgroups();
- find_next = now + find_every;
+ find_dt = 0;
}
read_all_cgroups(cgroup_root);