diff --git a/cmd/check_interface_metrics.go b/cmd/check_interface_metrics.go index d5d1b89..b8396cf 100644 --- a/cmd/check_interface_metrics.go +++ b/cmd/check_interface_metrics.go @@ -12,7 +12,7 @@ func init() { checkInterfaceMetricsCMD.Flags().Bool("print-interfaces", false, "Print interfaces to plugin output") checkInterfaceMetricsCMD.Flags().StringSlice("ifType-filter", []string{}, "Filter out interfaces which ifType equals the given types") - checkInterfaceMetricsCMD.Flags().StringSlice("ifName-filter", []string{}, "Filter out interfaces which ifType matches the given regex") + checkInterfaceMetricsCMD.Flags().StringSlice("ifName-filter", []string{}, "Filter out interfaces which ifName matches the given regex") } var checkInterfaceMetricsCMD = &cobra.Command{ diff --git a/config/codecommunicator/ceraos-ip10.go b/config/codecommunicator/ceraos-ip10.go index 3da7725..2761aa2 100644 --- a/config/codecommunicator/ceraos-ip10.go +++ b/config/codecommunicator/ceraos-ip10.go @@ -42,13 +42,19 @@ func (c *ceraosIP10Communicator) GetInterfaces(ctx context.Context) ([]device.In for i := range subInterfaces { if regex.MatchString(*subInterfaces[i].IfDescr) { - subInterfaces[i].IfHCInOctets = targetInterface.IfHCInOctets - subInterfaces[i].IfHCOutOctets = targetInterface.IfHCOutOctets subInterfaces[i].IfOperStatus = targetInterface.IfOperStatus subInterfaces[i].IfInOctets = targetInterface.IfInOctets subInterfaces[i].IfOutOctets = targetInterface.IfOutOctets subInterfaces[i].IfInErrors = targetInterface.IfInErrors subInterfaces[i].IfOutErrors = targetInterface.IfOutErrors + subInterfaces[i].IfHCInOctets = targetInterface.IfHCInOctets + subInterfaces[i].IfHCOutOctets = targetInterface.IfHCOutOctets + + if subInterfaces[i].IfSpeed != nil { + speed := *subInterfaces[i].IfSpeed * 1000 + subInterfaces[i].IfSpeed = &speed + } + break } } diff --git a/config/device-classes/generic.yaml b/config/device-classes/generic.yaml index 75346b5..2e0772c 100644 --- a/config/device-classes/generic.yaml +++ b/config/device-classes/generic.yaml @@ -143,8 +143,16 @@ components: oid: 1.3.6.1.2.1.10.7.2.1.13 dot3StatsInternalMacReceiveErrors: oid: 1.3.6.1.2.1.10.7.2.1.16 + dot3HCStatsAlignmentErrors: + oid: 1.3.6.1.2.1.10.7.11.1.1 dot3HCStatsFCSErrors: oid: 1.3.6.1.2.1.10.7.11.1.2 + dot3HCStatsInternalMacTransmitErrors: + oid: 1.3.6.1.2.1.10.7.11.1.3 + dot3HCStatsFrameTooLongs: + oid: 1.3.6.1.2.1.10.7.11.1.4 + dot3HCStatsInternalMacReceiveErrors: + oid: 1.3.6.1.2.1.10.7.11.1.5 etherStatsCRCAlignErrors: oid: 1.3.6.1.2.1.16.1.1.1.8 indices_mapping: diff --git a/internal/device/device.go b/internal/device/device.go index d036535..5e84d04 100644 --- a/internal/device/device.go +++ b/internal/device/device.go @@ -138,20 +138,24 @@ type Interface struct { // // swagger:model type EthernetLikeInterface struct { - Dot3StatsAlignmentErrors *uint64 `yaml:"dot3StatsAlignmentErrors,omitempty" json:"dot3StatsAlignmentErrors,omitempty" xml:"dot3StatsAlignmentErrors,omitempty"` - Dot3StatsFCSErrors *uint64 `yaml:"dot3StatsFCSErrors,omitempty" json:"dot3StatsFCSErrors,omitempty" xml:"dot3StatsFCSErrors,omitempty"` - Dot3StatsSingleCollisionFrames *uint64 `yaml:"dot3StatsSingleCollisionFrames,omitempty" json:"dot3StatsSingleCollisionFrames,omitempty" xml:"dot3StatsSingleCollisionFrames,omitempty"` - Dot3StatsMultipleCollisionFrames *uint64 `yaml:"dot3StatsMultipleCollisionFrames,omitempty" json:"dot3StatsMultipleCollisionFrames,omitempty" xml:"dot3StatsMultipleCollisionFrames,omitempty"` - Dot3StatsSQETestErrors *uint64 `yaml:"dot3StatsSQETestErrors,omitempty" json:"dot3StatsSQETestErrors,omitempty" xml:"dot3StatsSQETestErrors,omitempty"` - Dot3StatsDeferredTransmissions *uint64 `yaml:"dot3StatsDeferredTransmissions,omitempty" json:"dot3StatsDeferredTransmissions,omitempty" xml:"dot3StatsDeferredTransmissions,omitempty"` - Dot3StatsLateCollisions *uint64 `yaml:"dot3StatsLateCollisions,omitempty" json:"dot3StatsLateCollisions,omitempty" xml:"dot3StatsLateCollisions,omitempty"` - Dot3StatsExcessiveCollisions *uint64 `yaml:"dot3StatsExcessiveCollisions,omitempty" json:"dot3StatsExcessiveCollisions,omitempty" xml:"dot3StatsExcessiveCollisions,omitempty"` - Dot3StatsInternalMacTransmitErrors *uint64 `yaml:"dot3StatsInternalMacTransmitErrors,omitempty" json:"dot3StatsInternalMacTransmitErrors,omitempty" xml:"dot3StatsInternalMacTransmitErrors,omitempty"` - Dot3StatsCarrierSenseErrors *uint64 `yaml:"dot3StatsCarrierSenseErrors,omitempty" json:"dot3StatsCarrierSenseErrors,omitempty" xml:"dot3StatsCarrierSenseErrors,omitempty"` - Dot3StatsFrameTooLongs *uint64 `yaml:"dot3StatsFrameTooLongs,omitempty" json:"dot3StatsFrameTooLongs,omitempty" xml:"dot3StatsFrameTooLongs,omitempty"` - Dot3StatsInternalMacReceiveErrors *uint64 `yaml:"dot3StatsInternalMacReceiveErrors,omitempty" json:"dot3StatsInternalMacReceiveErrors,omitempty" xml:"dot3StatsInternalMacReceiveErrors,omitempty"` - Dot3HCStatsFCSErrors *uint64 `yaml:"dot3HCStatsFCSErrors,omitempty" json:"dot3HCStatsFCSErrors,omitempty" xml:"dot3HCStatsFCSErrors,omitempty"` - EtherStatsCRCAlignErrors *uint64 `yaml:"etherStatsCRCAlignErrors ,omitempty" json:"etherStatsCRCAlignErrors,omitempty" xml:"etherStatsCRCAlignErrors,omitempty"` + Dot3StatsAlignmentErrors *uint64 `yaml:"dot3StatsAlignmentErrors,omitempty" json:"dot3StatsAlignmentErrors,omitempty" xml:"dot3StatsAlignmentErrors,omitempty"` + Dot3StatsFCSErrors *uint64 `yaml:"dot3StatsFCSErrors,omitempty" json:"dot3StatsFCSErrors,omitempty" xml:"dot3StatsFCSErrors,omitempty"` + Dot3StatsSingleCollisionFrames *uint64 `yaml:"dot3StatsSingleCollisionFrames,omitempty" json:"dot3StatsSingleCollisionFrames,omitempty" xml:"dot3StatsSingleCollisionFrames,omitempty"` + Dot3StatsMultipleCollisionFrames *uint64 `yaml:"dot3StatsMultipleCollisionFrames,omitempty" json:"dot3StatsMultipleCollisionFrames,omitempty" xml:"dot3StatsMultipleCollisionFrames,omitempty"` + Dot3StatsSQETestErrors *uint64 `yaml:"dot3StatsSQETestErrors,omitempty" json:"dot3StatsSQETestErrors,omitempty" xml:"dot3StatsSQETestErrors,omitempty"` + Dot3StatsDeferredTransmissions *uint64 `yaml:"dot3StatsDeferredTransmissions,omitempty" json:"dot3StatsDeferredTransmissions,omitempty" xml:"dot3StatsDeferredTransmissions,omitempty"` + Dot3StatsLateCollisions *uint64 `yaml:"dot3StatsLateCollisions,omitempty" json:"dot3StatsLateCollisions,omitempty" xml:"dot3StatsLateCollisions,omitempty"` + Dot3StatsExcessiveCollisions *uint64 `yaml:"dot3StatsExcessiveCollisions,omitempty" json:"dot3StatsExcessiveCollisions,omitempty" xml:"dot3StatsExcessiveCollisions,omitempty"` + Dot3StatsInternalMacTransmitErrors *uint64 `yaml:"dot3StatsInternalMacTransmitErrors,omitempty" json:"dot3StatsInternalMacTransmitErrors,omitempty" xml:"dot3StatsInternalMacTransmitErrors,omitempty"` + Dot3StatsCarrierSenseErrors *uint64 `yaml:"dot3StatsCarrierSenseErrors,omitempty" json:"dot3StatsCarrierSenseErrors,omitempty" xml:"dot3StatsCarrierSenseErrors,omitempty"` + Dot3StatsFrameTooLongs *uint64 `yaml:"dot3StatsFrameTooLongs,omitempty" json:"dot3StatsFrameTooLongs,omitempty" xml:"dot3StatsFrameTooLongs,omitempty"` + Dot3StatsInternalMacReceiveErrors *uint64 `yaml:"dot3StatsInternalMacReceiveErrors,omitempty" json:"dot3StatsInternalMacReceiveErrors,omitempty" xml:"dot3StatsInternalMacReceiveErrors,omitempty"` + Dot3HCStatsAlignmentErrors *uint64 `yaml:"dot3HCStatsAlignmentErrors,omitempty" json:"dot3HCStatsAlignmentErrors,omitempty" xml:"dot3HCStatsAlignmentErrors,omitempty"` + Dot3HCStatsFCSErrors *uint64 `yaml:"dot3HCStatsFCSErrors,omitempty" json:"dot3HCStatsFCSErrors,omitempty" xml:"dot3HCStatsFCSErrors,omitempty"` + Dot3HCStatsInternalMacTransmitErrors *uint64 `yaml:"dot3HCStatsInternalMacTransmitErrors,omitempty" json:"dot3HCStatsInternalMacTransmitErrors,omitempty" xml:"dot3HCStatsInternalMacTransmitErrors,omitempty"` + Dot3HCStatsFrameTooLongs *uint64 `yaml:"dot3HCStatsFrameTooLongs,omitempty" json:"dot3HCStatsFrameTooLongs,omitempty" xml:"dot3HCStatsFrameTooLongs,omitempty"` + Dot3HCStatsInternalMacReceiveErrors *uint64 `yaml:"dot3HCStatsInternalMacReceiveErrors,omitempty" json:"dot3HCStatsInternalMacReceiveErrors,omitempty" xml:"dot3HCStatsInternalMacReceiveErrors,omitempty"` + EtherStatsCRCAlignErrors *uint64 `yaml:"etherStatsCRCAlignErrors,omitempty" json:"etherStatsCRCAlignErrors,omitempty" xml:"etherStatsCRCAlignErrors,omitempty"` } // RadioInterface diff --git a/internal/network/snmp_client.go b/internal/network/snmp_client.go index 0ae19ce..49ac85b 100644 --- a/internal/network/snmp_client.go +++ b/internal/network/snmp_client.go @@ -208,10 +208,13 @@ func NewSNMPv3Client(ctx context.Context, ipAddress string, port, timeout, retri Timeout: time.Duration(timeout) * time.Second, MaxOids: 60, Retries: retries, - ContextName: *v3Data.ContextName, SecurityModel: gosnmp.UserSecurityModel, } + if v3Data.ContextName != nil { + client.ContextName = *v3Data.ContextName + } + switch *v3Data.Level { case "noAuthNoPriv": client.MsgFlags = gosnmp.NoAuthNoPriv diff --git a/internal/request/check_interface_metrics_request_process.go b/internal/request/check_interface_metrics_request_process.go index 39cc7b6..de4c71c 100644 --- a/internal/request/check_interface_metrics_request_process.go +++ b/internal/request/check_interface_metrics_request_process.go @@ -339,14 +339,24 @@ func addCheckInterfacePerformanceData(interfaces []device.Interface, r *monitori //ethernet like interface metrics if i.EthernetLike != nil { - if i.EthernetLike.Dot3StatsAlignmentErrors != nil { + if i.EthernetLike.Dot3HCStatsAlignmentErrors != nil { + err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_alignment_errors", *i.EthernetLike.Dot3HCStatsAlignmentErrors).SetUnit("c").SetLabel(*i.IfDescr)) + if err != nil { + return err + } + } else if i.EthernetLike.Dot3StatsAlignmentErrors != nil { err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_alignment_errors", *i.EthernetLike.Dot3StatsAlignmentErrors).SetUnit("c").SetLabel(*i.IfDescr)) if err != nil { return err } } - if i.EthernetLike.Dot3StatsFCSErrors != nil { + if i.EthernetLike.Dot3HCStatsFCSErrors != nil { + err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_FCSErrors", *i.EthernetLike.Dot3HCStatsFCSErrors).SetUnit("c").SetLabel(*i.IfDescr)) + if err != nil { + return err + } + } else if i.EthernetLike.Dot3StatsFCSErrors != nil { err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_FCSErrors", *i.EthernetLike.Dot3StatsFCSErrors).SetUnit("c").SetLabel(*i.IfDescr)) if err != nil { return err @@ -395,7 +405,12 @@ func addCheckInterfacePerformanceData(interfaces []device.Interface, r *monitori } } - if i.EthernetLike.Dot3StatsInternalMacTransmitErrors != nil { + if i.EthernetLike.Dot3HCStatsInternalMacTransmitErrors != nil { + err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_internal_mac_transmit_errors", *i.EthernetLike.Dot3HCStatsInternalMacTransmitErrors).SetUnit("c").SetLabel(*i.IfDescr)) + if err != nil { + return err + } + } else if i.EthernetLike.Dot3StatsInternalMacTransmitErrors != nil { err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_internal_mac_transmit_errors", *i.EthernetLike.Dot3StatsInternalMacTransmitErrors).SetUnit("c").SetLabel(*i.IfDescr)) if err != nil { return err @@ -409,22 +424,25 @@ func addCheckInterfacePerformanceData(interfaces []device.Interface, r *monitori } } - if i.EthernetLike.Dot3StatsFrameTooLongs != nil { + if i.EthernetLike.Dot3HCStatsFrameTooLongs != nil { + err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_frame_too_longs", *i.EthernetLike.Dot3HCStatsFrameTooLongs).SetUnit("c").SetLabel(*i.IfDescr)) + if err != nil { + return err + } + } else if i.EthernetLike.Dot3StatsFrameTooLongs != nil { err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_frame_too_longs", *i.EthernetLike.Dot3StatsFrameTooLongs).SetUnit("c").SetLabel(*i.IfDescr)) if err != nil { return err } } - if i.EthernetLike.Dot3StatsInternalMacReceiveErrors != nil { - err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_internal_mac_receive_errors", *i.EthernetLike.Dot3StatsInternalMacReceiveErrors).SetUnit("c").SetLabel(*i.IfDescr)) + if i.EthernetLike.Dot3HCStatsInternalMacReceiveErrors != nil { + err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_internal_mac_receive_errors", *i.EthernetLike.Dot3HCStatsInternalMacReceiveErrors).SetUnit("c").SetLabel(*i.IfDescr)) if err != nil { return err } - } - - if i.EthernetLike.Dot3HCStatsFCSErrors != nil { - err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_dot3HCStatsFCSErrors", *i.EthernetLike.Dot3HCStatsFCSErrors).SetUnit("c").SetLabel(*i.IfDescr)) + } else if i.EthernetLike.Dot3StatsInternalMacReceiveErrors != nil { + err := r.AddPerformanceDataPoint(monitoringplugin.NewPerformanceDataPoint("error_counter_internal_mac_receive_errors", *i.EthernetLike.Dot3StatsInternalMacReceiveErrors).SetUnit("c").SetLabel(*i.IfDescr)) if err != nil { return err } diff --git a/test/testdata/devices/arista_eos/device_1/public.testdata b/test/testdata/devices/arista_eos/device_1/public.testdata index 93613a2..bfb8c41 100644 --- a/test/testdata/devices/arista_eos/device_1/public.testdata +++ b/test/testdata/devices/arista_eos/device_1/public.testdata @@ -185,20 +185,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "Management1", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_excessive_collisions", "label": "Ethernet1", @@ -325,20 +311,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "Ethernet1", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_alignment_errors", "label": "Management1", @@ -451,20 +423,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "Ethernet2", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_late_collisions", "label": "Management1", @@ -717,20 +675,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "Ethernet3", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "packet_counter_multicast_out", "label": "Management1", diff --git a/test/testdata/devices/comware/VSR1000/public.testdata b/test/testdata/devices/comware/VSR1000/public.testdata index 734d888..b3408d8 100644 --- a/test/testdata/devices/comware/VSR1000/public.testdata +++ b/test/testdata/devices/comware/VSR1000/public.testdata @@ -941,20 +941,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet5/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_single_collision_frames", "label": "GigabitEthernet4/0", @@ -1389,34 +1375,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet7/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet6/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "packet_counter_multicast_in", "label": "GigabitEthernet7/0", @@ -2120,7 +2078,7 @@ { "metric": "error_counter_internal_mac_receive_errors", "label": "GigabitEthernet8/0", - "value": 185, + "value": 0, "unit": "c", "thresholds": { "warningMin": null, @@ -2537,20 +2495,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet2/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_single_collision_frames", "label": "GigabitEthernet6/0", @@ -2971,20 +2915,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet8/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "packet_counter_unicast_out", "label": "GigabitEthernet1/0", @@ -2999,20 +2929,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet1/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "packet_counter_broadcast_out", "label": "GigabitEthernet4/0", @@ -3195,20 +3111,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet3/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_FCSErrors", "label": "GigabitEthernet7/0", @@ -3405,20 +3307,6 @@ "min": null, "max": null }, - { - "metric": "error_counter_dot3HCStatsFCSErrors", - "label": "GigabitEthernet4/0", - "value": 0, - "unit": "c", - "thresholds": { - "warningMin": null, - "warningMax": null, - "criticalMin": null, - "criticalMax": null - }, - "min": null, - "max": null - }, { "metric": "error_counter_out", "label": "GigabitEthernet5/0",