From cee68b86041ea517b839cf7166019e64e6dd4852 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Wed, 18 Aug 2021 14:43:59 +0200 Subject: [PATCH 1/3] fixed timos no sap interfaces available --- config/codecommunicator/timos.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/codecommunicator/timos.go b/config/codecommunicator/timos.go index dad39bb..3b84108 100644 --- a/config/codecommunicator/timos.go +++ b/config/codecommunicator/timos.go @@ -5,6 +5,7 @@ import ( "github.com/inexio/thola/internal/device" "github.com/inexio/thola/internal/network" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "strconv" "strings" ) @@ -38,7 +39,8 @@ func (c *timosCommunicator) GetInterfaces(ctx context.Context) ([]device.Interfa sapDescriptionsOID := ".1.3.6.1.4.1.6527.3.1.2.4.3.2.1.5" sapDescriptions, err := con.SNMP.SnmpClient.SNMPWalk(ctx, sapDescriptionsOID) if err != nil { - return nil, errors.Wrap(err, "snmpwalk failed") + log.Ctx(ctx).Debug().Err(err).Msg("sap interfaces are not available on this device") + return interfaces, nil } for _, response := range sapDescriptions { From b251f8e2874a384e038f5f37ad53cf485e7ae329 Mon Sep 17 00:00:00 2001 From: mikameyer Date: Thu, 19 Aug 2021 10:32:28 +0200 Subject: [PATCH 2/3] adva cleanup & bugfix --- config/codecommunicator/adva.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/config/codecommunicator/adva.go b/config/codecommunicator/adva.go index feedeca..60f94c4 100644 --- a/config/codecommunicator/adva.go +++ b/config/codecommunicator/adva.go @@ -23,18 +23,18 @@ func (c *advaCommunicator) GetInterfaces(ctx context.Context) ([]device.Interfac return nil, err } - if err = advaGetDWDMInterfaces(ctx, interfaces); err != nil { + if err = c.getDWDMInterfaces(ctx, interfaces); err != nil { return nil, err } - if err = advaGetChannels(ctx, interfaces); err != nil { + if err = c.getChannels(ctx, interfaces); err != nil { return nil, err } - return normalizeAdvaInterfaces(interfaces), nil + return c.normalizeInterfaces(interfaces), nil } -func advaGetDWDMInterfaces(ctx context.Context, interfaces []device.Interface) error { +func (c *advaCommunicator) getDWDMInterfaces(ctx context.Context, interfaces []device.Interface) error { con, ok := network.DeviceConnectionFromContext(ctx) if !ok || con.SNMP == nil { return errors.New("no device connection available") @@ -80,12 +80,12 @@ func advaGetDWDMInterfaces(ctx context.Context, interfaces []device.Interface) e txPower[oid[len(oid)-1]], _ = txValue.Mul(decimal.NewFromFloat(0.1)).Float64() } - rx100Values, err := advaGetPowerValues(ctx, ".1.3.6.1.4.1.2544.1.11.11.7.2.1.1.1.21") + rx100Values, err := c.getPowerValues(ctx, ".1.3.6.1.4.1.2544.1.11.11.7.2.1.1.1.21") if err != nil { log.Ctx(ctx).Debug().Err(err).Msg("failed to get rx 100 values") } - tx100Values, err := advaGetPowerValues(ctx, ".1.3.6.1.4.1.2544.1.11.11.7.2.1.1.1.22") + tx100Values, err := c.getPowerValues(ctx, ".1.3.6.1.4.1.2544.1.11.11.7.2.1.1.1.22") if err != nil { log.Ctx(ctx).Debug().Err(err).Msg("failed to get tx 100 values") } @@ -220,7 +220,7 @@ func advaGetDWDMInterfaces(ctx context.Context, interfaces []device.Interface) e return nil } -func advaGetChannels(ctx context.Context, interfaces []device.Interface) error { +func (c *advaCommunicator) getChannels(ctx context.Context, interfaces []device.Interface) error { con, ok := network.DeviceConnectionFromContext(ctx) if !ok || con.SNMP == nil { return errors.New("no device connection available") @@ -236,7 +236,7 @@ func advaGetChannels(ctx context.Context, interfaces []device.Interface) error { for _, res := range facilityPhysInstValueInputPowerValues { subtree := strings.TrimPrefix(res.GetOID(), facilityPhysInstValueInputPower) - if s := strings.Split(strings.Trim(subtree, "."), "."); len(s) > 2 && s[len(s)-2] != "0" { + if s := strings.Split(strings.Trim(subtree, "."), "."); len(s) > 3 && s[len(s)-2] != "0" && s[len(s)-3] == "33152" { val, err := res.GetValueString() if err != nil { return errors.Wrap(err, "failed to get rx value of channel "+subtree) @@ -263,7 +263,7 @@ func advaGetChannels(ctx context.Context, interfaces []device.Interface) error { for _, res := range facilityPhysInstValueOutputPowerValues { subtree := strings.TrimPrefix(res.GetOID(), facilityPhysInstValueOutputPower) - if s := strings.Split(strings.Trim(subtree, "."), "."); len(s) > 2 && s[len(s)-2] != "0" { + if s := strings.Split(strings.Trim(subtree, "."), "."); len(s) > 3 && s[len(s)-2] != "0" && s[len(s)-3] == "33152" { val, err := res.GetValueString() if err != nil { return errors.Wrap(err, "failed to get tx value of channel "+subtree) @@ -306,7 +306,7 @@ func advaGetChannels(ctx context.Context, interfaces []device.Interface) error { return nil } -func advaGetPowerValues(ctx context.Context, oid string) (map[string]float64, error) { +func (c *advaCommunicator) getPowerValues(ctx context.Context, oid string) (map[string]float64, error) { con, ok := network.DeviceConnectionFromContext(ctx) if !ok || con.SNMP == nil { return nil, errors.New("no device connection available") @@ -347,7 +347,7 @@ func advaGetPowerValues(ctx context.Context, oid string) (map[string]float64, er return descrToValues, nil } -func normalizeAdvaInterfaces(interfaces []device.Interface) []device.Interface { +func (c *advaCommunicator) normalizeInterfaces(interfaces []device.Interface) []device.Interface { var res []device.Interface for _, interf := range interfaces { From c2b13f2b24edd24041b8a0053fe27f2fd88beb4c Mon Sep 17 00:00:00 2001 From: mikameyer Date: Thu, 19 Aug 2021 12:13:36 +0200 Subject: [PATCH 3/3] bugfix ekinops interface not found --- config/codecommunicator/ekinops_module_reader_amplifier.go | 4 +++- config/codecommunicator/ekinops_module_reader_opm.go | 4 +++- config/codecommunicator/ekinops_module_reader_transponder.go | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/codecommunicator/ekinops_module_reader_amplifier.go b/config/codecommunicator/ekinops_module_reader_amplifier.go index 4161514..ce6a661 100644 --- a/config/codecommunicator/ekinops_module_reader_amplifier.go +++ b/config/codecommunicator/ekinops_module_reader_amplifier.go @@ -6,6 +6,7 @@ import ( "github.com/inexio/thola/internal/device" "github.com/inexio/thola/internal/network" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "strconv" "strings" ) @@ -52,7 +53,8 @@ func (m *ekinopsModuleReaderAmplifier) readModuleMetrics(ctx context.Context, in identifier := m.slotIdentifier + "/" + m.moduleName + "/" + strings.Split(*opticalAmplifierInterface.Identifier, "(")[0] idx, ok := mappings[identifier] if !ok { - return nil, fmt.Errorf("interface for identifier '%s' not found", identifier) + log.Ctx(ctx).Debug().Msgf("interface for identifier '%s' not found", identifier) + continue } interfaces[idx].OpticalAmplifier = &opticalAmplifierInterfaces[i] interfaces[idx].IfAlias = interfaces[idx].OpticalAmplifier.Label diff --git a/config/codecommunicator/ekinops_module_reader_opm.go b/config/codecommunicator/ekinops_module_reader_opm.go index e9ecb3b..21bc4c6 100644 --- a/config/codecommunicator/ekinops_module_reader_opm.go +++ b/config/codecommunicator/ekinops_module_reader_opm.go @@ -6,6 +6,7 @@ import ( "github.com/inexio/thola/internal/device" "github.com/inexio/thola/internal/network" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "strconv" "strings" ) @@ -39,7 +40,8 @@ func (m *ekinopsModuleReaderOPM8) readModuleMetrics(ctx context.Context, interfa identifier := m.slotIdentifier + "/" + m.moduleName + "/" + strings.Split(*opticalOPMInterface.Identifier, "(")[0] idx, ok := mappings[identifier] if !ok { - return nil, fmt.Errorf("interface for identifier '%s' not found", identifier) + log.Ctx(ctx).Debug().Msgf("interface for identifier '%s' not found", identifier) + continue } interfaces[idx].OpticalOPM = &opticalOPMInterfaces[i] interfaces[idx].IfAlias = interfaces[idx].OpticalOPM.Label diff --git a/config/codecommunicator/ekinops_module_reader_transponder.go b/config/codecommunicator/ekinops_module_reader_transponder.go index e7d9ad8..540f8d6 100644 --- a/config/codecommunicator/ekinops_module_reader_transponder.go +++ b/config/codecommunicator/ekinops_module_reader_transponder.go @@ -2,10 +2,10 @@ package codecommunicator import ( "context" - "fmt" "github.com/inexio/thola/internal/device" "github.com/inexio/thola/internal/network" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "strconv" "strings" ) @@ -53,7 +53,8 @@ func (m *ekinopsModuleReaderTransponder) readModuleMetrics(ctx context.Context, identifier := m.slotIdentifier + "/" + m.moduleName + "/" + strings.Split(*opticalTransponderInterface.Identifier, "(")[0] idx, ok := mappings[identifier] if !ok { - return nil, fmt.Errorf("interface for identifier '%s' not found", identifier) + log.Ctx(ctx).Debug().Msgf("interface for identifier '%s' not found", identifier) + continue } interfaces[idx].OpticalTransponder = &OpticalTransponderInterfaces[i] interfaces[idx].IfAlias = interfaces[idx].OpticalTransponder.Label