@cryptotaxi247 / netdata-1 / commits / 7a447032a

add Win CPU interrupts (#17753)

thiagoftsm committed Jun 27, 2024 at 22:23 UTC 7a447032a3d798a3b4ac7953d19d024657cdbce9
6 files changed +61 -48
CMakeLists.txt
+1
@@ -1017,6 +1017,7 @@ set(INTERNAL_COLLECTORS_FILES
1017 src/collectors/common-contexts/common-contexts.h
1018 src/collectors/common-contexts/disk.io.h
1019 src/collectors/common-contexts/system.io.h
1020 + src/collectors/common-contexts/system.interrupts.h
1021 src/collectors/common-contexts/system.processes.h
1022 src/collectors/common-contexts/system.ram.h
1023 src/collectors/common-contexts/mem.swap.h
src/collectors/common-contexts/common-contexts.h
+1
@@ -20,6 +20,7 @@ typedef void (*instance_labels_cb_t)(RRDSET *st, void *data);
20
21 #include "system.io.h"
22 #include "system.ram.h"
23 +#include "system.interrupts.h"
24 #include "system.processes.h"
25 #include "mem.swap.h"
26 #include "mem.pgfaults.h"
src/collectors/common-contexts/system.interrupts.h new
+39
@@ -0,0 +1,39 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#ifndef NETDATA_SYSTEM_INTERRUPTS_H
4 +#define NETDATA_SYSTEM_INTERRUPTS_H
5 +
6 +#include "common-contexts.h"
7 +
8 +#define _
9 +
10 +static inline void common_interrupts(uint64_t interrupts, int update_every, char *ext_module) {
11 + static RRDSET *st_intr = NULL;
12 + static RRDDIM *rd_interrupts = NULL;
13 +
14 + char *module = (!ext_module) ? _COMMON_PLUGIN_MODULE_NAME: ext_module;
15 +
16 + if(unlikely(!st_intr)) {
17 + st_intr = rrdset_create_localhost( "system"
18 + , "intr"
19 + , NULL
20 + , "interrupts"
21 + , NULL
22 + , "CPU Interrupts"
23 + , "interrupts/s"
24 + , _COMMON_PLUGIN_NAME
25 + , module
26 + , NETDATA_CHART_PRIO_SYSTEM_INTR
27 + , update_every
28 + , RRDSET_TYPE_LINE);
29 +
30 + rrdset_flag_set(st_intr, RRDSET_FLAG_DETAIL);
31 +
32 + rd_interrupts = rrddim_add(st_intr, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
33 + }
34 +
35 + rrddim_set_by_pointer(st_intr, rd_interrupts, (collected_number)interrupts);
36 + rrdset_done(st_intr);
37 +}
38 +
39 +#endif //NETDATA_SYSTEM_INTERRUPTS_H
src/collectors/freebsd.plugin/freebsd_sysctl.c
+5 -22
@@ -24,6 +24,10 @@
24 #include <netinet/udp.h>
25 #include <netinet/udp_var.h>
26
27 +#define _COMMON_PLUGIN_NAME "freebsd.plugin"
28 +#define _COMMON_PLUGIN_MODULE_NAME "freebsd"
29 +#include "../common-contexts/common-contexts.h"
30 +
31 // --------------------------------------------------------------------------------------------------------------------
32 // common definitions and variables
33
@@ -574,28 +578,7 @@ int do_hw_intcnt(int update_every, usec_t dt) {
578 static RRDSET *st_intr = NULL;
579 static RRDDIM *rd_intr = NULL;
580
577 - if (unlikely(!st_intr)) {
578 - st_intr = rrdset_create_localhost(
579 - "system",
580 - "intr",
581 - NULL,
582 - "interrupts",
583 - NULL,
584 - "Total Hardware Interrupts",
585 - "interrupts/s",
586 - "freebsd.plugin",
587 - "hw.intrcnt",
588 - NETDATA_CHART_PRIO_SYSTEM_INTR,
589 - update_every,
590 - RRDSET_TYPE_LINE
591 - );
592 - rrdset_flag_set(st_intr, RRDSET_FLAG_DETAIL);
593 -
594 - rd_intr = rrddim_add(st_intr, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
595 - }
596 -
597 - rrddim_set_by_pointer(st_intr, rd_intr, totalintr);
598 - rrdset_done(st_intr);
581 + common_interrupts(totalintr, update_every, "hw.intrcnt");
582
583 size_t size;
584 static int mib_hw_intrnames[2] = {0, 0};
src/collectors/proc.plugin/proc_stat.c
+1 -26
@@ -752,33 +752,8 @@ int do_proc_stat(int update_every, usec_t dt) {
752 }
753 else if(unlikely(hash == hash_intr && strcmp(row_key, "intr") == 0)) {
754 if(likely(do_interrupts)) {
755 - static RRDSET *st_intr = NULL;
756 - static RRDDIM *rd_interrupts = NULL;
755 unsigned long long value = str2ull(procfile_lineword(ff, l, 1), NULL);
758 -
759 - if(unlikely(!st_intr)) {
760 - st_intr = rrdset_create_localhost(
761 - "system"
762 - , "intr"
763 - , NULL
764 - , "interrupts"
765 - , NULL
766 - , "CPU Interrupts"
767 - , "interrupts/s"
768 - , PLUGIN_PROC_NAME
769 - , PLUGIN_PROC_MODULE_STAT_NAME
770 - , NETDATA_CHART_PRIO_SYSTEM_INTR
771 - , update_every
772 - , RRDSET_TYPE_LINE
773 - );
774 -
775 - rrdset_flag_set(st_intr, RRDSET_FLAG_DETAIL);
776 -
777 - rd_interrupts = rrddim_add(st_intr, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
778 - }
779 -
780 - rrddim_set_by_pointer(st_intr, rd_interrupts, value);
781 - rrdset_done(st_intr);
756 + common_interrupts(value, update_every, NULL);
757 }
758 }
759 else if(unlikely(hash == hash_ctxt && strcmp(row_key, "ctxt") == 0)) {
src/collectors/windows.plugin/perflib-processor.c
+14
@@ -3,6 +3,10 @@
3 #include "windows_plugin.h"
4 #include "windows-internals.h"
5
6 +#define _COMMON_PLUGIN_NAME "windows.plugin"
7 +#define _COMMON_PLUGIN_MODULE_NAME "PerflibProcesses"
8 +#include "../common-contexts/common-contexts.h"
9 +
10 struct processor {
11 bool collected_metadata;
12
@@ -22,6 +26,8 @@ struct processor {
26 COUNTER_DATA percentDPCTime;
27 COUNTER_DATA percentInterruptTime;
28 COUNTER_DATA percentIdleTime;
29 +
30 + COUNTER_DATA interruptsPerSec;
31 };
32
33 struct processor total = { 0 };
@@ -33,6 +39,7 @@ void initialize_processor_keys(struct processor *p) {
39 p->percentDPCTime.key = "% DPC Time";
40 p->percentInterruptTime.key = "% Interrupt Time";
41 p->percentIdleTime.key = "% Idle Time";
42 + p->interruptsPerSec.key = "Interrupts/sec";
43 }
44
45 void dict_processor_insert_cb(const DICTIONARY_ITEM *item __maybe_unused, void *value, void *data __maybe_unused) {
@@ -57,6 +64,7 @@ static bool do_processors(PERF_DATA_BLOCK *pDataBlock, int update_every) {
64
65 static const RRDVAR_ACQUIRED *cpus_var = NULL;
66 int cores_found = 0;
67 + uint64_t totalIPC = 0;
68
69 PERF_INSTANCE_DEFINITION *pi = NULL;
70 for(LONG i = 0; i < pObjectType->NumInstances ; i++) {
@@ -96,6 +104,8 @@ static bool do_processors(PERF_DATA_BLOCK *pDataBlock, int update_every) {
104 perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->percentInterruptTime);
105 perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->percentIdleTime);
106
107 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->interruptsPerSec);
108 +
109 if(!p->st) {
110 p->st = rrdset_create_localhost(
111 is_total ? "system" : "cpu"
@@ -130,6 +140,8 @@ static bool do_processors(PERF_DATA_BLOCK *pDataBlock, int update_every) {
140 uint64_t irq = p->percentInterruptTime.current.Data;
141 uint64_t idle = p->percentIdleTime.current.Data;
142
143 + totalIPC += p->interruptsPerSec.current.Data;
144 +
145 rrddim_set_by_pointer(p->st, p->rd_user, (collected_number)user);
146 rrddim_set_by_pointer(p->st, p->rd_system, (collected_number)system);
147 rrddim_set_by_pointer(p->st, p->rd_irq, (collected_number)irq);
@@ -167,6 +179,8 @@ static bool do_processors(PERF_DATA_BLOCK *pDataBlock, int update_every) {
179 if(cpus_var)
180 rrdvar_host_variable_set(localhost, cpus_var, cores_found);
181
182 + common_interrupts(totalIPC, update_every, NULL);
183 +
184 return true;
185 }
186