@cryptotaxi247 / netdata-1 / commits / 1006b9561

fixed interrupt names; enabled per core interrupts

Costa Tsaousis (ktsaou) committed Dec 15, 2015 at 11:52 UTC 1006b9561e7afd6bbea48f7a6fdd1941f5413c97
3 files changed +27 -11
src/proc_interrupts.c
+22 -9
@@ -15,12 +15,12 @@
15
16 #define MAX_INTERRUPTS 256
17 #define MAX_INTERRUPT_CPUS 256
18 -#define MAX_INTERRUPT_NAME 20
18 +#define MAX_INTERRUPT_NAME 50
19
20 struct interrupt {
21 int used;
22 char *id;
23 - char *name;
23 + char name[MAX_INTERRUPT_NAME + 1];
24 unsigned long long value[MAX_INTERRUPT_CPUS];
25 unsigned long long total;
26 };
@@ -31,7 +31,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
31
32 if(dt) {};
33
34 - if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/interrupts", "interrupts per core", 0);
34 + if(do_per_core == -1) do_per_core = config_get_boolean("plugin:proc:/proc/interrupts", "interrupts per core", 1);
35
36 if(!ff) {
37 char filename[FILENAME_MAX + 1];
@@ -78,8 +78,9 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
78 irr->id = procfile_lineword(ff, l, 0);
79 if(!irr->id || !irr->id[0]) continue;
80
81 - if(irr->id[strlen(irr->id) - 1] == ':')
82 - irr->id[strlen(irr->id) - 1] = '\0';
81 + int idlen = strlen(irr->id);
82 + if(irr->id[idlen - 1] == ':')
83 + irr->id[idlen - 1] = '\0';
84
85 int c;
86 for(c = 0; c < cpus ;c++) {
@@ -92,10 +93,19 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
93 }
94
95 if(isdigit(irr->id[0]) && (uint32_t)(cpus + 2) < words) {
95 - irr->name = procfile_lineword(ff, l, words - 1);
96 + strncpy(irr->name, procfile_lineword(ff, l, words - 1), MAX_INTERRUPT_NAME);
97 + irr->name[MAX_INTERRUPT_NAME] = '\0';
98 + int nlen = strlen(irr->name);
99 + if(nlen < (MAX_INTERRUPT_NAME-1)) {
100 + irr->name[nlen] = '_';
101 + strncpy(&irr->name[nlen + 1], irr->id, MAX_INTERRUPT_NAME - nlen);
102 + irr->name[MAX_INTERRUPT_NAME] = '\0';
103 + }
104 + }
105 + else {
106 + strncpy(irr->name, irr->id, MAX_INTERRUPT_NAME);
107 + irr->name[MAX_INTERRUPT_NAME] = '\0';
108 }
97 - else
98 - irr->name = irr->id;
109
110 irr->used = 1;
111 }
@@ -125,6 +135,9 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
135 int c;
136
137 for(c = 0; c < cpus ; c++) {
138 + char family[256];
139 + snprintf(family, 256, "cpu%d", c);
140 +
141 char id[256];
142 snprintf(id, 256, "cpu%d_interrupts", c);
143
@@ -133,7 +146,7 @@ int do_proc_interrupts(int update_every, unsigned long long dt) {
146 char name[256], title[256];
147 snprintf(name, 256, "cpu%d_interrupts", c);
148 snprintf(title, 256, "CPU%d Interrupts", c);
136 - st = rrdset_create("cpu", id, name, "cpu", title, "interrupts/s", 2000 + c, update_every, RRDSET_TYPE_STACKED);
149 + st = rrdset_create("cpu", id, name, family, title, "interrupts/s", 2000 + c, update_every, RRDSET_TYPE_STACKED);
150
151 for(l = 0; l < lines ;l++) {
152 if(!irrs[l].used) continue;
src/proc_stat.c
+2 -1
@@ -71,6 +71,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
71 char *type = RRD_TYPE_STAT;
72 long priority = 1000;
73 int isthistotal = 0;
74 +
75 if(strcmp(id, "cpu") == 0) {
76 isthistotal = 1;
77 title = "Total CPU utilization";
@@ -81,7 +82,7 @@ int do_proc_stat(int update_every, unsigned long long dt) {
82 if((isthistotal && do_cpu) || (!isthistotal && do_cpu_cores)) {
83 st = rrdset_find_bytype(type, id);
84 if(!st) {
84 - st = rrdset_create(type, id, NULL, "cpu", title, "percentage", priority, update_every, RRDSET_TYPE_STACKED);
85 + st = rrdset_create(type, id, NULL, id, title, "percentage", priority, update_every, RRDSET_TYPE_STACKED);
86
87 long multiplier = 1;
88 long divisor = 1; // sysconf(_SC_CLK_TCK);
web/dashboard_full.html
+3 -1
@@ -640,7 +640,9 @@ function prepareScreen(data) {
640 if(hash != '') {
641 // Clear the hash in the URL
642 // location.hash = ''; // delete front "//" if you want to change the address bar
643 - $('html, body').animate({ scrollTop: $(location.hash).offset().top}, 0);
643 + var offset = $(location.hash).offset();
644 + if(typeof offset !== 'undefined')
645 + $('html, body').animate({ scrollTop: offset.top }, 0);
646 }
647
648 /* activate bootstrap scrollspy (needed for sidebar) */