Skip to content

Commit

Permalink
Add mountpoint to mountstats collector.
Browse files Browse the repository at this point in the history
This is useful for Hammerspace where the same 'device' may be mounted
via the same protocol to differing locations, but is actually still a
unique mount.
  • Loading branch information
dsnt02518 committed Apr 27, 2023
1 parent d31af1d commit e0055e2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions collector/mountstats_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type nfsDeviceIdentifier struct {
Device string
Protocol string
MountAddress string
MountPoint string
}

func init() {
Expand All @@ -128,8 +129,8 @@ func NewMountStatsCollector(logger log.Logger) (Collector, error) {
)

var (
labels = []string{"export", "protocol", "mountaddr"}
opLabels = []string{"export", "protocol", "mountaddr", "operation"}
labels = []string{"export", "protocol", "mountaddr", "mountpoint"}
opLabels = []string{"export", "protocol", "mountaddr", "mountpoint", "operation"}
)

return &mountStatsCollector{
Expand Down Expand Up @@ -538,22 +539,22 @@ func (c *mountStatsCollector) Update(ch chan<- prometheus.Metric) error {
mountAddress = miStats.SuperOptions["addr"]
}

deviceIdentifier := nfsDeviceIdentifier{m.Device, stats.Transport.Protocol, mountAddress}
deviceIdentifier := nfsDeviceIdentifier{m.Device, stats.Transport.Protocol, mountAddress, m.Mount}
i := deviceList[deviceIdentifier]
if i {
level.Debug(c.logger).Log("msg", "Skipping duplicate device entry", "device", deviceIdentifier)
continue
}

deviceList[deviceIdentifier] = true
c.updateNFSStats(ch, stats, m.Device, stats.Transport.Protocol, mountAddress)
c.updateNFSStats(ch, stats, m.Device, stats.Transport.Protocol, mountAddress, m.Mount)
}

return nil
}

func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, s *procfs.MountStatsNFS, export, protocol, mountAddress string) {
labelValues := []string{export, protocol, mountAddress}
func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, s *procfs.MountStatsNFS, export, protocol, mountAddress string, mountPoint string) {
labelValues := []string{export, protocol, mountAddress, mountPoint}
ch <- prometheus.MustNewConstMetric(
c.NFSAgeSecondsTotal,
prometheus.CounterValue,
Expand Down Expand Up @@ -688,7 +689,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, s *pro
)

for _, op := range s.Operations {
opLabelValues := []string{export, protocol, mountAddress, op.Operation}
opLabelValues := []string{export, protocol, mountAddress, mountPoint, op.Operation}

ch <- prometheus.MustNewConstMetric(
c.NFSOperationsRequestsTotal,
Expand Down

0 comments on commit e0055e2

Please sign in to comment.