{"record":{"id":"602befb8a9558a8e","repo":"prometheus/node_exporter","slug":"getmntinfo-failed","errorCode":null,"errorMessage":"getmntinfo() failed","messagePattern":"getmntinfo\\(\\) failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/filesystem_bsd.go","lineNumber":42,"sourceCode":"#include <sys/param.h>\n#include <sys/ucred.h>\n#include <sys/mount.h>\n#include <stdio.h>\n*/\nimport \"C\"\n\nconst (\n\tdefMountPointsExcluded = \"^/(dev)($|/)\"\n\tdefFSTypesExcluded     = \"^devfs$\"\n\treadOnly               = 0x1 // MNT_RDONLY\n)\n\n// Expose filesystem fullness.\nfunc (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {\n\tvar mntbuf *C.struct_statfs\n\tcount := C.getmntinfo(&mntbuf, C.MNT_NOWAIT)\n\tif count == 0 {\n\t\treturn nil, errors.New(\"getmntinfo() failed\")\n\t}\n\n\tmnt := (*[1 << 20]C.struct_statfs)(unsafe.Pointer(mntbuf))\n\tstats = []filesystemStats{}\n\tfor i := 0; i < int(count); i++ {\n\t\tmountpoint := C.GoString(&mnt[i].f_mntonname[0])\n\t\tif c.mountPointFilter.ignored(mountpoint) {\n\t\t\tc.logger.Debug(\"Ignoring mount point\", \"mountpoint\", mountpoint)\n\t\t\tcontinue\n\t\t}\n\n\t\tdevice := C.GoString(&mnt[i].f_mntfromname[0])\n\t\tfstype := C.GoString(&mnt[i].f_fstypename[0])\n\t\tif c.fsTypeFilter.ignored(fstype) {\n\t\t\tc.logger.Debug(\"Ignoring fs type\", \"type\", fstype)\n\t\t\tcontinue\n\t\t}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/filesystem_bsd.go#L24-L60","documentation":"In filesystem_bsd.go, GetStats calls C.getmntinfo to enumerate mounted filesystems on BSD; a return count of 0 is treated as failure and surfaces as errors.New(\"getmntinfo() failed\"). Without a mount list the filesystem collector cannot produce any metrics for the scrape.","triggerScenarios":"C.getmntinfo(&mntbuf, C.MNT_NOWAIT) returns 0 in filesystemCollector.GetStats — the libc getmntinfo call failed or returned no mount entries, e.g. memory allocation failure inside libc, or genuinely zero mounted filesystems.","commonSituations":"Severe memory pressure inside the exporter process (getmntinfo allocates internally); extremely restricted BSD jails/chroots where mount enumeration is unavailable; a misconfigured container with no mounts visible.","solutions":["Check host/process memory and rlimits — getmntinfo allocates the statfs array internally","Verify 'mount' output on the host is non-empty and the process is not jailed without filesystem visibility","Upgrade/rebuild node_exporter for your BSD release if libc behavior differs","Disable the filesystem collector on hosts where mount enumeration is impossible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"stats, err := c.GetStats()\nif err != nil {\n    if strings.Contains(err.Error(), \"getmntinfo() failed\") {\n        c.logger.Warn(\"mount enumeration failed; skipping filesystem metrics\", \"err\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Check process memory/rlimits — getmntinfo allocates the statfs array internally","Verify 'mount' works for the exporter's user in jails/chroots at deploy time","Disable the filesystem collector where mount enumeration is unavailable","Rebuild node_exporter against the target BSD release's libc"],"tags":["cgo","filesystem","getmntinfo","bsd"],"backgroundTag":"system-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"}