{"record":{"id":"87d996930293acca","repo":"prometheus/node_exporter","slug":"failed-to-open-sysfs-w-87d996","errorCode":null,"errorMessage":"failed to open sysfs: %w","messagePattern":"failed to open sysfs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"collector/ethtool_linux.go","lineNumber":89,"sourceCode":"\ntype ethtoolCollector struct {\n\tfs             sysfs.FS\n\tentries        map[string]*prometheus.Desc\n\tentriesMutex   sync.Mutex\n\tethtool        Ethtool\n\tdeviceFilter   deviceFilter\n\tinfoDesc       *prometheus.Desc\n\tmetricsPattern *regexp.Regexp\n\tlogger         *slog.Logger\n}\n\n// makeEthtoolCollector is the internal constructor for EthtoolCollector.\n// This allows NewEthtoolTestCollector to override its .ethtool interface\n// for testing.\nfunc makeEthtoolCollector(logger *slog.Logger) (*ethtoolCollector, error) {\n\tfs, err := sysfs.NewFS(*sysPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open sysfs: %w\", err)\n\t}\n\n\te, err := ethtool.NewEthtool()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to initialize ethtool library: %w\", err)\n\t}\n\n\tif *ethtoolDeviceInclude != \"\" {\n\t\tlogger.Info(\"Parsed flag --collector.ethtool.device-include\", \"flag\", *ethtoolDeviceInclude)\n\t}\n\tif *ethtoolDeviceExclude != \"\" {\n\t\tlogger.Info(\"Parsed flag --collector.ethtool.device-exclude\", \"flag\", *ethtoolDeviceExclude)\n\t}\n\tif *ethtoolIncludedMetrics != \"\" {\n\t\tlogger.Info(\"Parsed flag --collector.ethtool.metrics-include\", \"flag\", *ethtoolIncludedMetrics)\n\t}\n\n\t// Pre-populate some common ethtool metrics.","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/ethtool_linux.go#L71-L107","documentation":"makeEthtoolCollector, the internal constructor used by NewEthtoolCollector (and the test constructor), first opens sysfs via sysfs.NewFS(*sysPath) (default /sys). If that path cannot be opened as a sysfs filesystem, the constructor returns 'failed to open sysfs' and node_exporter fails to create the ethtool collector. Like the procfs counterpart, this is nearly always a bad --path.sysfs flag or missing /sys.","triggerScenarios":"makeEthtoolCollector invoked with --path.sysfs pointing at a nonexistent or non-sysfs directory; environment without /sys mounted.","commonSituations":"Typo in --path.sysfs; minimal containers/chroots without sysfs; running inside namespaces where sysfs was remounted away; permission restrictions on the mount.","solutions":["Verify the flag: `--path.sysfs=/sys` and that the directory exists (`ls /sys/class/net`).","Mount sysfs in the container or point the flag at the real sysfs location.","Check mount options/permissions; the wrapped %w error names the precise OS cause.","Disable the ethtool collector (--collector.ethtool=false) if sysfs is unavailable by design."],"exampleFix":"// before: wrong path\nnode_exporter --path.sysfs=/syss\n\n// after\nnode_exporter --path.sysfs=/sys","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction sysfsLooksValid(p = '/sys') {\n  return fs.existsSync(p) && fs.statSync(p).isDirectory() && fs.existsSync(`${p}/class/net`);\n}\nif (!sysfsLooksValid()) console.error('--path.sysfs target invalid; ethtool collector will fail to start');","typeGuard":null,"tryCatchPattern":"try {\n  await startNodeExporter({ sysPath: '/sys' });\n} catch (e) {\n  if (String(e).includes('failed to open sysfs')) {\n    console.error('Bad --path.sysfs; verify /sys is mounted and the flag is correct');\n  } else throw e;\n}","preventionTips":["Pass --path.sysfs=/sys explicitly in container/deployment manifests.","Ensure sysfs is mounted (privileged or proper volume mount) in containers.","Validate flag values with a startup smoke test."],"tags":["linux","sysfs","ethtool","configuration","startup"],"backgroundTag":"invalid-config-value","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"}