mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2026-05-06 21:57:29 +02:00
Add bandwidth metrics for ib_total and ib_total_pkts
This commit is contained in:
@@ -202,7 +202,9 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMess
|
|||||||
for i := range m.info {
|
for i := range m.info {
|
||||||
info := &m.info[i]
|
info := &m.info[i]
|
||||||
|
|
||||||
var ib_total, ib_total_pkts int64
|
var ib_total, ib_total_last_state,
|
||||||
|
ib_total_pkts, ib_total_pkts_last_state int64
|
||||||
|
var ib_total_last_state_available, ib_total_pkts_last_state_available bool
|
||||||
for i := range info.portCounterFiles {
|
for i := range info.portCounterFiles {
|
||||||
counterDef := &info.portCounterFiles[i]
|
counterDef := &info.portCounterFiles[i]
|
||||||
|
|
||||||
@@ -232,14 +234,7 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMess
|
|||||||
|
|
||||||
// Send absolut values
|
// Send absolut values
|
||||||
if m.config.SendAbsoluteValues {
|
if m.config.SendAbsoluteValues {
|
||||||
if y, err := lp.NewMessage(
|
if y, err := lp.NewMetric(counterDef.name, info.tagSet, m.meta, counterDef.currentState, now); err == nil {
|
||||||
counterDef.name,
|
|
||||||
info.tagSet,
|
|
||||||
m.meta,
|
|
||||||
map[string]any{
|
|
||||||
"value": counterDef.currentState,
|
|
||||||
},
|
|
||||||
now); err == nil {
|
|
||||||
y.AddMeta("unit", counterDef.unit)
|
y.AddMeta("unit", counterDef.unit)
|
||||||
output <- y
|
output <- y
|
||||||
}
|
}
|
||||||
@@ -249,17 +244,21 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMess
|
|||||||
if m.config.SendDerivedValues {
|
if m.config.SendDerivedValues {
|
||||||
if counterDef.lastState >= 0 {
|
if counterDef.lastState >= 0 {
|
||||||
rate := float64((counterDef.currentState - counterDef.lastState)) / timeDiff
|
rate := float64((counterDef.currentState - counterDef.lastState)) / timeDiff
|
||||||
if y, err := lp.NewMessage(
|
if y, err := lp.NewMetric(counterDef.name+"_bw", info.tagSet, m.meta, rate, now); err == nil {
|
||||||
counterDef.name+"_bw",
|
|
||||||
info.tagSet,
|
|
||||||
m.meta,
|
|
||||||
map[string]any{
|
|
||||||
"value": rate,
|
|
||||||
},
|
|
||||||
now); err == nil {
|
|
||||||
y.AddMeta("unit", counterDef.unit+"/sec")
|
y.AddMeta("unit", counterDef.unit+"/sec")
|
||||||
output <- y
|
output <- y
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sum up total values of last state
|
||||||
|
if m.config.SendTotalValues {
|
||||||
|
switch {
|
||||||
|
case counterDef.addToIBTotal:
|
||||||
|
ib_total_last_state += counterDef.lastState
|
||||||
|
ib_total_last_state_available = true
|
||||||
|
case counterDef.addToIBTotalPkgs:
|
||||||
|
ib_total_pkts_last_state += counterDef.lastState
|
||||||
|
ib_total_pkts_last_state_available = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
counterDef.lastState = counterDef.currentState
|
counterDef.lastState = counterDef.currentState
|
||||||
@@ -278,29 +277,31 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMess
|
|||||||
|
|
||||||
// Send total values
|
// Send total values
|
||||||
if m.config.SendTotalValues {
|
if m.config.SendTotalValues {
|
||||||
if y, err := lp.NewMessage(
|
if y, err := lp.NewMetric("ib_total", info.tagSet, m.meta, ib_total, now); err == nil {
|
||||||
"ib_total",
|
|
||||||
info.tagSet,
|
|
||||||
m.meta,
|
|
||||||
map[string]any{
|
|
||||||
"value": ib_total,
|
|
||||||
},
|
|
||||||
now); err == nil {
|
|
||||||
y.AddMeta("unit", "bytes")
|
y.AddMeta("unit", "bytes")
|
||||||
output <- y
|
output <- y
|
||||||
}
|
}
|
||||||
|
|
||||||
if y, err := lp.NewMessage(
|
if y, err := lp.NewMetric("ib_total_pkts", info.tagSet, m.meta, ib_total_pkts, now); err == nil {
|
||||||
"ib_total_pkts",
|
|
||||||
info.tagSet,
|
|
||||||
m.meta,
|
|
||||||
map[string]any{
|
|
||||||
"value": ib_total_pkts,
|
|
||||||
},
|
|
||||||
now); err == nil {
|
|
||||||
y.AddMeta("unit", "packets")
|
y.AddMeta("unit", "packets")
|
||||||
output <- y
|
output <- y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.config.SendDerivedValues && ib_total_last_state_available {
|
||||||
|
rate := float64((ib_total - ib_total_last_state)) / timeDiff
|
||||||
|
if y, err := lp.NewMetric("ib_total_bw", info.tagSet, m.meta, rate, now); err == nil {
|
||||||
|
y.AddMeta("unit", "bytes/sec")
|
||||||
|
output <- y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.config.SendDerivedValues && ib_total_pkts_last_state_available {
|
||||||
|
rate := float64((ib_total_pkts - ib_total_pkts_last_state)) / timeDiff
|
||||||
|
if y, err := lp.NewMetric("ib_total_pkts_bw", info.tagSet, m.meta, rate, now); err == nil {
|
||||||
|
y.AddMeta("unit", "packets/sec")
|
||||||
|
output <- y
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,5 +41,7 @@ Metrics:
|
|||||||
* `ib_xmit_bw` (if `send_derived_values == true`)
|
* `ib_xmit_bw` (if `send_derived_values == true`)
|
||||||
* `ib_recv_pkts_bw` (if `send_derived_values == true`)
|
* `ib_recv_pkts_bw` (if `send_derived_values == true`)
|
||||||
* `ib_xmit_pkts_bw` (if `send_derived_values == true`)
|
* `ib_xmit_pkts_bw` (if `send_derived_values == true`)
|
||||||
|
* `ib_total_bw` (if `send_total_values == true` and `send_derived_values == true`)
|
||||||
|
* `ib_total_pkts_bw` (if `send_total_values == true` and `send_derived_values == true`)
|
||||||
|
|
||||||
The collector adds a `device` tag to all metrics
|
The collector adds a `device` tag to all metrics
|
||||||
|
|||||||
Reference in New Issue
Block a user