X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fproc_interrupts.c;h=082e1f57b9c59233202d13834ae7fd49a5ff745a;hb=0a773d0ce3377451cde05d8f3981649715f9869b;hp=fd10044c7601c832f2e3dc8042e74c67c279aee4;hpb=f95aca2a808b4b22fcb9c8fc9084bdcb38645600;p=netdata.git diff --git a/src/proc_interrupts.c b/src/proc_interrupts.c index fd10044c..082e1f57 100644 --- a/src/proc_interrupts.c +++ b/src/proc_interrupts.c @@ -23,12 +23,12 @@ 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; + size_t l; int c; irrs = (struct interrupt *)reallocz(irrs, lines * recordsize(cpus)); @@ -48,7 +48,7 @@ static inline struct interrupt *get_interrupts_array(uint32_t lines, int cpus) { return irrs; } -int do_proc_interrupts(int update_every, unsigned long long dt) { +int do_proc_interrupts(int update_every, usec_t dt) { (void)dt; static procfile *ff = NULL; static int cpus = -1, do_per_core = -1; @@ -59,7 +59,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/interrupts"); + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/interrupts"); ff = procfile_open(config_get("plugin:proc:/proc/interrupts", "filename to monitor", filename), " \t", PROCFILE_FLAG_DEFAULT); } if(unlikely(!ff)) @@ -69,8 +69,8 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { 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/interrupts, zero lines reported."); @@ -108,14 +108,14 @@ int do_proc_interrupts(int update_every, unsigned long long 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; @@ -124,8 +124,8 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { if(unlikely(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words)) { strncpyz(irr->name, procfile_lineword(ff, l, words - 1), MAX_INTERRUPT_NAME); - int nlen = strlen(irr->name); - int idlen = strlen(irr->id); + size_t nlen = strlen(irr->name); + idlen = strlen(irr->id); if(likely(nlen + 1 + idlen <= MAX_INTERRUPT_NAME)) { irr->name[nlen] = '_'; strncpyz(&irr->name[nlen + 1], irr->id, MAX_INTERRUPT_NAME - nlen - 1); @@ -146,8 +146,9 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { // -------------------------------------------------------------------- - st = rrdset_find_bytype("system", "interrupts"); - if(unlikely(!st)) st = rrdset_create("system", "interrupts", NULL, "interrupts", NULL, "System interrupts", "interrupts/s", 1000, update_every, RRDSET_TYPE_STACKED); + st = rrdset_find_bytype_localhost("system", "interrupts"); + if(unlikely(!st)) st = rrdset_create_localhost("system", "interrupts", NULL, "interrupts", NULL, "System interrupts" + , "interrupts/s", 1000, update_every, RRDSET_TYPE_STACKED); else rrdset_next(st); for(l = 0; l < lines ;l++) { @@ -159,7 +160,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { if(unlikely(!irr->rd || strncmp(irr->rd->name, irr->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); @@ -181,11 +182,12 @@ int do_proc_interrupts(int update_every, unsigned long long dt) { char id[50+1]; snprintfz(id, 50, "cpu%d_interrupts", c); - st = rrdset_find_bytype("cpu", id); + st = rrdset_find_bytype_localhost("cpu", id); if(unlikely(!st)) { char title[100+1]; snprintfz(title, 100, "CPU%d Interrupts", c); - st = rrdset_create("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s", 1100 + c, update_every, RRDSET_TYPE_STACKED); + st = rrdset_create_localhost("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s", + 1100 + c, update_every, RRDSET_TYPE_STACKED); } else rrdset_next(st); @@ -195,7 +197,7 @@ int do_proc_interrupts(int update_every, unsigned long long 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); }