mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-14 00:55:54 +02:00
Refactor: Avoid redundant tag maps
This commit is contained in:
parent
c0f59d7d90
commit
0bea1d53a0
@ -104,34 +104,39 @@ func (m *NetstatCollector) Init(config json.RawMessage) error {
|
|||||||
|
|
||||||
// Check if device is a included device
|
// Check if device is a included device
|
||||||
if _, ok := stringArrayContains(m.config.IncludeDevices, dev); ok {
|
if _, ok := stringArrayContains(m.config.IncludeDevices, dev); ok {
|
||||||
|
tags_unit_byte := map[string]string{"device": dev, "type": "node", "unit": "bytes"}
|
||||||
|
tags_unit_byte_per_sec := map[string]string{"device": dev, "type": "node", "unit": "bytes/sec"}
|
||||||
|
tags_unit_pkts := map[string]string{"device": dev, "type": "node", "unit": "packets"}
|
||||||
|
tags_unit_pkts_per_sec := map[string]string{"device": dev, "type": "node", "unit": "packets/sec"}
|
||||||
|
|
||||||
m.matches[dev] = []NetstatCollectorMetric{
|
m.matches[dev] = []NetstatCollectorMetric{
|
||||||
{
|
{
|
||||||
name: "net_bytes_in",
|
name: "net_bytes_in",
|
||||||
index: fieldReceiveBytes,
|
index: fieldReceiveBytes,
|
||||||
lastValue: 0,
|
lastValue: 0,
|
||||||
tags: map[string]string{"device": dev, "type": "node", "unit": "bytes"},
|
tags: tags_unit_byte,
|
||||||
rate_tags: map[string]string{"device": dev, "type": "node", "unit": "bytes/sec"},
|
rate_tags: tags_unit_byte_per_sec,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "net_pkts_in",
|
name: "net_pkts_in",
|
||||||
index: fieldReceivePackets,
|
index: fieldReceivePackets,
|
||||||
lastValue: 0,
|
lastValue: 0,
|
||||||
tags: map[string]string{"device": dev, "type": "node", "unit": "packets"},
|
tags: tags_unit_pkts,
|
||||||
rate_tags: map[string]string{"device": dev, "type": "node", "unit": "packets/sec"},
|
rate_tags: tags_unit_pkts_per_sec,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "net_bytes_out",
|
name: "net_bytes_out",
|
||||||
index: fieldTransmitBytes,
|
index: fieldTransmitBytes,
|
||||||
lastValue: 0,
|
lastValue: 0,
|
||||||
tags: map[string]string{"device": dev, "type": "node", "unit": "bytes"},
|
tags: tags_unit_byte,
|
||||||
rate_tags: map[string]string{"device": dev, "type": "node", "unit": "bytes/sec"},
|
rate_tags: tags_unit_byte_per_sec,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "net_pkts_out",
|
name: "net_pkts_out",
|
||||||
index: fieldTransmitPackets,
|
index: fieldTransmitPackets,
|
||||||
lastValue: 0,
|
lastValue: 0,
|
||||||
tags: map[string]string{"device": dev, "type": "node", "unit": "packets"},
|
tags: tags_unit_pkts,
|
||||||
rate_tags: map[string]string{"device": dev, "type": "node", "unit": "packets/sec"},
|
rate_tags: tags_unit_pkts_per_sec,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user