{"record":{"id":"0b4d77d5b53b1c89","repo":"prometheus/node_exporter","slug":"sysctl-vm-stats-vm-v-page-size-failed-w","errorCode":null,"errorMessage":"sysctl(vm.stats.vm.v_page_size) failed: %w","messagePattern":"sysctl\\(vm\\.stats\\.vm\\.v_page_size\\) failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/memory_bsd.go","lineNumber":45,"sourceCode":"\tmemorySubsystem = \"memory\"\n)\n\ntype memoryCollector struct {\n\tpageSize uint64\n\tsysctls  []bsdSysctl\n\tkvm      kvm\n\tlogger   *slog.Logger\n}\n\nfunc init() {\n\tregisterCollector(\"meminfo\", defaultEnabled, NewMemoryCollector)\n}\n\n// NewMemoryCollector returns a new Collector exposing memory stats.\nfunc NewMemoryCollector(logger *slog.Logger) (Collector, error) {\n\ttmp32, err := unix.SysctlUint32(\"vm.stats.vm.v_page_size\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"sysctl(vm.stats.vm.v_page_size) failed: %w\", err)\n\t}\n\tsize := float64(tmp32)\n\n\tmibSwapTotal := \"vm.swap_total\"\n\t/* swap_total is FreeBSD specific. Fall back to Dfly specific mib if not present. */\n\t_, err = unix.SysctlUint64(mibSwapTotal)\n\tif err != nil {\n\t\tmibSwapTotal = \"vm.swap_size\"\n\t}\n\n\tfromPage := func(v float64) float64 {\n\t\treturn v * size\n\t}\n\n\treturn &memoryCollector{\n\t\tlogger:   logger,\n\t\tpageSize: uint64(tmp32),\n\t\tsysctls: []bsdSysctl{","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/memory_bsd.go#L27-L63","documentation":"NewMemoryCollector on FreeBSD/DragonFly BSD reads the page size via unix.SysctlUint32(\"vm.stats.vm.v_page_size\") before constructing the collector. If that sysctl fails (missing MIB or permission error), collector creation aborts and the wrapped error is returned. This means the memory collector cannot be initialized because a fundamental kernel value is unavailable.","triggerScenarios":"Instantiating the memory collector on a BSD kernel where the vm.stats.vm.v_page_size MIB does not exist (e.g. non-FreeBSD/DragonFly kernels reaching this file via build tags) or where sysctl access is denied to the running user.","commonSituations":"Running node_exporter in a jail or sandbox that restricts vm.* sysctls; porting/building for a BSD variant lacking the vm.stats tree; kernel version changes renaming MIBs.","solutions":["Run node_exporter as a user permitted to read vm.stats.vm.v_page_size (verify: `sysctl vm.stats.vm.v_page_size`)","Confirm the target OS actually exposes this MIB; if running a non-FreeBSD/DragonFly BSD, use the platform-appropriate build","Check jail/sandbox settings (security.jail.* sysctls) to allow vm.* sysctls inside the jail","Upgrade node_exporter in case the MIB handling changed for your kernel version"],"exampleFix":"// before\nsize, err := unix.SysctlUint32(\"vm.stats.vm.v_page_size\")\nif err != nil {\n\treturn nil, fmt.Errorf(\"sysctl(vm.stats.vm.v_page_size) failed: %w\", err)\n}\n// after (caller-side verification before deployment)\n// $ sysctl vm.stats.vm.v_page_size  -> must print a value; otherwise fix\n// permissions or OS choice before starting node_exporter","handlingStrategy":"validation","validationCode":"// run before starting the exporter\nif ! sysctl -n vm.stats.vm.v_page_size >/dev/null 2>&1; then\n  echo 'vm.stats.vm.v_page_size unavailable - memory collector will fail'\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"c, err := NewMemoryCollector(logger)\nif err != nil {\n\tlogger.Error(\"memory collector disabled\", \"err\", err)\n\t// register remaining collectors and continue\n}","preventionTips":["Verify required sysctls exist on the target kernel before deployment","Avoid restricting vm.* sysctls in jails hosting the exporter","Rebuild the exporter on the target OS/branch"],"tags":["freebsd","sysctl","memory","collector-init"],"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"}