Skip to content

Commit

Permalink
Merge pull request #57 from inexio/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
babos77 authored Jul 2, 2021
2 parents b248fe3 + 0f4e200 commit b03ced6
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 197 deletions.
2 changes: 1 addition & 1 deletion cmd/check_interface_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 8 additions & 2 deletions config/codecommunicator/ceraos-ip10.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
8 changes: 8 additions & 0 deletions config/device-classes/generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 18 additions & 14 deletions internal/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion internal/network/snmp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 28 additions & 10 deletions internal/request/check_interface_metrics_request_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
56 changes: 0 additions & 56 deletions test/testdata/devices/arista_eos/device_1/public.testdata
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit b03ced6

Please sign in to comment.