func()

in image/resources/knfsd-metrics-agent/internal/mounts/scraper.go [135:168]


func (s *mountScraper) aggregateNFSStats() (nfsStatsAggregator, error) {
	ids, err := s.findNFSDeviceIDs()
	if err != nil {
		return nil, err
	}

	mounts, err := s.p.MountStats()
	if err != nil {
		return nil, err
	}

	agg := make(nfsStatsAggregator)
	for _, m := range mounts {
		if !isNFS(m.Type) {
			continue
		}

		blkid := ids[m.Mount]
		if blkid == "" {
			// This can happen if the mounts change between scraping mountinfo
			// and scraping mountstats. For example auto-mounting a nested
			// mount.
			//
			// Ignore the mount for this scrape, the block device ID should be
			// present on the next scrape. Without the block device ID it's not
			// possible to de-duplicate the io_stats.
			s.logger.Debug("Skipping mount, block device ID not found", zap.String("mount", m.Mount))
			continue
		}

		agg.AddMount(blkid, m)
	}
	return agg, nil
}