summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaelUrankar <49529234+MikaelUrankar@users.noreply.github.com>2021-05-24 16:40:09 +0200
committerGitHub <noreply@github.com>2021-05-24 17:40:09 +0300
commit4b130034f223a5034c241b8a3e905d8f8031747d (patch)
treefbcd02c4cbd5f18b9639c33e1f6eb662a5c6dffc
parent4d0f785c15b982d9f0e277131d91b83f47a61ecd (diff)
Query the size of the hw.intrnames mib instead of using of a fixed va… (#11159)
-rw-r--r--collectors/freebsd.plugin/freebsd_sysctl.c82
1 files changed, 44 insertions, 38 deletions
diff --git a/collectors/freebsd.plugin/freebsd_sysctl.c b/collectors/freebsd.plugin/freebsd_sysctl.c
index 7d48e76dc0..3dc1fbfb16 100644
--- a/collectors/freebsd.plugin/freebsd_sysctl.c
+++ b/collectors/freebsd.plugin/freebsd_sysctl.c
@@ -641,52 +641,58 @@ int do_hw_intcnt(int update_every, usec_t dt) {
static int mib_hw_intrnames[2] = {0, 0};
static char *intrnames = NULL;
- size = nintr * (MAXCOMLEN + 1);
- if (unlikely(nintr != old_nintr))
- intrnames = reallocz(intrnames, size);
- if (unlikely(GETSYSCTL_WSIZE("hw.intrnames", mib_hw_intrnames, intrnames, size))) {
+ if (unlikely(GETSYSCTL_SIZE("hw.intrnames", mib_hw_intrnames, size))) {
error("DISABLED: system.intr chart");
error("DISABLED: system.interrupts chart");
error("DISABLED: hw.intrcnt module");
return 1;
} else {
+ if (unlikely(nintr != old_nintr))
+ intrnames = reallocz(intrnames, size);
+ if (unlikely(GETSYSCTL_WSIZE("hw.intrnames", mib_hw_intrnames, intrnames, size))) {
+ error("DISABLED: system.intr chart");
+ error("DISABLED: system.interrupts chart");
+ error("DISABLED: hw.intrcnt module");
+ return 1;
+ } else {
- // --------------------------------------------------------------------
-
- static RRDSET *st_interrupts = NULL;
-
- if (unlikely(!st_interrupts))
- st_interrupts = rrdset_create_localhost(
- "system",
- "interrupts",
- NULL,
- "interrupts",
- NULL,
- "System interrupts",
- "interrupts/s",
- "freebsd.plugin",
- "hw.intrcnt",
- NETDATA_CHART_PRIO_SYSTEM_INTERRUPTS,
- update_every,
- RRDSET_TYPE_STACKED
- );
- else
- rrdset_next(st_interrupts);
-
- for (i = 0; i < nintr; i++) {
- void *p;
-
- p = intrnames + i * (MAXCOMLEN + 1);
- if (unlikely((intrcnt[i] != 0) && (*(char *) p != 0))) {
- RRDDIM *rd_interrupts = rrddim_find_active(st_interrupts, p);
-
- if (unlikely(!rd_interrupts))
- rd_interrupts = rrddim_add(st_interrupts, p, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
-
- rrddim_set_by_pointer(st_interrupts, rd_interrupts, intrcnt[i]);
+ // --------------------------------------------------------------------
+
+ static RRDSET *st_interrupts = NULL;
+
+ if (unlikely(!st_interrupts))
+ st_interrupts = rrdset_create_localhost(
+ "system",
+ "interrupts",
+ NULL,
+ "interrupts",
+ NULL,
+ "System interrupts",
+ "interrupts/s",
+ "freebsd.plugin",
+ "hw.intrcnt",
+ NETDATA_CHART_PRIO_SYSTEM_INTERRUPTS,
+ update_every,
+ RRDSET_TYPE_STACKED
+ );
+ else
+ rrdset_next(st_interrupts);
+
+ for (i = 0; i < nintr; i++) {
+ void *p;
+
+ p = intrnames + i * (strlen(intrnames) + 1);
+ if (unlikely((intrcnt[i] != 0) && (*(char *) p != 0))) {
+ RRDDIM *rd_interrupts = rrddim_find_active(st_interrupts, p);
+
+ if (unlikely(!rd_interrupts))
+ rd_interrupts = rrddim_add(st_interrupts, p, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+
+ rrddim_set_by_pointer(st_interrupts, rd_interrupts, intrcnt[i]);
+ }
}
+ rrdset_done(st_interrupts);
}
- rrdset_done(st_interrupts);
}
}