{"record":{"id":"63920d8cebb14e26","repo":"prometheus/node_exporter","slug":"unable-to-list-all-processes-w","errorCode":null,"errorMessage":"unable to list all processes: %w","messagePattern":"unable to list all processes: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/processes_linux.go","lineNumber":119,"sourceCode":"\n\tfor state := range threadStates {\n\t\tch <- prometheus.MustNewConstMetric(c.threadsState, prometheus.GaugeValue, float64(threadStates[state]), state)\n\t}\n\n\tpidM, err := readUintFromFile(procFilePath(\"sys/kernel/pid_max\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to retrieve limit number of maximum pids allowed: %w\", err)\n\t}\n\tch <- prometheus.MustNewConstMetric(c.pidUsed, prometheus.GaugeValue, float64(pids))\n\tch <- prometheus.MustNewConstMetric(c.pidMax, prometheus.GaugeValue, float64(pidM))\n\n\treturn nil\n}\n\nfunc (c *processCollector) getAllocatedThreads() (int, map[string]int32, int, map[string]int32, error) {\n\tp, err := c.fs.AllProcs()\n\tif err != nil {\n\t\treturn 0, nil, 0, nil, fmt.Errorf(\"unable to list all processes: %w\", err)\n\t}\n\tpids := 0\n\tthread := 0\n\tprocStates := make(map[string]int32)\n\tthreadStates := make(map[string]int32)\n\n\tfor _, pid := range p {\n\t\tstat, err := pid.Stat()\n\t\tif err != nil {\n\t\t\t// PIDs can vanish between getting the list and getting stats.\n\t\t\tif c.isIgnoredError(err) {\n\t\t\t\tc.logger.Debug(\"file not found when retrieving stats for pid\", \"pid\", pid.PID, \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tc.logger.Debug(\"error reading stat for pid\", \"pid\", pid.PID, \"err\", err)\n\t\t\treturn 0, nil, 0, nil, fmt.Errorf(\"error reading stat for pid %d: %w\", pid.PID, err)\n\t\t}\n\t\tpids++","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/processes_linux.go#L101-L137","documentation":"getAllocatedThreads calls c.fs.AllProcs() to enumerate /proc and wraps any error as 'unable to list all processes'. AllProcs reads the /proc directory listing (and related stat data), so this indicates the process table could not be enumerated at all.","triggerScenarios":"fs.AllProcs() returns an error during Update()'s call to getAllocatedThreads — the procfs handle points to an unreadable or non-proc directory, or a directory read failed with an error other than a missing entry.","commonSituations":"--path.procfs pointing at a wrong or empty directory (e.g. stale fixture path); procfs mounted with hidepid and restricted readdir; EPERM/EACCES on directory traversal for the exporter user.","solutions":["Inspect the wrapped cause; if it is a permission error, fix filesystem permissions for the exporter user on the procfs path.","Verify --path.procfs points to a live procfs mount containing numeric PID directories (ls /proc | grep -E '^[0-9]+$').","In tests, ensure fixtures are unpacked (make test) and the fs handle is built from the fixture path.","Retry the scrape; a transient readdir failure (e.g. during heavy pid churn) often resolves on the next scrape."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before constructing/using the collector\nentries, err := os.ReadDir(*procPath)\nif err != nil {\n    log.Printf(\"cannot list %s: %v\", *procPath, err)\n} else {\n    numeric := 0\n    for _, e := range entries {\n        if _, err := strconv.Atoi(e.Name()); err == nil {\n            numeric++\n        }\n    }\n    if numeric == 0 {\n        log.Printf(\"%s has no pid directories; is it a real procfs?\", *procPath)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := c.Update(ch); err != nil {\n    if strings.Contains(err.Error(), \"unable to list all processes\") {\n        log.Printf(\"procfs enumeration broken, check --path.procfs and permissions: %v\", err)\n    }\n}","preventionTips":["Point --path.procfs at a live procfs mount containing numeric PID directories.","Avoid hidepid configurations that block readdir for the exporter user.","Unpack test fixtures (make test) before running tests that use fixture procfs paths.","Alert on consecutive scrape failures rather than a single failure."],"tags":["linux","procfs","processes","readdir","node-exporter"],"backgroundTag":"file-read-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"}