Skip to content

Commit

Permalink
Should sanitize in caller, to simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
astj committed Oct 5, 2016
1 parent c5750a6 commit 28b41f0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions metrics/linux/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ func parseDiskStats(out []byte, mapping map[string]string) (metrics.Values, erro
diskLogger.Warningf("Failed to parse disk metrics: %s", text)
continue
}
device := util.SanitizeMetricKey(cols[2])
device := cols[2]
values := cols[3:]

if len(values) != len(diskMetricsNames) {
diskLogger.Warningf("Failed to parse disk metrics: %s", device)
break
}

deviceLabel := device
deviceLabel := util.SanitizeMetricKey(device)
mountpoint, exists := mapping[device]
if exists {
deviceLabel = mountpoint
deviceLabel = util.SanitizeMetricKey(mountpoint)
}

deviceResult := make(map[string]float64)
Expand All @@ -150,7 +150,7 @@ func parseDiskStats(out []byte, mapping map[string]string) (metrics.Values, erro
return results, nil
}

// Generate the metrics of filesystems
// mapping from device name (like 'svda1') to mountpoint (like '/tmp')
func getDeviceNameMapping() (map[string]string, error) {
filesystems, err := util.CollectDfValues()
if err != nil {
Expand All @@ -160,9 +160,7 @@ func getDeviceNameMapping() (map[string]string, error) {
for _, dfs := range filesystems {
name := dfs.Name
if device := strings.TrimPrefix(name, "/dev/"); name != device {
mountpointLabel := util.SanitizeMetricKey(dfs.Mounted)
deviceName := util.SanitizeMetricKey(device)
ret[deviceName] = mountpointLabel
ret[device] = dfs.Mounted
}
}
return ret, nil
Expand Down

0 comments on commit 28b41f0

Please sign in to comment.