I chose the minimal route; basically if one gets ENODEV back, the values
for the unavailable cpus will be 0.
I don't use xstatbar, but is this an acceptable direction?
Thanks.
Index: Makefile
===================================================================
RCS file: /home/open/cvs/ports/sysutils/xstatbar/Makefile,v
retrieving revision 1.19
diff -u -p -r1.19 Makefile
--- Makefile 1 Jun 2018 14:20:19 -0000 1.19
+++ Makefile 4 Oct 2018 11:56:06 -0000
@@ -5,7 +5,7 @@ ONLY_FOR_ARCHS= ${APM_ARCHS}
COMMENT= simple system monitor bar
DISTNAME= xstatbar-0.5
-REVISION= 9
+REVISION= 10
FIX_EXTRACT_PERMISSIONS=Yes
CATEGORIES= sysutils x11
Index: patches/patch-stats_c
===================================================================
RCS file: /home/open/cvs/ports/sysutils/xstatbar/patches/patch-stats_c,v
retrieving revision 1.9
diff -u -p -r1.9 patch-stats_c
--- patches/patch-stats_c 1 Jun 2018 14:20:19 -0000 1.9
+++ patches/patch-stats_c 4 Oct 2018 11:57:39 -0000
@@ -56,7 +56,17 @@ Index: stats.c
/* get swap status */
if ((nswaps = swapctl(SWAP_NSWAP, 0, 0)) == 0)
-@@ -509,9 +520,9 @@ int
+@@ -459,7 +470,8 @@ sysinfo_update()
+ for (cpu = 0; cpu < sysinfo.ncpu; cpu++) {
+ mib_cpus[2] = cpu;
+ if (sysctl(mib_cpus, 3, sysinfo.cpu_raw[cpu][cur], &size, NULL, 0) <
0)
+- err(1, "sysinfo update: KERN.CPTIME2.%d failed", cpu);
++ if (errno != ENODEV)
++ err(1, "sysinfo update: KERN.CPTIME2.%d failed", cpu);
+ }
+ } else {
+ int i;
+@@ -509,9 +521,9 @@ int
cpu_draw(int cpu, XColor color, int x, int y)
{
static char str[1000];
@@ -68,7 +78,7 @@ Index: stats.c
};
int state, startx, time, col, h, i;
-@@ -531,7 +542,7 @@ cpu_draw(int cpu, XColor color, int x, int y)
+@@ -531,7 +543,7 @@ cpu_draw(int cpu, XColor color, int x, int y)
/* user time */
h = 0;
@@ -77,7 +87,7 @@ Index: stats.c
h = h * XINFO.height / 100;
XSetForeground(XINFO.disp, XINFO.gc, COLOR_RED.pixel);
XDrawLine(XINFO.disp, XINFO.buf, XINFO.gc,
-@@ -540,7 +551,7 @@ cpu_draw(int cpu, XColor color, int x, int y)
+@@ -540,7 +552,7 @@ cpu_draw(int cpu, XColor color, int x, int y)
/* nice time */
h = 0;
@@ -86,7 +96,7 @@ Index: stats.c
h = h * XINFO.height / 100;
XSetForeground(XINFO.disp, XINFO.gc, COLOR_BLUE.pixel);
XDrawLine(XINFO.disp, XINFO.buf, XINFO.gc,
-@@ -549,15 +560,24 @@ cpu_draw(int cpu, XColor color, int x, int y)
+@@ -549,15 +561,24 @@ cpu_draw(int cpu, XColor color, int x, int y)
/* system time */
h = 0;
@@ -113,7 +123,7 @@ Index: stats.c
h = h * XINFO.height / 100;
XSetForeground(XINFO.disp, XINFO.gc, COLOR_MAGENTA.pixel);
XDrawLine(XINFO.disp, XINFO.buf, XINFO.gc,
-@@ -594,7 +614,8 @@ mem_draw(XColor color, int x, int y)
+@@ -594,7 +615,8 @@ mem_draw(XColor color, int x, int y)
/* determine total memory */
total = sysinfo.memory[cur][MEM_ACT]
+ sysinfo.memory[cur][MEM_TOT]
@@ -123,7 +133,7 @@ Index: stats.c
/* start drawing ... */
x += render_text(color, x, y, "mem:") + 1;
-@@ -610,7 +631,8 @@ mem_draw(XColor color, int x, int y)
+@@ -610,7 +632,8 @@ mem_draw(XColor color, int x, int y)
if ((sysinfo.memory[time][MEM_ACT] != 0)
|| (sysinfo.memory[time][MEM_TOT] != 0)
@@ -133,7 +143,7 @@ Index: stats.c
/* draw yellow (total) bar */
-@@ -627,6 +649,13 @@ mem_draw(XColor color, int x, int y)
+@@ -627,6 +650,13 @@ mem_draw(XColor color, int x, int y)
XDrawLine(XINFO.disp, XINFO.buf, XINFO.gc,
x + col, XINFO.height - h,
x + col, XINFO.height);
@@ -147,7 +157,7 @@ Index: stats.c
}
time = (time + 1) % sysinfo.hist_size;
-@@ -639,6 +668,8 @@ mem_draw(XColor color, int x, int y)
+@@ -639,6 +669,8 @@ mem_draw(XColor color, int x, int y)
x += render_text(COLOR_YELLOW, x, y, fmtmem(sysinfo.memory[cur][MEM_TOT]));
x += render_text(color, x, y, "/");
x += render_text(COLOR_GREEN, x, y, fmtmem(sysinfo.memory[cur][MEM_FRE]));
Index: patches/patch-stats_h
===================================================================
RCS file: /home/open/cvs/ports/sysutils/xstatbar/patches/patch-stats_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-stats_h
--- patches/patch-stats_h 8 Jul 2014 10:15:39 -0000 1.2
+++ patches/patch-stats_h 4 Oct 2018 11:55:51 -0000
@@ -1,7 +1,14 @@
$OpenBSD: patch-stats_h,v 1.2 2014/07/08 10:15:39 sthen Exp $
---- stats.h.orig Tue Aug 3 18:04:34 2010
-+++ stats.h Tue Jul 8 11:12:49 2014
-@@ -30,10 +30,12 @@
+Index: stats.h
+--- stats.h.orig
++++ stats.h
+@@ -25,15 +25,18 @@
+ #include <fcntl.h>
+ #include <math.h>
+ #include <err.h>
++#include <errno.h>
+
+ #include <machine/apmvar.h>
#include <sys/audioio.h>
#include <sys/ioctl.h>
#include <sys/param.h>
@@ -14,7 +21,7 @@ $OpenBSD: patch-stats_h,v 1.2 2014/07/08
#include "xstatbar.h"
-@@ -84,6 +86,7 @@ typedef struct {
+@@ -84,6 +87,7 @@ typedef struct {
#define MEM_ACT 0
#define MEM_TOT 1
#define MEM_FRE 2