enabled_cgroup_patterns = simple_pattern_create(
config_get("plugin:cgroups", "enable by default cgroups matching",
+ " /system.slice/docker-*.scope "
" !*.mount "
" !*.partition "
" !*.scope "
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);