summaryrefslogtreecommitdiffstats
path: root/collectors/proc.plugin/proc_softirqs.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--collectors/proc.plugin/proc_softirqs.c (renamed from src/proc_softirqs.c)73
1 files changed, 33 insertions, 40 deletions
diff --git a/src/proc_softirqs.c b/collectors/proc.plugin/proc_softirqs.c
index cd7440b00..d68c69bb7 100644
--- a/src/proc_softirqs.c
+++ b/collectors/proc.plugin/proc_softirqs.c
@@ -1,4 +1,8 @@
-#include "common.h"
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "plugin_proc.h"
+
+#define PLUGIN_PROC_MODULE_SOFTIRQS_NAME "/proc/softirqs"
#define MAX_INTERRUPT_NAME 50
@@ -51,15 +55,16 @@ static inline struct interrupt *get_interrupts_array(size_t lines, int cpus) {
int do_proc_softirqs(int update_every, usec_t dt) {
(void)dt;
static procfile *ff = NULL;
- static int cpus = -1, do_per_core = -1;
+ static int cpus = -1, do_per_core = CONFIG_BOOLEAN_INVALID;
struct interrupt *irrs = NULL;
- if(unlikely(do_per_core == -1)) do_per_core = config_get_boolean("plugin:proc:/proc/softirqs", "interrupts per core", 1);
+ if(unlikely(do_per_core == CONFIG_BOOLEAN_INVALID))
+ do_per_core = config_get_boolean_ondemand("plugin:proc:/proc/softirqs", "interrupts per core", CONFIG_BOOLEAN_AUTO);
if(unlikely(!ff)) {
char filename[FILENAME_MAX + 1];
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);
+ ff = procfile_open(config_get("plugin:proc:/proc/softirqs", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
if(unlikely(!ff)) return 1;
}
@@ -105,10 +110,6 @@ 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;
- 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))
@@ -136,9 +137,9 @@ int do_proc_softirqs(int update_every, usec_t dt) {
, NULL
, "System softirqs"
, "softirqs/s"
- , "proc"
- , "softirqs"
- , 950
+ , PLUGIN_PROC_NAME
+ , PLUGIN_PROC_MODULE_SOFTIRQS_NAME
+ , NETDATA_CHART_PRIO_SYSTEM_SOFTIRQS
, update_every
, RRDSET_TYPE_STACKED
);
@@ -148,34 +149,30 @@ int do_proc_softirqs(int update_every, usec_t dt) {
for(l = 0; l < lines ;l++) {
struct interrupt *irr = irrindex(irrs, l, cpus);
- if(unlikely(!irr->used)) continue;
-
- // some interrupt may have changed without changing the total number of lines
- // if the same number of interrupts have been added and removed between two
- // calls of this function.
- if(unlikely(!irr->rd || strncmp(irr->name, irr->rd->name, MAX_INTERRUPT_NAME) != 0)) {
- irr->rd = rrddim_find(st_system_softirqs, irr->id);
-
- if(unlikely(!irr->rd))
+ if(irr->used && irr->total) {
+ // some interrupt may have changed without changing the total number of lines
+ // if the same number of interrupts have been added and removed between two
+ // calls of this function.
+ if(unlikely(!irr->rd || strncmp(irr->name, irr->rd->name, MAX_INTERRUPT_NAME) != 0)) {
irr->rd = rrddim_add(st_system_softirqs, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- else
rrddim_set_name(st_system_softirqs, irr->rd, irr->name);
- // also reset per cpu RRDDIMs to avoid repeating strncmp() in the per core loop
- if(likely(do_per_core)) {
- int c;
- for (c = 0; c < cpus ;c++) irr->cpu[c].rd = NULL;
+ // also reset per cpu RRDDIMs to avoid repeating strncmp() in the per core loop
+ if(likely(do_per_core != CONFIG_BOOLEAN_NO)) {
+ int c;
+ for(c = 0; c < cpus; c++) irr->cpu[c].rd = NULL;
+ }
}
- }
- rrddim_set_by_pointer(st_system_softirqs, irr->rd, irr->total);
+ rrddim_set_by_pointer(st_system_softirqs, irr->rd, irr->total);
+ }
}
rrdset_done(st_system_softirqs);
// --------------------------------------------------------------------
- if(do_per_core) {
+ if(do_per_core != CONFIG_BOOLEAN_NO) {
static RRDSET **core_st = NULL;
static int old_cpus = 0;
@@ -214,9 +211,9 @@ int do_proc_softirqs(int update_every, usec_t dt) {
, "cpu.softirqs"
, title
, "softirqs/s"
- , "proc"
- , "softirqs"
- , 3000 + c
+ , PLUGIN_PROC_NAME
+ , PLUGIN_PROC_MODULE_SOFTIRQS_NAME
+ , NETDATA_CHART_PRIO_SOFTIRQS_PER_CORE + c
, update_every
, RRDSET_TYPE_STACKED
);
@@ -227,18 +224,14 @@ int do_proc_softirqs(int update_every, usec_t dt) {
for(l = 0; l < lines ;l++) {
struct interrupt *irr = irrindex(irrs, l, cpus);
- if(unlikely(!irr->used)) continue;
-
- if(unlikely(!irr->cpu[c].rd)) {
- irr->cpu[c].rd = rrddim_find(core_st[c], irr->id);
-
- if(unlikely(!irr->cpu[c].rd))
+ if(irr->used && (do_per_core == CONFIG_BOOLEAN_YES || irr->cpu[c].value)) {
+ if(unlikely(!irr->cpu[c].rd)) {
irr->cpu[c].rd = rrddim_add(core_st[c], irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
- else
rrddim_set_name(core_st[c], irr->cpu[c].rd, irr->name);
- }
+ }
- rrddim_set_by_pointer(core_st[c], irr->cpu[c].rd, irr->cpu[c].value);
+ rrddim_set_by_pointer(core_st[c], irr->cpu[c].rd, irr->cpu[c].value);
+ }
}
rrdset_done(core_st[c]);