{"record":{"id":"2f004a8dd6c7dca7","repo":"prometheus/node_exporter","slug":"host-processor-info-error-d","errorCode":null,"errorMessage":"host_processor_info error=%d","messagePattern":"host_processor_info error=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/cpu_darwin.go","lineNumber":84,"sourceCode":"\t\tlogger: logger,\n\t}, nil\n}\n\nfunc (c *statCollector) Update(ch chan<- prometheus.Metric) error {\n\tvar (\n\t\tcount   C.mach_msg_type_number_t\n\t\tcpuload *C.processor_cpu_load_info_data_t\n\t\tncpu    C.natural_t\n\t)\n\n\tstatus := C.host_processor_info(C.host_t(C.mach_host_self()),\n\t\tC.PROCESSOR_CPU_LOAD_INFO,\n\t\t&ncpu,\n\t\t(*C.processor_info_array_t)(unsafe.Pointer(&cpuload)),\n\t\t&count)\n\n\tif status != C.KERN_SUCCESS {\n\t\treturn fmt.Errorf(\"host_processor_info error=%d\", status)\n\t}\n\n\t// jump through some cgo casting hoops and ensure we properly free\n\t// the memory that cpuload points to\n\ttarget := C.vm_map_t(C.mach_task_self_)\n\taddress := C.vm_address_t(uintptr(unsafe.Pointer(cpuload)))\n\tdefer C.vm_deallocate(target, address, C.vm_size_t(ncpu))\n\n\t// the body of struct processor_cpu_load_info\n\t// aka processor_cpu_load_info_data_t\n\tvar cpuTicks [C.CPU_STATE_MAX]uint32\n\n\t// copy the cpuload array to a []byte buffer\n\t// where we can binary.Read the data\n\tsize := int(ncpu) * binary.Size(cpuTicks)\n\tbuf := (*[1 << 30]byte)(unsafe.Pointer(cpuload))[:size:size]\n\n\tbbuf := bytes.NewBuffer(buf)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/cpu_darwin.go#L66-L102","documentation":"On macOS the CPU collector queries per-CPU load via the Mach host_processor_info call. A non-KERN_SUCCESS return status means the Mach kernel refused or failed the request; the raw kernel status code is embedded in the message so the specific reason (privilege, invalid host, resource shortage) can be identified.","triggerScenarios":"C.host_processor_info(host, PROCESSOR_CPU_LOAD_INFO, ...) returns a status other than KERN_SUCCESS during the cpu collector's Update().","commonSituations":"Sandboxed execution (App Sandbox/seccomp-like profiles) denying Mach host ports; running under environments with restricted task ports (e.g. hardened macOS, containers runningDarwin-side); kernel resource exhaustion.","solutions":["Run the exporter outside of sandboxed/restricted environments so it can access Mach host information","Check the embedded status code to identify the Mach failure (e.g. KERN_INVALID_ARGUMENT vs privilege issues)","If Mach access cannot be granted, disable the cpu collector on macOS"],"exampleFix":"// before\nsandbox-exec ... node_exporter  # host_processor_info denied\n// after\nrun node_exporter as a normal launchd service without sandbox restrictions","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := cpu.Update(ch); err != nil {\n    if strings.Contains(err.Error(), \"host_processor_info error=\") {\n        // likely sandbox/privilege issue — do not hot-retry\n        log.Warn(\"mach host info unavailable; check sandbox\", \"err\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Run the exporter unsandboxed (plain launchd service) on macOS","Avoid embedding node_exporter in App-Sandboxed helpers","Inspect the embedded status code when troubleshooting Mach denials"],"tags":["darwin","cpu","mach"],"backgroundTag":"mach-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"}