Add network device to metric names to NetstatCollector

This commit is contained in:
Thomas Roehl 2021-03-25 15:54:17 +01:00
parent 0110547b68
commit 5659607993

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
"time" "time"
"log" "log"
"fmt"
) )
const NETSTATFILE = `/proc/net/dev` const NETSTATFILE = `/proc/net/dev`
@ -46,8 +47,7 @@ func (m *NetstatCollector) Read(interval time.Duration){
for i, name := range matches { for i, name := range matches {
v, err := strconv.ParseInt(f[i], 10, 0) v, err := strconv.ParseInt(f[i], 10, 0)
if err == nil { if err == nil {
m.node[fmt.Sprintf("%s_%s", dev, name)] = float64(v) * 1.0e-3
m.node[name] = float64(v) * 1.0e-3
} }
} }
} }