Skip to content

Commit

Permalink
sanitize interface name on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Oct 25, 2017
1 parent 6520645 commit 75317e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions metrics/linux/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/mackerelio/go-osstat/network"
"github.com/mackerelio/golib/logging"
"github.com/mackerelio/mackerel-agent/metrics"
"github.com/mackerelio/mackerel-agent/util"
)

/*
Expand Down Expand Up @@ -73,8 +74,9 @@ func (g *InterfaceGenerator) collectInterfacesValues() (map[string]uint64, error
}
results := make(map[string]uint64, len(networks)*2)
for _, network := range networks {
results["interface."+network.Name+".rxBytes"] = network.RxBytes
results["interface."+network.Name+".txBytes"] = network.TxBytes
name := util.SanitizeMetricKey(network.Name)
results["interface."+name+".rxBytes"] = network.RxBytes
results["interface."+name+".txBytes"] = network.TxBytes
}
return results, nil
}

0 comments on commit 75317e3

Please sign in to comment.