prometheus/node_exporter · error
length of bytes received from sysctl
Error message
length of bytes received from sysctl (%d) does not match expected bytes (long: %d), (int: %d)
What it means
BSD sysctl validation guard in getCLong: unix.SysctlRaw returned a byte buffer whose length is neither sizeof(long) nor sizeof(int), so the raw value cannot be safely reinterpreted as a numeric sysctl. This indicates a kernel/platform returning an unexpected size for MIB entry b.mib, or a sysctl whose value is not scalar numeric at all.
Solutions
- Check the sysctl type: `sysctl -n <name>` / `sysctl -x` to see whether it is truly a long/int or a string/opaque value; if so, use the appropriate handler instead of the long getter.
- Verify OS/arch support — unusual architectures may return different sizes; report/fix the size handling for that platform.
- Update FreeBSD/OS version mappings if the kernel changed the value's representation.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at collector/sysctl_bsd.go:108 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07).
Data as JSON: /api/errors/2f20656887e6b0a9.
Report an issue: GitHub.
Appendix: source
Thrown at collector/sysctl_bsd.go:108
func (b bsdSysctl) getCLong() (float64, error) {
raw, err := unix.SysctlRaw(b.mib)
if err != nil {
return 0, err
}
if len(raw) == C.sizeof_long {
return float64(*(*C.long)(unsafe.Pointer(&raw[0]))), nil
}
if len(raw) == C.sizeof_int {
// This is valid for at least vfs.bufspace, and the default
// long handler - which can clamp longs to 32-bits:
// https://github.com/freebsd/freebsd/blob/releng/10.3/sys/kern/vfs_bio.c#L338
// https://github.com/freebsd/freebsd/blob/releng/10.3/sys/kern/kern_sysctl.c#L1062
return float64(*(*C.int)(unsafe.Pointer(&raw[0]))), nil
}
return 0, fmt.Errorf(
"length of bytes received from sysctl (%d) does not match expected bytes (long: %d), (int: %d)",
len(raw),
C.sizeof_long,
C.sizeof_int,
)
}
View on GitHub (pinned to 17ddd77c59)