{"record":{"id":"ba54ffa5249269bb","repo":"prometheus/node_exporter","slug":"sysctl-ctl-vfs-vfs-generic-vfs-bcachestat-failed","errorCode":null,"errorMessage":"sysctl CTL_VFS VFS_GENERIC VFS_BCACHESTAT failed: %w","messagePattern":"sysctl CTL_VFS VFS_GENERIC VFS_BCACHESTAT failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/meminfo_openbsd.go","lineNumber":76,"sourceCode":"}\n\n// NewMeminfoCollector returns a new Collector exposing memory stats.\nfunc NewMeminfoCollector(logger *slog.Logger) (Collector, error) {\n\treturn &meminfoCollector{\n\t\tlogger: logger,\n\t}, nil\n}\n\nfunc (c *meminfoCollector) getMemInfo() (map[string]float64, error) {\n\tvar uvmexp C.struct_uvmexp\n\tvar bcstats C.struct_bcachestats\n\n\tif _, err := C.sysctl_uvmexp(&uvmexp); err != nil {\n\t\treturn nil, fmt.Errorf(\"sysctl CTL_VM VM_UVMEXP failed: %w\", err)\n\t}\n\n\tif _, err := C.sysctl_bcstats(&bcstats); err != nil {\n\t\treturn nil, fmt.Errorf(\"sysctl CTL_VFS VFS_GENERIC VFS_BCACHESTAT failed: %w\", err)\n\t}\n\n\tps := float64(uvmexp.pagesize)\n\n\t// see uvm(9)\n\treturn map[string]float64{\n\t\t\"active_bytes\":                  ps * float64(uvmexp.active),\n\t\t\"cache_bytes\":                   ps * float64(bcstats.numbufpages),\n\t\t\"free_bytes\":                    ps * float64(uvmexp.free),\n\t\t\"inactive_bytes\":                ps * float64(uvmexp.inactive),\n\t\t\"size_bytes\":                    ps * float64(uvmexp.npages),\n\t\t\"swap_size_bytes\":               ps * float64(uvmexp.swpages),\n\t\t\"swap_used_bytes\":               ps * float64(uvmexp.swpginuse),\n\t\t\"swapped_in_pages_bytes_total\":  ps * float64(uvmexp.pgswapin),\n\t\t\"swapped_out_pages_bytes_total\": ps * float64(uvmexp.pgswapout),\n\t\t\"wired_bytes\":                   ps * float64(uvmexp.wired),\n\t}, nil\n}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/meminfo_openbsd.go#L58-L94","documentation":"This error is returned by getMemInfo in the OpenBSD meminfo collector when the cgo wrapper C.sysctl_bcstats fails to read the buffer cache statistics via the sysctl CTL_VFS/VFS_GENERIC/VFS_BCACHESTAT MIB. The kernel rejected the sysctl call (or the cgo helper failed), so buffer cache stats cannot be collected and the wrapped errno is surfaced with %w. node_exporter throws it because the meminfo metrics on OpenBSD depend on both VM_UVMEXP and VFS bcachestat data.","triggerScenarios":"Calling the meminfo collector on OpenBSD when sysctl vfs.generic.bcachestat is unavailable, restricted, or its struct size no longer matches what the kernel expects (kernel/userland mismatch after an OpenBSD version upgrade).","commonSituations":"Running a node_exporter binary built against a different OpenBSD release than the running kernel; hardened kernel restrictions on sysctl access; running inside a restricted jail/pledge(4) sandbox that blocks CTL_VFS lookups.","solutions":["Rebuild node_exporter from source on (or matching) the target OpenBSD release so the bcachestat struct layout matches the kernel","Verify with `sysctl vfs.generic.bcachestat` that the MIB exists and is readable by the user running node_exporter","Check pledge/unveil or jail restrictions and run the exporter with permissions allowing sysctl CTL_VFS access","Update to the latest node_exporter, as the cgo sysctl wrapper may have fixes for newer kernels"],"exampleFix":"// before (struct mismatch after kernel upgrade)\nif _, err := C.sysctl_bcstats(&bcstats); err != nil {\n\treturn nil, fmt.Errorf(\"sysctl CTL_VFS VFS_GENERIC VFS_BCACHESTAT failed: %w\", err)\n}\n// after: rebuild/redeploy a binary compiled on the matching OpenBSD release;\n// no code change needed if struct layout was the cause. Alternatively, skip\n// bcachestat gracefully:\nif _, err := C.sysctl_bcstats(&bcstats); err != nil {\n\tlogger.Debug(\"bcachestat unavailable\", \"err\", err)\n\tbcstats = C.struct_bcachestat{}\n}","handlingStrategy":"fallback","validationCode":"// shell check before deploying\n// sysctl vfs.generic.bcachestat && echo ok || echo 'bcachestat unavailable'","typeGuard":null,"tryCatchPattern":"metrics, err := collector.getMemInfo()\nif err != nil {\n\tif strings.Contains(err.Error(), \"VFS_BCACHESTAT\") {\n\t\tlogger.Warn(\"bcachestat sysctl unavailable; meminfo partial/absent\", \"err\", err)\n\t\treturn nil // degrade instead of failing the scrape\n\t}\n\treturn err\n}","preventionTips":["Pin node_exporter builds to the matching OpenBSD release","Smoke-test `sysctl vfs.generic.bcachestat` in deployment scripts","Review pledge/jail policies before sandboxing the exporter"],"tags":["openbsd","sysctl","memory","cgo","collector"],"backgroundTag":"sysctl-call-failed","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}