Compute metrics ib_total and ib_total_pkts

This commit is contained in:
Holger Obermaier 2023-08-17 16:46:53 +02:00
parent 41ea9139c6
commit f5d2d27090
2 changed files with 51 additions and 3 deletions

View File

@ -37,6 +37,7 @@ type InfinibandCollector struct {
config struct { config struct {
ExcludeDevices []string `json:"exclude_devices,omitempty"` // IB device to exclude e.g. mlx5_0 ExcludeDevices []string `json:"exclude_devices,omitempty"` // IB device to exclude e.g. mlx5_0
SendAbsoluteValues bool `json:"send_abs_values"` // Send absolut values as read from sys filesystem SendAbsoluteValues bool `json:"send_abs_values"` // Send absolut values as read from sys filesystem
SendTotalValues bool `json:"send_total_values"` // Send computed total values
SendDerivedValues bool `json:"send_derived_values"` // Send derived values e.g. rates SendDerivedValues bool `json:"send_derived_values"` // Send derived values e.g. rates
} }
info []*InfinibandCollectorInfo info []*InfinibandCollectorInfo
@ -171,6 +172,9 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMetr
m.lastTimestamp = now m.lastTimestamp = now
for _, info := range m.info { for _, info := range m.info {
currentState := make(map[string]int64)
for counterName, counterDef := range info.portCounterFiles { for counterName, counterDef := range info.portCounterFiles {
// Read counter file // Read counter file
@ -211,11 +215,52 @@ func (m *InfinibandCollector) Read(interval time.Duration, output chan lp.CCMetr
output <- y output <- y
} }
} }
// Save current state
info.lastState[counterName] = v
}
} }
// Save current state
currentState[counterName] = v
}
// Save current state for use as last state
if m.config.SendDerivedValues {
info.lastState = currentState
}
if m.config.SendAbsoluteValues {
recv, recv_ok := currentState["ib_recv"]
xmit, xmit_ok := currentState["ib_xmit"]
recv_pkts, recv_pkts_ok := currentState["ib_recv_pkts"]
xmit_pkts, xmit_pkts_ok := currentState["ib_xmit_pkts"]
if recv_ok && xmit_ok {
if y, err :=
lp.New(
"ib_total",
info.tagSet,
m.meta,
map[string]interface{}{
"value": recv + xmit,
},
now); err == nil {
y.AddMeta("unit", "bytes")
output <- y
}
}
if recv_pkts_ok && xmit_pkts_ok {
if y, err :=
lp.New(
"ib_total_pkts",
info.tagSet,
m.meta,
map[string]interface{}{
"value": recv_pkts + xmit_pkts,
},
now); err == nil {
y.AddMeta("unit", "packets")
output <- y
}
}
}
} }
} }

View File

@ -17,13 +17,16 @@ LID file (`/sys/class/infiniband/<dev>/ports/<port>/lid`)
The devices can be filtered with the `exclude_devices` option in the configuration. The devices can be filtered with the `exclude_devices` option in the configuration.
For each found LID the collector reads data through the sysfs files below `/sys/class/infiniband/<device>`. For each found LID the collector reads data through the sysfs files below `/sys/class/infiniband/<device>`. (See: <https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-class-infiniband>)
Metrics: Metrics:
* `ib_recv` * `ib_recv`
* `ib_xmit` * `ib_xmit`
* `ib_recv_pkts` * `ib_recv_pkts`
* `ib_xmit_pkts` * `ib_xmit_pkts`
* `ib_total = ib_recv + ib_xmit` (if `send_total_values == true`)
* `ib_total_pkts = ib_recv_pkts + ib_xmit_pkts` (if `send_total_values == true`)
* `ib_recv_bw` (if `send_derived_values == true`) * `ib_recv_bw` (if `send_derived_values == true`)
* `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`)