diff --git a/pkg/plugin/linuxutil/ethtool_stats_linux.go b/pkg/plugin/linuxutil/ethtool_stats_linux.go index bb38e45b2f..19abe8a5ab 100644 --- a/pkg/plugin/linuxutil/ethtool_stats_linux.go +++ b/pkg/plugin/linuxutil/ethtool_stats_linux.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/retina/pkg/log" "github.com/microsoft/retina/pkg/metrics" + "github.com/microsoft/retina/pkg/utils" "github.com/safchain/ethtool" "go.uber.org/zap" ) @@ -60,7 +61,7 @@ func (er *EthtoolReader) readInterfaceStats() error { defer er.ethHandle.Close() er.data = &EthtoolStats{ - stats: make(map[string]map[string]uint64), + stats: make(map[string]uint64), } for _, i := range ifaces { @@ -83,12 +84,12 @@ func (er *EthtoolReader) readInterfaceStats() error { continue } - er.data.stats[i.Name] = make(map[string]uint64) tempMap := er.processStats(ifaceStats) - er.data.stats[i.Name] = tempMap + for key, value := range tempMap { + er.data.stats[key] += value + } er.l.Debug("Processed ethtool Stats ", zap.String("ifacename", i.Name)) - } return nil @@ -114,10 +115,8 @@ func (er *EthtoolReader) processStats(ifaceStats map[string]uint64) map[string]u func (er *EthtoolReader) updateMetrics() { // update metrics section - // retrive interfacename and statname from ethStats - for ifName, stats := range er.data.stats { - for statName, statVal := range stats { - metrics.InterfaceStatsGauge.WithLabelValues(ifName, statName).Set(float64(statVal)) - } + // retrive statname from ethStats + for statName, statVal := range er.data.stats { + metrics.InterfaceStatsGauge.WithLabelValues(utils.InterfaceNameConstant, statName).Set(float64(statVal)) } } diff --git a/pkg/plugin/linuxutil/types_linux.go b/pkg/plugin/linuxutil/types_linux.go index 27f7b40dc7..7eda664b3c 100644 --- a/pkg/plugin/linuxutil/types_linux.go +++ b/pkg/plugin/linuxutil/types_linux.go @@ -35,7 +35,7 @@ var netstatCuratedKeys = map[string]struct{}{ "DataCsumErr": {}, "AddAddrDrop": {}, "RmAddrDrop": {}, - "TCPTimeouts": {}, + "TCPTimeouts": {}, "TCPLossProbes": {}, "TCPLostRetransmit": {}, } @@ -95,8 +95,8 @@ type NetstatOpts struct { } type EthtoolStats struct { - // Stats by interface name and stat name - stats map[string]map[string]uint64 + // Stats by name + stats map[string]uint64 } type EthtoolOpts struct { diff --git a/pkg/utils/attr_utils.go b/pkg/utils/attr_utils.go index 9d102dc9d7..6826db74c9 100644 --- a/pkg/utils/attr_utils.go +++ b/pkg/utils/attr_utils.go @@ -34,21 +34,22 @@ var ( remoteNodeKey = attribute.Key("remote_node") // todo move to attributes pkg? - Type = "type" - Reason = "reason" - Direction = "direction" - SourceNodeName = "source_node_name" - TargetNodeName = "target_node_name" - State = "state" - Address = "address" - Port = "port" - StatName = "statistic_name" - InterfaceName = "interface_name" - Flag = "flag" - Endpoint = "endpoint" - AclRule = "aclrule" - Active = "ACTIVE" - Device = "device" + Type = "type" + Reason = "reason" + Direction = "direction" + SourceNodeName = "source_node_name" + TargetNodeName = "target_node_name" + State = "state" + Address = "address" + Port = "port" + StatName = "statistic_name" + InterfaceName = "interface_name" + InterfaceNameConstant = "all_interfaces" + Flag = "flag" + Endpoint = "endpoint" + AclRule = "aclrule" + Active = "ACTIVE" + Device = "device" // TCP Connection Statistic Names ResetCount = "ResetCount"