prometheus/node_exporter · error

getmntinfo() failed

Error message

getmntinfo() failed

What it means

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.

Solutions

  1. Check host/process memory and rlimits — getmntinfo allocates the statfs array internally
  2. Verify 'mount' output on the host is non-empty and the process is not jailed without filesystem visibility
  3. Upgrade/rebuild node_exporter for your BSD release if libc behavior differs
  4. Disable the filesystem collector on hosts where mount enumeration is impossible
Defensive patterns

Strategy: try-catch

Try / catch

stats, err := c.GetStats()
if err != nil {
    if strings.Contains(err.Error(), "getmntinfo() failed") {
        c.logger.Warn("mount enumeration failed; skipping filesystem metrics", "err", err)
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prometheus/node_exporter@17ddd77c59 (2026-09-07). Data as JSON: /api/errors/602befb8a9558a8e. Report an issue: GitHub.

Appendix: source

Thrown at collector/filesystem_bsd.go:42

#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#include <stdio.h>
*/
import "C"

const (
	defMountPointsExcluded = "^/(dev)($|/)"
	defFSTypesExcluded     = "^devfs$"
	readOnly               = 0x1 // MNT_RDONLY
)

// Expose filesystem fullness.
func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
	var mntbuf *C.struct_statfs
	count := C.getmntinfo(&mntbuf, C.MNT_NOWAIT)
	if count == 0 {
		return nil, errors.New("getmntinfo() failed")
	}

	mnt := (*[1 << 20]C.struct_statfs)(unsafe.Pointer(mntbuf))
	stats = []filesystemStats{}
	for i := 0; i < int(count); i++ {
		mountpoint := C.GoString(&mnt[i].f_mntonname[0])
		if c.mountPointFilter.ignored(mountpoint) {
			c.logger.Debug("Ignoring mount point", "mountpoint", mountpoint)
			continue
		}

		device := C.GoString(&mnt[i].f_mntfromname[0])
		fstype := C.GoString(&mnt[i].f_fstypename[0])
		if c.fsTypeFilter.ignored(fstype) {
			c.logger.Debug("Ignoring fs type", "type", fstype)
			continue
		}

View on GitHub (pinned to 17ddd77c59)