Skip to content

Commit

Permalink
fix: remove duplicate network dashboards (#1314)
Browse files Browse the repository at this point in the history
* fix: remove duplicate network dashboards

Fixes #1306

* fix: remove duplicate network dashboards

Fixes #1306

* fix: remove duplicate network dashboards

Fixes #1306

* fix: remove duplicate network dashboards

Fixes #1306

* fix: remove duplicate network dashboards

Fixes #1306

* fix: remove duplicate network dashboards

Fixes #1306

* fix: add comments

Fixes #1306

* feat: addressed review comments
  • Loading branch information
rahulguptajss authored Sep 28, 2022
1 parent bfa264b commit 6b45932
Show file tree
Hide file tree
Showing 8 changed files with 2,613 additions and 8,026 deletions.
76 changes: 45 additions & 31 deletions cmd/collectors/restperf/plugins/nic/nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin {
return &Nic{AbstractPlugin: p}
}

// Run speed label is reported in bits-per-second and rx/tx is reported as bytes-per-second
func (me *Nic) Run(data *matrix.Matrix) ([]*matrix.Matrix, error) {

var read, write, rx, tx, util matrix.Metric
Expand Down Expand Up @@ -71,50 +72,63 @@ func (me *Nic) Run(data *matrix.Matrix) ([]*matrix.Matrix, error) {
var speed, base int
var s string
var err error

if s = instance.GetLabel("speed"); strings.HasSuffix(s, "M") {
base, err = strconv.Atoi(strings.TrimSuffix(s, "M"))
if err != nil {
s = instance.GetLabel("speed")
if s != "" {
if strings.HasSuffix(s, "M") {
base, err = strconv.Atoi(strings.TrimSuffix(s, "M"))
if err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
} else {
// NIC speed value converted from Mbps to Bps(bytes per second)
speed = base * 125000
me.Logger.Debug().Msgf("converted speed (%s) to numeric (%d)", s, speed)
}
} else if speed, err = strconv.Atoi(s); err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
} else {
// NIC speed value converted from Mbps to Bps(bytes per second)
speed = base * 125000
instance.SetLabel("speed", strconv.Itoa(speed))
me.Logger.Debug().Msgf("converted speed (%s) to numeric (%d)", s, speed)
}
} else if speed, err = strconv.Atoi(s); err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
}

if speed != 0 {
if speed != 0 {

var rxBytes, txBytes, rxPercent, txPercent float64
var rxOk, txOk, passRx, passTx bool
var rxBytes, txBytes, rxPercent, txPercent float64
var rxOk, txOk, passRx, passTx bool

if rxBytes, rxOk, passRx = read.GetValueFloat64(instance); rxOk && passRx {
rxPercent = rxBytes / float64(speed)
err := rx.SetValueFloat64(instance, rxPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
if rxBytes, rxOk, passRx = read.GetValueFloat64(instance); rxOk && passRx {
rxPercent = rxBytes / float64(speed)
err := rx.SetValueFloat64(instance, rxPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
}
}

if txBytes, txOk, passTx = write.GetValueFloat64(instance); txOk && passTx {
txPercent = txBytes / float64(speed)
err := tx.SetValueFloat64(instance, txPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
if txBytes, txOk, passTx = write.GetValueFloat64(instance); txOk && passTx {
txPercent = txBytes / float64(speed)
err := tx.SetValueFloat64(instance, txPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
}
}

if (rxOk || txOk) && (passRx || passTx) {
err := util.SetValueFloat64(instance, math.Max(rxPercent, txPercent))
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
if (rxOk || txOk) && (passRx || passTx) {
err := util.SetValueFloat64(instance, math.Max(rxPercent, txPercent))
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
}
}
}

if s = instance.GetLabel("speed"); strings.HasSuffix(s, "M") {
base, err = strconv.Atoi(strings.TrimSuffix(s, "M"))
if err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
} else {
// NIC speed value converted from Mbps to bps(bits per second)
speed = base * 1_000_000
instance.SetLabel("speed", strconv.Itoa(speed))
me.Logger.Debug().Msgf("converted speed (%s) to numeric (%d)", s, speed)
}
}

// truncate redundant prefix in nic type
if t := instance.GetLabel("type"); strings.HasPrefix(t, "nic_") {
instance.SetLabel("type", strings.TrimPrefix(t, "nic_"))
Expand Down
75 changes: 45 additions & 30 deletions cmd/collectors/zapiperf/plugins/nic/nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func New(p *plugin.AbstractPlugin) plugin.Plugin {
return &Nic{AbstractPlugin: p}
}

// Run speed label is reported in bits-per-second and rx/tx is reported as bytes-per-second
func (me *Nic) Run(data *matrix.Matrix) ([]*matrix.Matrix, error) {

var read, write, rx, tx, util matrix.Metric
Expand Down Expand Up @@ -74,46 +75,60 @@ func (me *Nic) Run(data *matrix.Matrix) ([]*matrix.Matrix, error) {
var s string
var err error

if s = instance.GetLabel("speed"); strings.HasSuffix(s, "M") {
base, err = strconv.Atoi(strings.TrimSuffix(s, "M"))
if err != nil {
s = instance.GetLabel("speed")

if s != "" {
if strings.HasSuffix(s, "M") {
base, err = strconv.Atoi(strings.TrimSuffix(s, "M"))
if err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
} else {
// NIC speed value converted from Mbps to Bps(bytes per second)
speed = base * 125000
me.Logger.Debug().Msgf("converted speed (%s) to Bps numeric (%d)", s, speed)
}
} else if speed, err = strconv.Atoi(s); err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
} else {
// NIC speed value converted from Mbps to Bps(bytes per second)
speed = base * 125000
instance.SetLabel("speed", strconv.Itoa(speed))
me.Logger.Debug().Msgf("converted speed (%s) to numeric (%d)", s, speed)
}
} else if speed, err = strconv.Atoi(s); err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
}

if speed != 0 {
if speed != 0 {
var rxBytes, txBytes, rxPercent, txPercent float64
var rxOk, txOk, passRx, passTx bool

var rxBytes, txBytes, rxPercent, txPercent float64
var rxOk, txOk, passRx, passTx bool
if rxBytes, rxOk, passRx = read.GetValueFloat64(instance); rxOk && passRx {
rxPercent = rxBytes / float64(speed)
err := rx.SetValueFloat64(instance, rxPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
}

if rxBytes, rxOk, passRx = read.GetValueFloat64(instance); rxOk && passRx {
rxPercent = rxBytes / float64(speed)
err := rx.SetValueFloat64(instance, rxPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
if txBytes, txOk, passTx = write.GetValueFloat64(instance); txOk && passTx {
txPercent = txBytes / float64(speed)
err := tx.SetValueFloat64(instance, txPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
}
}

if txBytes, txOk, passTx = write.GetValueFloat64(instance); txOk && passTx {
txPercent = txBytes / float64(speed)
err := tx.SetValueFloat64(instance, txPercent)
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
if (rxOk || txOk) && (passRx || passTx) {
err := util.SetValueFloat64(instance, math.Max(rxPercent, txPercent))
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
}
}
}

if (rxOk || txOk) && (passRx || passTx) {
err := util.SetValueFloat64(instance, math.Max(rxPercent, txPercent))
if err != nil {
me.Logger.Error().Stack().Err(err).Msg("error")
}
if s = instance.GetLabel("speed"); strings.HasSuffix(s, "M") {
base, err = strconv.Atoi(strings.TrimSuffix(s, "M"))
if err != nil {
me.Logger.Warn().Msgf("convert speed [%s]", s)
} else {
// NIC speed value converted from Mbps to bps(bits per second)
speed = base * 1_000_000
instance.SetLabel("speed", strconv.Itoa(speed))
me.Logger.Debug().Msgf("converted speed (%s) to bps numeric (%d)", s, speed)
}
}

Expand Down
4 changes: 1 addition & 3 deletions conf/zapiperf/cdot/9.10.1/fcp.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


name: FcpPort
query: fcp_port
object: fcp
Expand Down Expand Up @@ -40,7 +38,7 @@ counters:
- nvmf_avg_read_latency
- nvmf_avg_remote_other_latency
- nvmf_avg_remote_read_latency
- nvmf_avg_remote_write_latenc
- nvmf_avg_remote_write_latency
- nvmf_avg_write_latency
- nvmf_caw_data
- nvmf_caw_ops
Expand Down
Loading

0 comments on commit 6b45932

Please sign in to comment.