Skip to content

Commit

Permalink
ekinops fix very small tx and rx power values
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFireMike committed Mar 9, 2021
1 parent ab04e2f commit ea4fb8d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
19 changes: 13 additions & 6 deletions core/communicator/ekinops_module_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ func (m *ekinopsModuleReaderWrapper) readModuleMetrics(ctx context.Context, inte
type ekinopsPowerTransformFunc func(float64) float64

func ekinopsPowerTransform10Log10XMinus40(f float64) float64 {
return 10*math.Log10(f) - 40
return ekinopsPowerTransformCheckTooSmall(10*math.Log10(f) - 40)
}

func ekinopsPowerTransform10Log10XDivideBy10000(f float64) float64 {
return 10 * math.Log10(f/10000)
return ekinopsPowerTransformCheckTooSmall(10 * math.Log10(f/10000))
}

func ekionopsPowerTransformShiftDivideBy100(f float64) float64 {
if f < 32768 {
return f / 100
return ekinopsPowerTransformCheckTooSmall(f / 100)
} else {
return (f - 65536) / 100
return ekinopsPowerTransformCheckTooSmall((f - 65536) / 100)
}
}

Expand All @@ -241,8 +241,15 @@ func ekinopsPowerTransformMinus32768MultiplyByPoint005(f float64) float64 {

func ekinopsPowerTransformOPM8(f float64) float64 {
if f < 32768 {
return f / 256
return ekinopsPowerTransformCheckTooSmall(f / 256)
} else {
return f/256 - 256
return ekinopsPowerTransformCheckTooSmall(f/256 - 256)
}
}

func ekinopsPowerTransformCheckTooSmall(f float64) float64 {
if math.IsInf(f, 0) || math.IsNaN(f) || f < -100 {
f = -100
}
return f
}
4 changes: 2 additions & 2 deletions core/request/check_interface_metrics_request_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@ func addCheckInterfacePerformanceData(interfaces []device.Interface, r *monitori
}
}
if i.OpticalTransponder.CorrectedFEC != nil {
err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("corrected_fec_counter", *i.OpticalTransponder.CorrectedFEC, "").SetLabel(*i.IfDescr))
err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("corrected_fec_counter", *i.OpticalTransponder.CorrectedFEC, "c").SetLabel(*i.IfDescr))
if err != nil {
return err
}
}
if i.OpticalTransponder.UncorrectedFEC != nil {
err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("uncorrected_fec_counter", *i.OpticalTransponder.UncorrectedFEC, "").SetLabel(*i.IfDescr))
err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("uncorrected_fec_counter", *i.OpticalTransponder.UncorrectedFEC, "c").SetLabel(*i.IfDescr))
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/google/go-cmp v0.5.4
github.com/gosnmp/gosnmp v1.30.0
github.com/huandu/go-sqlbuilder v1.8.0
github.com/inexio/go-monitoringplugin v1.0.0
github.com/inexio/go-monitoringplugin v1.0.2
github.com/jmoiron/sqlx v1.2.0
github.com/labstack/echo/v4 v4.2.0
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ github.com/huandu/go-sqlbuilder v1.8.0 h1:1KP21dzROt03II0aoX/rD2Y6TX1VCIixSX5mvk
github.com/huandu/go-sqlbuilder v1.8.0/go.mod h1:cM38aLPrMXaGxsUkHFh1e2skthPnQRPK7h8//X5LQMc=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inexio/go-monitoringplugin v1.0.0 h1:aOGOF+vBEwfQNnzFPWJKFWyY3HwV3zzd1HbUljm3Saw=
github.com/inexio/go-monitoringplugin v1.0.0/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8=
github.com/inexio/go-monitoringplugin v1.0.2 h1:jhVHjshrJHC6cjyqomaReqmPIhkJTNJM1ztw3ltx65k=
github.com/inexio/go-monitoringplugin v1.0.2/go.mod h1:kzHRJGZ2iE/0IElB4NYI38h3h0HM5wqTTH7KyUCjkM8=
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
Expand Down

0 comments on commit ea4fb8d

Please sign in to comment.