X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fproc_stat.c;h=04f0896cd20266f1ae120350334744e4afb3122d;hb=0711ceaacadf4b435b11377ce9f0e65392675d2a;hp=d8f764ec4b7e9ec9e7d60064fb651bfac4e6c801;hpb=d7a1f3c8494e0546fc4c31d22b390a87ea9bd21a;p=netdata.git diff --git a/src/proc_stat.c b/src/proc_stat.c index d8f764ec..04f0896c 100644 --- a/src/proc_stat.c +++ b/src/proc_stat.c @@ -24,7 +24,7 @@ int do_proc_stat(int update_every, usec_t dt) { if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/stat"); + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/stat"); ff = procfile_open(config_get("plugin:proc:/proc/stat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT); if(unlikely(!ff)) return 1; } @@ -32,8 +32,8 @@ int do_proc_stat(int update_every, usec_t dt) { ff = procfile_readall(ff); if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time - uint32_t lines = procfile_lines(ff), l; - uint32_t words; + size_t lines = procfile_lines(ff), l; + size_t words; unsigned long long processes = 0, running = 0 , blocked = 0; RRDSET *st; @@ -46,7 +46,7 @@ int do_proc_stat(int update_every, usec_t dt) { if(likely(row_key[0] == 'c' && row_key[1] == 'p' && row_key[2] == 'u')) { words = procfile_linewords(ff, l); if(unlikely(words < 9)) { - error("Cannot read /proc/stat cpu line. Expected 9 params, read %u.", words); + error("Cannot read /proc/stat cpu line. Expected 9 params, read %zu.", words); continue; } @@ -91,24 +91,25 @@ int do_proc_stat(int update_every, usec_t dt) { } if(likely((isthistotal && do_cpu) || (!isthistotal && do_cpu_cores))) { - st = rrdset_find_bytype(type, id); + st = rrdset_find_bytype_localhost(type, id); if(unlikely(!st)) { - st = rrdset_create(type, id, NULL, family, context, title, "percentage", priority, update_every, RRDSET_TYPE_STACKED); + st = rrdset_create_localhost(type, id, NULL, family, context, title, "percentage", priority + , update_every, RRDSET_TYPE_STACKED); long multiplier = 1; long divisor = 1; // sysconf(_SC_CLK_TCK); - rrddim_add(st, "guest_nice", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "guest", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "steal", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "softirq", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "irq", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "user", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "system", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "nice", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - rrddim_add(st, "iowait", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); - - rrddim_add(st, "idle", NULL, multiplier, divisor, RRDDIM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "guest_nice", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "guest", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "steal", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "softirq", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "irq", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "user", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "system", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "nice", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + rrddim_add(st, "iowait", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); + + rrddim_add(st, "idle", NULL, multiplier, divisor, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); rrddim_hide(st, "idle"); } else rrdset_next(st); @@ -132,12 +133,13 @@ int do_proc_stat(int update_every, usec_t dt) { // -------------------------------------------------------------------- if(likely(do_interrupts)) { - st = rrdset_find_bytype("system", "intr"); + st = rrdset_find_bytype_localhost("system", "intr"); if(unlikely(!st)) { - st = rrdset_create("system", "intr", NULL, "interrupts", NULL, "CPU Interrupts", "interrupts/s", 900, update_every, RRDSET_TYPE_LINE); - st->isdetail = 1; + st = rrdset_create_localhost("system", "intr", NULL, "interrupts", NULL, "CPU Interrupts" + , "interrupts/s", 900, update_every, RRDSET_TYPE_LINE); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - rrddim_add(st, "interrupts", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); @@ -151,11 +153,12 @@ int do_proc_stat(int update_every, usec_t dt) { // -------------------------------------------------------------------- if(likely(do_context)) { - st = rrdset_find_bytype("system", "ctxt"); + st = rrdset_find_bytype_localhost("system", "ctxt"); if(unlikely(!st)) { - st = rrdset_create("system", "ctxt", NULL, "processes", NULL, "CPU Context Switches", "context switches/s", 800, update_every, RRDSET_TYPE_LINE); + st = rrdset_create_localhost("system", "ctxt", NULL, "processes", NULL, "CPU Context Switches" + , "context switches/s", 800, update_every, RRDSET_TYPE_LINE); - rrddim_add(st, "switches", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "switches", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); @@ -177,12 +180,13 @@ int do_proc_stat(int update_every, usec_t dt) { // -------------------------------------------------------------------- if(likely(do_forks)) { - st = rrdset_find_bytype("system", "forks"); + st = rrdset_find_bytype_localhost("system", "forks"); if(unlikely(!st)) { - st = rrdset_create("system", "forks", NULL, "processes", NULL, "Started Processes", "processes/s", 700, update_every, RRDSET_TYPE_LINE); - st->isdetail = 1; + st = rrdset_create_localhost("system", "forks", NULL, "processes", NULL, "Started Processes", "processes/s" + , 700, update_every, RRDSET_TYPE_LINE); + rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - rrddim_add(st, "started", NULL, 1, 1, RRDDIM_INCREMENTAL); + rrddim_add(st, "started", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); } else rrdset_next(st); @@ -193,12 +197,13 @@ int do_proc_stat(int update_every, usec_t dt) { // -------------------------------------------------------------------- if(likely(do_processes)) { - st = rrdset_find_bytype("system", "processes"); + st = rrdset_find_bytype_localhost("system", "processes"); if(unlikely(!st)) { - st = rrdset_create("system", "processes", NULL, "processes", NULL, "System Processes", "processes", 600, update_every, RRDSET_TYPE_LINE); + st = rrdset_create_localhost("system", "processes", NULL, "processes", NULL, "System Processes", "processes" + , 600, update_every, RRDSET_TYPE_LINE); - rrddim_add(st, "running", NULL, 1, 1, RRDDIM_ABSOLUTE); - rrddim_add(st, "blocked", NULL, -1, 1, RRDDIM_ABSOLUTE); + rrddim_add(st, "running", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + rrddim_add(st, "blocked", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE); } else rrdset_next(st);