Skip to content

Commit

Permalink
FIX: use sysfs to determine actual sector size for each disk
Browse files Browse the repository at this point in the history
Signed-off-by: Vasilii Alferov <vasilii@cloudflare.com>
  • Loading branch information
dukelion committed Mar 19, 2021
1 parent e026f0f commit 54c2ed0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions collector/diskstats_sysfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ type sysfsDiskCollector struct {
}

func (m *metric) mustNewConstMetric() prometheus.Metric {
switch conv := m.Desc.Conv; conv {
case Ms:
m.Value = m.Value / 1000.0
case Sectors:
m.Value = m.Value * DefaultSectorSize
}
promMetric := prometheus.MustNewConstMetric(
prometheus.NewDesc(
prometheus.BuildFQName(namespace, diskSubsystem, m.Desc.Name),
Expand Down Expand Up @@ -413,6 +407,13 @@ func (c *sysfsDiskCollector) getDeviceStats(d *dmDevice) ([]metric, error) {
break
}

switch conv := metricDescs[i].Conv; conv {
case Ms:
v = v / 1000.0
case Sectors:
v = v * d.SectorSize
}

m = append(m, metric{
Desc: &metricDescs[i],
Value: v,
Expand Down

0 comments on commit 54c2ed0

Please sign in to comment.