Update retrieves and exports Btrfs statistics. It implements Collector.
(ch chan<- prometheus.Metric)
| 53 | // Update retrieves and exports Btrfs statistics. |
| 54 | // It implements Collector. |
| 55 | func (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 | |
| 79 | type btrfsIoctlFsDevStats struct { |
| 80 | path string |
nothing calls this directly
no test coverage detected