hello, I recently decided to give collectd a try. However it seems it cannot collect CPU information, if that is enabled it will complain as such:
Jul 6 10:38:35 monitor collectd[24483]: cpu plugin: sysctl failed: Cannot allocate memory. Jul 6 10:38:35 monitor collectd[24483]: read-function of plugin `cpu' failed. Will suspend it for 20.000 seconds. Talking to sthen@ he suspects the issue came about as a result of the cpu stats change: https://github.com/openbsd/src/commit/531d8034253fb82282f0f353c086e9ad827e031c#diff-fee7dc79f296ae9ec5c557e620e80ed9 And the solution is probably to fix something in collectd's cpu collection code here, around the CAN_USE_SYSCTL block. https://github.com/collectd/collectd/blob/master/src/cpu.c #elif CAN_USE_SYSCTL /* {{{ */ uint64_t cpuinfo[numcpu][CPUSTATES]; size_t cpuinfo_size; int status; if (numcpu < 1) { ERROR("cpu plugin: Could not determine number of " "installed CPUs using sysctl(3)."); return -1; } memset(cpuinfo, 0, sizeof(cpuinfo)); #if defined(KERN_CPTIME2) if (numcpu > 1) { for (int i = 0; i < numcpu; i++) { int mib[] = {CTL_KERN, KERN_CPTIME2, i}; cpuinfo_size = sizeof(cpuinfo[0]); status = sysctl(mib, STATIC_ARRAY_SIZE(mib), cpuinfo[i], &cpuinfo_size, NULL, 0); if (status == -1) { ERROR("cpu plugin: sysctl failed: %s.", STRERRNO); return -1; } } } else #endif /* defined(KERN_CPTIME2) */ { int mib[] = {CTL_KERN, KERN_CPTIME}; long cpuinfo_tmp[CPUSTATES]; cpuinfo_size = sizeof(cpuinfo_tmp); status = sysctl(mib, STATIC_ARRAY_SIZE(mib), &cpuinfo_tmp, &cpuinfo_size, NULL, 0); if (status == -1) { ERROR("cpu plugin: sysctl failed: %s.", STRERRNO); return -1; } for (int i = 0; i < CPUSTATES; i++) { cpuinfo[0][i] = cpuinfo_tmp[i]; } } for (int i = 0; i < numcpu; i++) { cpu_stage(i, COLLECTD_CPU_STATE_USER, (derive_t)cpuinfo[i][CP_USER], now); cpu_stage(i, COLLECTD_CPU_STATE_NICE, (derive_t)cpuinfo[i][CP_NICE], now); cpu_stage(i, COLLECTD_CPU_STATE_SYSTEM, (derive_t)cpuinfo[i][CP_SYS], now); cpu_stage(i, COLLECTD_CPU_STATE_IDLE, (derive_t)cpuinfo[i][CP_IDLE], now); cpu_stage(i, COLLECTD_CPU_STATE_INTERRUPT, (derive_t)cpuinfo[i][CP_INTR], now); } /* }}} #endif CAN_USE_SYSCTL */ However this is far and above my skills, so I'm hoping someone sees something obvious to fix this. This is on a -current snap with the latest packages on amd64 (I am seeing the same behaviour on i386, and while the host below is a vmm I'm seeing it on physical hardware as well) thanks, .jh --- $ dmesg OpenBSD 6.3-current (GENERIC) #99: Fri Jul 6 10:18:31 MDT 2018 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC real mem = 1056956416 (1007MB) avail mem = 1015943168 (968MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0 acpi at bios0 not configured cpu0 at mainbus0: (uniprocessor) cpu0: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz, 2395.06 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,PCLMUL,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,PAGE1GB,LONG,LAHF,ABM,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,MELTDOWN cpu0: 256KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 pvbus0 at mainbus0: OpenBSD pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 "OpenBSD VMM Host" rev 0x00 virtio0 at pci0 dev 1 function 0 "Qumranet Virtio RNG" rev 0x00 viornd0 at virtio0 virtio0: irq 3 virtio1 at pci0 dev 2 function 0 "Qumranet Virtio Storage" rev 0x00 vioblk0 at virtio1 scsibus1 at vioblk0: 2 targets sd0 at scsibus1 targ 0 lun 0: <VirtIO, Block Device, > SCSI3 0/direct fixed sd0: 20480MB, 512 bytes/sector, 41943040 sectors virtio1: irq 5 virtio2 at pci0 dev 3 function 0 "Qumranet Virtio Network" rev 0x00 vio0 at virtio2: address fe:e1:bb:d1:1b:85 virtio2: irq 6 virtio3 at pci0 dev 4 function 0 "OpenBSD VMM Control" rev 0x00 vmmci0 at virtio3 virtio3: irq 7 isa0 at mainbus0 isadma0 at isa0 com0 at isa0 port 0x3f8/8 irq 4: ns16450, no fifo com0: console vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets root on sd0a (b3b0e43be04b11e0.a) swap on sd0b dump on sd0b $ pkg_info | grep collectd collectd-5.8.0p0 system metrics collection engine