X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fproc_softirqs.c;h=560e2acb2d9dd1ab67c3e14f88cfd399e0df205b;hb=1c5e878d6d711b6f362b1089975d85f63625bfb0;hp=a6e77fc309cb7c79dbba5efbd66a96d3e9c57698;hpb=9e48033fbcf2f83c8359b181fbe4cf6dab757616;p=netdata.git diff --git a/src/proc_softirqs.c b/src/proc_softirqs.c index a6e77fc3..560e2acb 100644 --- a/src/proc_softirqs.c +++ b/src/proc_softirqs.c @@ -23,9 +23,9 @@ struct interrupt { // given a base, get a pointer to each record #define irrindex(base, line, cpus) ((struct interrupt *)&((char *)(base))[line * recordsize(cpus)]) -static inline struct interrupt *get_interrupts_array(uint32_t lines, int cpus) { +static inline struct interrupt *get_interrupts_array(size_t lines, int cpus) { static struct interrupt *irrs = NULL; - static uint32_t allocated = 0; + static size_t allocated = 0; if(unlikely(lines != allocated)) { uint32_t l; @@ -58,7 +58,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/softirqs"); + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/softirqs"); ff = procfile_open(config_get("plugin:proc:/proc/softirqs", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT); if(unlikely(!ff)) return 1; } @@ -66,8 +66,8 @@ int do_proc_softirqs(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 = procfile_linewords(ff, 0); + size_t lines = procfile_lines(ff), l; + size_t words = procfile_linewords(ff, 0); if(unlikely(!lines)) { error("Cannot read /proc/softirqs, zero lines reported."); @@ -105,14 +105,14 @@ int do_proc_softirqs(int update_every, usec_t dt) { irr->id = procfile_lineword(ff, l, 0); if(unlikely(!irr->id || !irr->id[0])) continue; - int idlen = strlen(irr->id); - if(unlikely(irr->id[idlen - 1] == ':')) + size_t idlen = strlen(irr->id); + if(unlikely(idlen && irr->id[idlen - 1] == ':')) irr->id[idlen - 1] = '\0'; int c; for(c = 0; c < cpus ;c++) { if(likely((c + 1) < (int)words)) - irr->cpu[c].value = strtoull(procfile_lineword(ff, l, (uint32_t)(c + 1)), NULL, 10); + irr->cpu[c].value = str2ull(procfile_lineword(ff, l, (uint32_t)(c + 1))); else irr->cpu[c].value = 0; @@ -128,8 +128,9 @@ int do_proc_softirqs(int update_every, usec_t dt) { // -------------------------------------------------------------------- - st = rrdset_find_bytype("system", "softirqs"); - if(unlikely(!st)) st = rrdset_create("system", "softirqs", NULL, "softirqs", NULL, "System softirqs", "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED); + st = rrdset_find_bytype_localhost("system", "softirqs"); + if(unlikely(!st)) st = rrdset_create_localhost("system", "softirqs", NULL, "softirqs", NULL, "System softirqs" + , "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED); else rrdset_next(st); for(l = 0; l < lines ;l++) { @@ -141,7 +142,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { if(unlikely(!irr->rd || strncmp(irr->name, irr->rd->name, MAX_INTERRUPT_NAME) != 0)) { irr->rd = rrddim_find(st, irr->id); if(unlikely(!irr->rd)) - irr->rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL); + irr->rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL); else rrddim_set_name(st, irr->rd, irr->name); @@ -163,7 +164,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { char id[50+1]; snprintfz(id, 50, "cpu%d_softirqs", c); - st = rrdset_find_bytype("cpu", id); + st = rrdset_find_bytype_localhost("cpu", id); if(unlikely(!st)) { // find if everything is zero unsigned long long core_sum = 0 ; @@ -176,7 +177,8 @@ int do_proc_softirqs(int update_every, usec_t dt) { char title[100+1]; snprintfz(title, 100, "CPU%d softirqs", c); - st = rrdset_create("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c, update_every, RRDSET_TYPE_STACKED); + st = rrdset_create_localhost("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c + , update_every, RRDSET_TYPE_STACKED); } else rrdset_next(st); @@ -186,7 +188,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { if(unlikely(!irr->cpu[c].rd)) { irr->cpu[c].rd = rrddim_find(st, irr->id); if(unlikely(!irr->cpu[c].rd)) - irr->cpu[c].rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRDDIM_INCREMENTAL); + irr->cpu[c].rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL); else rrddim_set_name(st, irr->cpu[c].rd, irr->name); }