MCPcopy
hub / github.com/prometheus/node_exporter / Update

Method Update

collector/btrfs_linux.go:55–77  ·  view source on GitHub ↗

Update retrieves and exports Btrfs statistics. It implements Collector.

(ch chan<- prometheus.Metric)

Source from the content-addressed store, hash-verified

53// Update retrieves and exports Btrfs statistics.
54// It implements Collector.
55func (c *btrfsCollector) Update(ch chan<- prometheus.Metric) error {
56 stats, err := c.fs.Stats()
57 if err != nil {
58 return fmt.Errorf("failed to retrieve Btrfs stats from procfs: %w", err)
59 }
60
61 ioctlStatsMap, err := c.getIoctlStats()
62 if err != nil {
63 c.logger.Debug(
64 "Error querying btrfs device stats with ioctl",
65 "err", err)
66 ioctlStatsMap = make(map[string]*btrfsIoctlFsStats)
67 }
68
69 for _, s := range stats {
70 // match up procfs and ioctl info by filesystem UUID (without dashes)
71 var fsUUID = strings.ReplaceAll(s.UUID, "-", "")
72 ioctlStats := ioctlStatsMap[fsUUID]
73 c.updateBtrfsStats(ch, s, ioctlStats)
74 }
75
76 return nil
77}
78
79type btrfsIoctlFsDevStats struct {
80 path string

Callers

nothing calls this directly

Calls 3

getIoctlStatsMethod · 0.95
updateBtrfsStatsMethod · 0.95
StatsMethod · 0.65

Tested by

no test coverage detected