From 53b85bc11c376f768b58d92226582f575322db04 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Mon, 14 Jul 2025 15:54:38 +0200 Subject: [PATCH 01/27] system statistics for ipv4 init commit --- .../systemstatisticsIPv4/collector.go | 171 ++++++++++++++++++ .../systemstatisticsIPv4/rpc.go | 64 +++++++ 2 files changed, 235 insertions(+) create mode 100644 pkg/features/systemstatistics/systemstatisticsIPv4/collector.go create mode 100644 pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go new file mode 100644 index 00000000..75c02c70 --- /dev/null +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go @@ -0,0 +1,171 @@ +package systemstatisticsIPv4 + +import ( + "github.com/prometheus/client_golang/prometheus" + + "github.com/czerwonk/junos_exporter/pkg/collector" +) + +const prefix string = "junos_systemstatistics_ipv4_" + +// Metrics to collect for the feature +var ( + packetsReceivedDesc *prometheus.Desc + badHeaderChecksumsDesc *prometheus.Desc + packetsWithSizeSmallerThanMinimumDesc *prometheus.Desc + packetsWithDataSizeLessThanDatalengthDesc *prometheus.Desc + packetsWithHeaderLengthLessThanHeaderlengthDesc *prometheus.Desc + packetsWithIncorrectVersionNumberDesc *prometheus.Desc + packetsDestinedToDeadNextHopDesc *prometheus.Desc + fragmentsReceivedDesc *prometheus.Desc + fragmentsDroppedDueToOutspaceOfDUPDesc *prometheus.Desc + fragmentsDroppedDueToQueueoverflowDesc *prometheus.Desc + fragmentsDroppedAfterTimeoutDesc *prometheus.Desc + packetsReassembledOKDesc *prometheus.Desc + packetsForThisHostDesc *prometheus.Desc + packetsForUnknownOrUnsupportedProtocolDesc *prometheus.Desc + packetsForwardedDesc *prometheus.Desc + packetsNotForwardableDesc *prometheus.Desc + redirectsSentDesc *prometheus.Desc + packetsSentFromThisHostDesc *prometheus.Desc + packetsSentWithFabricatedIPHeaderDesc *prometheus.Desc + outputPacketsDroppedDueToNoBufsDesc *prometheus.Desc + outputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc + outputDatagramsFragmentedDesc *prometheus.Desc + fragmentsCreatedDesc *prometheus.Desc + datagramsThatCanNotBeFragmentedDesc *prometheus.Desc + packetsWithBadOptionsDesc *prometheus.Desc + packetsWithOptionsHandledWithoutErrorDesc *prometheus.Desc + strictSourceAndRecordRouteOptionsDesc *prometheus.Desc + looseSourceAndRecordRouteOptionsDesc *prometheus.Desc + recordRouteOptionsDesc *prometheus.Desc + timestampOptionsDesc *prometheus.Desc + timestampAndAddressOptionsDesc *prometheus.Desc + timestampAndPrespecifiedAddressOptionsDesc *prometheus.Desc + optionPacketsDroppedDueToRateLimitDesc *prometheus.Desc + routerAlertOptionDesc *prometheus.Desc + multicastPacketsDroppedDesc *prometheus.Desc + packetsDroppedDesc *prometheus.Desc + transitREPacketsDroppedonMGMTInterfaceDesc *prometheus.Desc + packetsUsedFirstNexthopInECMPUnilistDesc *prometheus.Desc + incomingTtpoipPacketsReceivedDesc *prometheus.Desc + incomingTtpoipPacketsDroppedDesc *prometheus.Desc + outgoingTtpoipPacketsSentDesc *prometheus.Desc + outgoingTtpoipPacketsDroppedDesc *prometheus.Desc + incomingRawIPPacketsDroppedNoSocketBufferDesc *prometheus.Desc + incomingVirtualNodePacketsDeliveredDesc *prometheus.Desc +) + +func init() { + l := []string{"target"} + packetsReceivedDesc = prometheus.NewDesc(prefix+"packets_received", "Number of packets received", l, nil) + badHeaderChecksumsDesc = prometheus.NewDesc(prefix+"bad_header_checksums", "Number of packets received with bad header checksums", l, nil) + packetsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", l, nil) + packetsWithDataSizeLessThanDatalengthDesc = prometheus.NewDesc(prefix+"packets_with_data_size_less_than_datalength", "Number of packets received with data size less than data length", l, nil) + packetsWithHeaderLengthLessThanHeaderlengthDesc = prometheus.NewDesc(prefix+"packets_with_header_length_less_than_headerlength", "Number of packets received with header length less than header length", l, nil) + packetsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"packets_with_incorrect_version_number", "Number of packets received with incorrect version number", l, nil) + packetsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"packets_destined_to_dead_next_hop", "Number of packets received destined to dead next hop", l, nil) + fragmentsReceivedDesc = prometheus.NewDesc(prefix+"fragments_received", "Number of fragments received", l, nil) + fragmentsDroppedDueToOutspaceOfDUPDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_outspace_of_dup", "Number of fragments dropped due to outspace of DUP", l, nil) + fragmentsDroppedDueToQueueoverflowDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_queueoverflow", "Number of fragments dropped due to queue overflow", l, nil) + fragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"fragments_dropped_after_timeout", "Number of fragments dropped after timeout", l, nil) + packetsReassembledOKDesc = prometheus.NewDesc(prefix+"packets_reassembled_ok", "Number of packets reassembled OK", l, nil) + packetsForThisHostDesc = prometheus.NewDesc(prefix+"packets_for_this_host", "Number of packets for this host", l, nil) + packetsForUnknownOrUnsupportedProtocolDesc = prometheus.NewDesc(prefix+"packets_for_unknown_or_unsupported_protocol", "Number of packets for unknown or unsupported protocol", l, nil) + packetsForwardedDesc = prometheus.NewDesc(prefix+"packets_forwarded", "Number of packets forwarded", l, nil) + packetsNotForwardableDesc = prometheus.NewDesc(prefix+"packets_not_forwardable", "Number of packets not forwardable", l, nil) + redirectsSentDesc = prometheus.NewDesc(prefix+"redirects_sent", "Number of redirects sent", l, nil) + packetsSentFromThisHostDesc = prometheus.NewDesc(prefix+"packets_sent_from_this_host", "Number of packets sent from this host", l, nil) + packetsSentWithFabricatedIPHeaderDesc = prometheus.NewDesc(prefix+"packets_sent_with_fabricated_ip_header", "Number of packets sent with fabricated IP header", l, nil) + outputPacketsDroppedDueToNoBufsDesc = prometheus.NewDesc(prefix+"output_packets_dropped_due_to_no_bufs", "Number of output packets dropped due to no bufs", l, nil) + outputPacketsDiscardedDueToNoRouteDesc = prometheus.NewDesc(prefix+"output_packets_discarded_due_to_no_route", "Number of output packets discarded due to no route", l, nil) + outputDatagramsFragmentedDesc = prometheus.NewDesc(prefix+"output_datagrams_fragmented", "Number of output datagrams fragmented", l, nil) + fragmentsCreatedDesc = prometheus.NewDesc(prefix+"fragments_created", "Number of fragments created", l, nil) + datagramsThatCanNotBeFragmentedDesc = prometheus.NewDesc(prefix+"datagrams_that_can_not_be_fragmented", "Number of datagrams that can not be fragmented", l, nil) + packetsWithBadOptionsDesc = prometheus.NewDesc(prefix+"packets_with_bad_options", "Number of packets with bad options", l, nil) + packetsWithOptionsHandledWithoutErrorDesc = prometheus.NewDesc(prefix+"packets_with_options_handled_without_error", "Number of packets with options handled without error", l, nil) + strictSourceAndRecordRouteOptionsDesc = prometheus.NewDesc(prefix+"strict_source_and_record_route_options", "Number of packets with strict source and record route options", l, nil) + looseSourceAndRecordRouteOptionsDesc = prometheus.NewDesc(prefix+"loose_source_and_record_route_options", "Number of packets with loose source and record route options", l, nil) + recordRouteOptionsDesc = prometheus.NewDesc(prefix+"record_route_options", "Number of packets with record route options", l, nil) + timestampOptionsDesc = prometheus.NewDesc(prefix+"timestamp_options", "Number of packets with timestamp options", l, nil) + timestampAndAddressOptionsDesc = prometheus.NewDesc(prefix+"timestamp_and_address_options", "Number of packets with timestamp and address options", l, nil) + timestampAndPrespecifiedAddressOptionsDesc = prometheus.NewDesc(prefix+"timestamp_and_prespecified_address_options", "Number of packets with timestamp and prespecified address options", l, nil) + optionPacketsDroppedDueToRateLimitDesc = prometheus.NewDesc(prefix+"option_packets_dropped_due_to_rate_limit", "Number of option packets dropped due to rate limit", l, nil) + routerAlertOptionDesc = prometheus.NewDesc(prefix+"router_alert_option", "Number of packets with router alert option", l, nil) + multicastPacketsDroppedDesc = prometheus.NewDesc(prefix+"multicast_packets_dropped", "Number of multicast packets dropped", l, nil) + packetsDroppedDesc = prometheus.NewDesc(prefix+"packets_dropped", "Number of packets dropped", l, nil) + transitREPacketsDroppedonMGMTInterfaceDesc = prometheus.NewDesc(prefix+"transit_re_packets_droppedon_mgt_interface", "Number of transit RE packets dropped on MGMT interface", l, nil) + packetsUsedFirstNexthopInECMPUnilistDesc = prometheus.NewDesc(prefix+"packets_used_first_nexthop_in_ecmp_unilist", "Number of packets used first nexthop in ECMP unilist", l, nil) + incomingTtpoipPacketsReceivedDesc = prometheus.NewDesc(prefix+"incoming_ttpoip_packets_received", "Number of incoming TTPoIP packets received", l, nil) + incomingTtpoipPacketsDroppedDesc = prometheus.NewDesc(prefix+"incoming_ttpoip_packets_dropped", "Number of incoming TTPoIP packets dropped", l, nil) + outgoingTtpoipPacketsSentDesc = prometheus.NewDesc(prefix+"outgoing_ttpoip_packets_sent", "Number of outgoing TTPoIP packets sent", l, nil) + outgoingTtpoipPacketsDroppedDesc = prometheus.NewDesc(prefix+"outgoing_ttpoip_packets_dropped", "Number of outgoing TTPoIP packets dropped", l, nil) + incomingRawIPPacketsDroppedNoSocketBufferDesc = prometheus.NewDesc(prefix+"incoming_raw_ip_packets_dropped_no_socket_buffer", "Number of incoming raw IP packets dropped due to no socket buffer", l, nil) + incomingVirtualNodePacketsDeliveredDesc = prometheus.NewDesc(prefix+"incoming_virtual_node_packets_delivered", "Number of incoming virtual node packets delivered", l, nil) +} + +type systemstatisticsIPv4Collector struct{} + +func NewCollector() collector.RPCCollector { + return &systemstatisticsIPv4Collector{} +} + +func (c *systemstatisticsIPv4Collector) Name() string { + return "systemstatisticsIPv4" +} + +func (c *systemstatisticsIPv4Collector) Describe(ch chan<- *prometheus.Desc) { + ch <- packetsReceivedDesc + ch <- badHeaderChecksumsDesc + ch <- packetsWithSizeSmallerThanMinimumDesc + ch <- packetsWithDataSizeLessThanDatalengthDesc + ch <- packetsWithHeaderLengthLessThanHeaderlengthDesc + ch <- packetsWithIncorrectVersionNumberDesc + ch <- packetsDestinedToDeadNextHopDesc + ch <- fragmentsReceivedDesc + ch <- fragmentsDroppedDueToOutspaceOfDUPDesc + ch <- fragmentsDroppedDueToQueueoverflowDesc + ch <- fragmentsDroppedAfterTimeoutDesc + ch <- packetsReassembledOKDesc + ch <- packetsForThisHostDesc + ch <- packetsForUnknownOrUnsupportedProtocolDesc + ch <- packetsForwardedDesc + ch <- packetsNotForwardableDesc + ch <- redirectsSentDesc + ch <- packetsSentFromThisHostDesc + ch <- packetsSentWithFabricatedIPHeaderDesc + ch <- outputPacketsDroppedDueToNoBufsDesc + ch <- outputPacketsDiscardedDueToNoRouteDesc + ch <- outputDatagramsFragmentedDesc + ch <- fragmentsCreatedDesc + ch <- datagramsThatCanNotBeFragmentedDesc + ch <- packetsWithBadOptionsDesc + ch <- packetsWithOptionsHandledWithoutErrorDesc + ch <- strictSourceAndRecordRouteOptionsDesc + ch <- looseSourceAndRecordRouteOptionsDesc + ch <- recordRouteOptionsDesc + ch <- timestampOptionsDesc + ch <- timestampAndAddressOptionsDesc + ch <- timestampAndPrespecifiedAddressOptionsDesc + ch <- optionPacketsDroppedDueToRateLimitDesc + ch <- routerAlertOptionDesc + ch <- multicastPacketsDroppedDesc + ch <- packetsDroppedDesc + ch <- transitREPacketsDroppedonMGMTInterfaceDesc + ch <- packetsUsedFirstNexthopInECMPUnilistDesc + ch <- incomingTtpoipPacketsReceivedDesc + ch <- incomingTtpoipPacketsDroppedDesc + ch <- outgoingTtpoipPacketsSentDesc + ch <- outgoingTtpoipPacketsDroppedDesc + ch <- incomingRawIPPacketsDroppedNoSocketBufferDesc + ch <- incomingVirtualNodePacketsDeliveredDesc +} + +func (c *systemstatisticsIPv4Collector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var s StatisticsIPv4 + err := client.RunCommandAndParse("show system statistics ipv", &s) + if err != nil { + return err + } + +} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go new file mode 100644 index 00000000..26a7fa0c --- /dev/null +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go @@ -0,0 +1,64 @@ +package systemstatisticsIPv4 + +import "encoding/xml" + +type StatisticsIPv4 struct { + XMLName xml.Name `xml:"rpc-reply"` + Text string `xml:",chardata"` + Junos string `xml:"junos,attr"` + Statistics struct { + Text string `xml:",chardata"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived int `xml:"packets-received"` + BadHeaderChecksums int `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum int `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength int `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize int `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength int `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber int `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop int `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived int `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup int `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow int `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout int `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk int `xml:"packets-reassembled-ok"` + PacketsForThisHost int `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol int `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded int `xml:"packets-forwarded"` + PacketsNotForwardable int `xml:"packets-not-forwardable"` + RedirectsSent int `xml:"redirects-sent"` + PacketsSentFromThisHost int `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader int `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs int `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute int `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented int `xml:"output-datagrams-fragmented"` + FragmentsCreated int `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented int `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions int `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError int `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions int `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions int `xml:"loose-source-and-record-route-options"` + RecordRouteOptions int `xml:"record-route-options"` + TimestampOptions int `xml:"timestamp-options"` + TimestampAndAddressOptions int `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions int `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit int `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions int `xml:"router-alert-options"` + MulticastPacketsDropped int `xml:"multicast-packets-dropped"` + PacketsDropped int `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface int `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist int `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived int `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped int `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent int `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped int `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer int `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered int `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + } `xml:"statistics"` + Cli struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + } `xml:"cli"` +} From b339e0d68b0c78bd2b1e1546d04803f1db89cc3d Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Tue, 15 Jul 2025 12:02:55 +0200 Subject: [PATCH 02/27] finished system statistics for IPv4 --- collectors.go | 2 + internal/config/config.go | 2 + main.go | 2 + .../systemstatisticsIPv4/collector.go | 151 ++++++++++++------ .../systemstatisticsIPv4/rpc.go | 90 +++++------ 5 files changed, 151 insertions(+), 96 deletions(-) diff --git a/collectors.go b/collectors.go index 54fffe4d..1a1d6fb5 100644 --- a/collectors.go +++ b/collectors.go @@ -7,6 +7,7 @@ import ( "github.com/czerwonk/junos_exporter/pkg/features/ddosprotection" "github.com/czerwonk/junos_exporter/pkg/features/poe" + "github.com/czerwonk/junos_exporter/pkg/features/systemstatistics/systemstatisticsIPv4" "github.com/czerwonk/junos_exporter/internal/config" "github.com/czerwonk/junos_exporter/pkg/collector" @@ -130,6 +131,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device, descRe * c.addCollectorIfEnabledForDevice(device, "ddosprotection", f.DDOSProtection, ddosprotection.NewCollector) c.addCollectorIfEnabledForDevice(device, "krt", f.KRT, krt.NewCollector) c.addCollectorIfEnabledForDevice(device, "twamp", f.TWAMP, twamp.NewCollector) + c.addCollectorIfEnabledForDevice(device, "system_statistics_ipv4", f.SystemStatisticsIPv4, systemstatisticsIPv4.NewCollector) } func (c *collectors) addCollectorIfEnabledForDevice(device *connector.Device, key string, enabled bool, newCollector func() collector.RPCCollector) { diff --git a/internal/config/config.go b/internal/config/config.go index 3f16119b..df066fe4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -103,6 +103,7 @@ type FeatureConfig struct { DDOSProtection bool `yaml:"ddos_protection,omitempty"` KRT bool `yaml:"krt,omitempty"` TWAMP bool `yaml:"twamp,omitempty"` + SystemStatisticsIPv4 bool `yaml:"system_statistics_ipv4,omitempty"` } // New creates a new config @@ -182,6 +183,7 @@ func setDefaultValues(c *Config) { f.License = false f.MACSec = true f.Poe = false + f.SystemStatisticsIPv4 = true } // FeaturesForDevice gets the feature set configured for a device diff --git a/main.go b/main.go index d4f7654d..2a1a99ab 100644 --- a/main.go +++ b/main.go @@ -90,6 +90,7 @@ var ( poeEnabled = flag.Bool("poe.enabled", true, "Scrape PoE metrics") krtEnabled = flag.Bool("krt.enabled", false, "Scrape KRT queue metrics") twampEnabled = flag.Bool("twamp.enabled", false, "Scrape TWAMP metrics") + systemstatisticsIPv4Enabled = flag.Bool("systemstatisticsipv4.enabled", true, "Scrape system statistics IPv4 metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager @@ -266,6 +267,7 @@ func loadConfigFromFlags() *config.Config { f.Poe = *poeEnabled f.KRT = *krtEnabled f.TWAMP = *twampEnabled + f.SystemStatisticsIPv4 = *systemstatisticsIPv4Enabled return c } diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go index 75c02c70..963f5f74 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go @@ -10,63 +10,63 @@ const prefix string = "junos_systemstatistics_ipv4_" // Metrics to collect for the feature var ( - packetsReceivedDesc *prometheus.Desc - badHeaderChecksumsDesc *prometheus.Desc - packetsWithSizeSmallerThanMinimumDesc *prometheus.Desc - packetsWithDataSizeLessThanDatalengthDesc *prometheus.Desc - packetsWithHeaderLengthLessThanHeaderlengthDesc *prometheus.Desc - packetsWithIncorrectVersionNumberDesc *prometheus.Desc - packetsDestinedToDeadNextHopDesc *prometheus.Desc - fragmentsReceivedDesc *prometheus.Desc - fragmentsDroppedDueToOutspaceOfDUPDesc *prometheus.Desc - fragmentsDroppedDueToQueueoverflowDesc *prometheus.Desc - fragmentsDroppedAfterTimeoutDesc *prometheus.Desc - packetsReassembledOKDesc *prometheus.Desc - packetsForThisHostDesc *prometheus.Desc - packetsForUnknownOrUnsupportedProtocolDesc *prometheus.Desc - packetsForwardedDesc *prometheus.Desc - packetsNotForwardableDesc *prometheus.Desc - redirectsSentDesc *prometheus.Desc - packetsSentFromThisHostDesc *prometheus.Desc - packetsSentWithFabricatedIPHeaderDesc *prometheus.Desc - outputPacketsDroppedDueToNoBufsDesc *prometheus.Desc - outputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc - outputDatagramsFragmentedDesc *prometheus.Desc - fragmentsCreatedDesc *prometheus.Desc - datagramsThatCanNotBeFragmentedDesc *prometheus.Desc - packetsWithBadOptionsDesc *prometheus.Desc - packetsWithOptionsHandledWithoutErrorDesc *prometheus.Desc - strictSourceAndRecordRouteOptionsDesc *prometheus.Desc - looseSourceAndRecordRouteOptionsDesc *prometheus.Desc - recordRouteOptionsDesc *prometheus.Desc - timestampOptionsDesc *prometheus.Desc - timestampAndAddressOptionsDesc *prometheus.Desc - timestampAndPrespecifiedAddressOptionsDesc *prometheus.Desc - optionPacketsDroppedDueToRateLimitDesc *prometheus.Desc - routerAlertOptionDesc *prometheus.Desc - multicastPacketsDroppedDesc *prometheus.Desc - packetsDroppedDesc *prometheus.Desc - transitREPacketsDroppedonMGMTInterfaceDesc *prometheus.Desc - packetsUsedFirstNexthopInECMPUnilistDesc *prometheus.Desc - incomingTtpoipPacketsReceivedDesc *prometheus.Desc - incomingTtpoipPacketsDroppedDesc *prometheus.Desc - outgoingTtpoipPacketsSentDesc *prometheus.Desc - outgoingTtpoipPacketsDroppedDesc *prometheus.Desc - incomingRawIPPacketsDroppedNoSocketBufferDesc *prometheus.Desc - incomingVirtualNodePacketsDeliveredDesc *prometheus.Desc + packetsReceivedDesc *prometheus.Desc + badHeaderChecksumsDesc *prometheus.Desc + packetsWithSizeSmallerThanMinimumDesc *prometheus.Desc + packetsWithDataSizeLessThanDatalengthDesc *prometheus.Desc + PacketsWithHeaderLengthLessThanDataSizeDesc *prometheus.Desc + packetsWithIncorrectVersionNumberDesc *prometheus.Desc + packetsDestinedToDeadNextHopDesc *prometheus.Desc + fragmentsReceivedDesc *prometheus.Desc + fragmentsDroppedDueToOutspaceOrDUPDesc *prometheus.Desc + fragmentsDroppedDueToQueueoverflowDesc *prometheus.Desc + fragmentsDroppedAfterTimeoutDesc *prometheus.Desc + packetsReassembledOKDesc *prometheus.Desc + packetsForThisHostDesc *prometheus.Desc + packetsForUnknownOrUnsupportedProtocolDesc *prometheus.Desc + packetsForwardedDesc *prometheus.Desc + packetsNotForwardableDesc *prometheus.Desc + redirectsSentDesc *prometheus.Desc + packetsSentFromThisHostDesc *prometheus.Desc + packetsSentWithFabricatedIPHeaderDesc *prometheus.Desc + outputPacketsDroppedDueToNoBufsDesc *prometheus.Desc + outputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc + outputDatagramsFragmentedDesc *prometheus.Desc + fragmentsCreatedDesc *prometheus.Desc + datagramsThatCanNotBeFragmentedDesc *prometheus.Desc + packetsWithBadOptionsDesc *prometheus.Desc + packetsWithOptionsHandledWithoutErrorDesc *prometheus.Desc + strictSourceAndRecordRouteOptionsDesc *prometheus.Desc + looseSourceAndRecordRouteOptionsDesc *prometheus.Desc + recordRouteOptionsDesc *prometheus.Desc + timestampOptionsDesc *prometheus.Desc + timestampAndAddressOptionsDesc *prometheus.Desc + timestampAndPrespecifiedAddressOptionsDesc *prometheus.Desc + optionPacketsDroppedDueToRateLimitDesc *prometheus.Desc + routerAlertOptionDesc *prometheus.Desc + multicastPacketsDroppedDesc *prometheus.Desc + packetsDroppedDesc *prometheus.Desc + transitREPacketsDroppedonMGMTInterfaceDesc *prometheus.Desc + packetsUsedFirstNexthopInECMPUnilistDesc *prometheus.Desc + incomingTtpoipPacketsReceivedDesc *prometheus.Desc + incomingTtpoipPacketsDroppedDesc *prometheus.Desc + outgoingTtpoipPacketsSentDesc *prometheus.Desc + outgoingTtpoipPacketsDroppedDesc *prometheus.Desc + incomingRawIPPacketsDroppedNoSocketBufferDesc *prometheus.Desc + incomingVirtualNodePacketsDeliveredDesc *prometheus.Desc ) func init() { - l := []string{"target"} + l := []string{"target", "protocol"} packetsReceivedDesc = prometheus.NewDesc(prefix+"packets_received", "Number of packets received", l, nil) badHeaderChecksumsDesc = prometheus.NewDesc(prefix+"bad_header_checksums", "Number of packets received with bad header checksums", l, nil) packetsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", l, nil) packetsWithDataSizeLessThanDatalengthDesc = prometheus.NewDesc(prefix+"packets_with_data_size_less_than_datalength", "Number of packets received with data size less than data length", l, nil) - packetsWithHeaderLengthLessThanHeaderlengthDesc = prometheus.NewDesc(prefix+"packets_with_header_length_less_than_headerlength", "Number of packets received with header length less than header length", l, nil) + PacketsWithHeaderLengthLessThanDataSizeDesc = prometheus.NewDesc(prefix+"packets_with_header_length_less_than_data_size", "Number of packets received with header length less than data size", l, nil) packetsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"packets_with_incorrect_version_number", "Number of packets received with incorrect version number", l, nil) packetsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"packets_destined_to_dead_next_hop", "Number of packets received destined to dead next hop", l, nil) fragmentsReceivedDesc = prometheus.NewDesc(prefix+"fragments_received", "Number of fragments received", l, nil) - fragmentsDroppedDueToOutspaceOfDUPDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_outspace_of_dup", "Number of fragments dropped due to outspace of DUP", l, nil) + fragmentsDroppedDueToOutspaceOrDUPDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_outspace_or_dup", "Number of fragments dropped due to outspace or DUP", l, nil) fragmentsDroppedDueToQueueoverflowDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_queueoverflow", "Number of fragments dropped due to queue overflow", l, nil) fragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"fragments_dropped_after_timeout", "Number of fragments dropped after timeout", l, nil) packetsReassembledOKDesc = prometheus.NewDesc(prefix+"packets_reassembled_ok", "Number of packets reassembled OK", l, nil) @@ -111,7 +111,7 @@ func NewCollector() collector.RPCCollector { } func (c *systemstatisticsIPv4Collector) Name() string { - return "systemstatisticsIPv4" + return "systemstatistics" } func (c *systemstatisticsIPv4Collector) Describe(ch chan<- *prometheus.Desc) { @@ -119,11 +119,11 @@ func (c *systemstatisticsIPv4Collector) Describe(ch chan<- *prometheus.Desc) { ch <- badHeaderChecksumsDesc ch <- packetsWithSizeSmallerThanMinimumDesc ch <- packetsWithDataSizeLessThanDatalengthDesc - ch <- packetsWithHeaderLengthLessThanHeaderlengthDesc + ch <- PacketsWithHeaderLengthLessThanDataSizeDesc ch <- packetsWithIncorrectVersionNumberDesc ch <- packetsDestinedToDeadNextHopDesc ch <- fragmentsReceivedDesc - ch <- fragmentsDroppedDueToOutspaceOfDUPDesc + ch <- fragmentsDroppedDueToOutspaceOrDUPDesc ch <- fragmentsDroppedDueToQueueoverflowDesc ch <- fragmentsDroppedAfterTimeoutDesc ch <- packetsReassembledOKDesc @@ -163,9 +163,58 @@ func (c *systemstatisticsIPv4Collector) Describe(ch chan<- *prometheus.Desc) { func (c *systemstatisticsIPv4Collector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { var s StatisticsIPv4 - err := client.RunCommandAndParse("show system statistics ipv", &s) + err := client.RunCommandAndParse("show system statistics ip", &s) if err != nil { return err } + c.collectSystemStatisticsIPv4(ch, labelValues, s) + return nil +} +func (c *systemstatisticsIPv4Collector) collectSystemStatisticsIPv4(ch chan<- prometheus.Metric, labelValues []string, s StatisticsIPv4) { + labels := append(labelValues, "ipv4") + ch <- prometheus.MustNewConstMetric(packetsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsReceived, labels...) + ch <- prometheus.MustNewConstMetric(badHeaderChecksumsDesc, prometheus.CounterValue, s.Statistics.Ip.BadHeaderChecksums, labels...) + ch <- prometheus.MustNewConstMetric(packetsWithSizeSmallerThanMinimumDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, labels...) + ch <- prometheus.MustNewConstMetric(packetsWithDataSizeLessThanDatalengthDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, labels...) + ch <- prometheus.MustNewConstMetric(PacketsWithHeaderLengthLessThanDataSizeDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, labels...) + ch <- prometheus.MustNewConstMetric(packetsWithIncorrectVersionNumberDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithIncorrectVersionNumber, labels...) + ch <- prometheus.MustNewConstMetric(packetsDestinedToDeadNextHopDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsDestinedToDeadNextHop, labels...) + ch <- prometheus.MustNewConstMetric(fragmentsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsReceived, labels...) + ch <- prometheus.MustNewConstMetric(fragmentsDroppedDueToOutspaceOrDUPDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, labels...) + ch <- prometheus.MustNewConstMetric(fragmentsDroppedDueToQueueoverflowDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, labels...) + ch <- prometheus.MustNewConstMetric(fragmentsDroppedAfterTimeoutDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedAfterTimeout, labels...) + ch <- prometheus.MustNewConstMetric(packetsReassembledOKDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsReassembledOk, labels...) + ch <- prometheus.MustNewConstMetric(packetsForThisHostDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForThisHost, labels...) + ch <- prometheus.MustNewConstMetric(packetsForUnknownOrUnsupportedProtocolDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, labels...) + ch <- prometheus.MustNewConstMetric(packetsForwardedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForwarded, labels...) + ch <- prometheus.MustNewConstMetric(packetsNotForwardableDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsNotForwardable, labels...) + ch <- prometheus.MustNewConstMetric(redirectsSentDesc, prometheus.CounterValue, s.Statistics.Ip.RedirectsSent, labels...) + ch <- prometheus.MustNewConstMetric(packetsSentFromThisHostDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsSentFromThisHost, labels...) + ch <- prometheus.MustNewConstMetric(packetsSentWithFabricatedIPHeaderDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsSentWithFabricatedIpHeader, labels...) + ch <- prometheus.MustNewConstMetric(outputPacketsDroppedDueToNoBufsDesc, prometheus.CounterValue, s.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, labels...) + ch <- prometheus.MustNewConstMetric(outputPacketsDiscardedDueToNoRouteDesc, prometheus.CounterValue, s.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, labels...) + ch <- prometheus.MustNewConstMetric(outputDatagramsFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip.OutputDatagramsFragmented, labels...) + ch <- prometheus.MustNewConstMetric(fragmentsCreatedDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsCreated, labels...) + ch <- prometheus.MustNewConstMetric(datagramsThatCanNotBeFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip.DatagramsThatCanNotBeFragmented, labels...) + ch <- prometheus.MustNewConstMetric(packetsWithBadOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithBadOptions, labels...) + ch <- prometheus.MustNewConstMetric(packetsWithOptionsHandledWithoutErrorDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithOptionsHandledWithoutError, labels...) + ch <- prometheus.MustNewConstMetric(strictSourceAndRecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.StrictSourceAndRecordRouteOptions, labels...) + ch <- prometheus.MustNewConstMetric(looseSourceAndRecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.LooseSourceAndRecordRouteOptions, labels...) + ch <- prometheus.MustNewConstMetric(recordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.RecordRouteOptions, labels...) + ch <- prometheus.MustNewConstMetric(timestampOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampOptions, labels...) + ch <- prometheus.MustNewConstMetric(timestampAndAddressOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampAndAddressOptions, labels...) + ch <- prometheus.MustNewConstMetric(timestampAndPrespecifiedAddressOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, labels...) + ch <- prometheus.MustNewConstMetric(optionPacketsDroppedDueToRateLimitDesc, prometheus.CounterValue, s.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, labels...) + ch <- prometheus.MustNewConstMetric(routerAlertOptionDesc, prometheus.CounterValue, s.Statistics.Ip.RouterAlertOptions, labels...) + ch <- prometheus.MustNewConstMetric(multicastPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.MulticastPacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(packetsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(transitREPacketsDroppedonMGMTInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, labels...) + ch <- prometheus.MustNewConstMetric(packetsUsedFirstNexthopInECMPUnilistDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, labels...) + ch <- prometheus.MustNewConstMetric(incomingTtpoipPacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingTtpoipPacketsReceived, labels...) + ch <- prometheus.MustNewConstMetric(incomingTtpoipPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingTtpoipPacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(outgoingTtpoipPacketsSentDesc, prometheus.CounterValue, s.Statistics.Ip.OutgoingTtpoipPacketsSent, labels...) + ch <- prometheus.MustNewConstMetric(outgoingTtpoipPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.OutgoingTtpoipPacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(incomingRawIPPacketsDroppedNoSocketBufferDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, labels...) + ch <- prometheus.MustNewConstMetric(incomingVirtualNodePacketsDeliveredDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingVirtualNodePacketsDelivered, labels...) } diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go index 26a7fa0c..f4278c40 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go @@ -10,51 +10,51 @@ type StatisticsIPv4 struct { Text string `xml:",chardata"` Ip struct { Text string `xml:",chardata"` - PacketsReceived int `xml:"packets-received"` - BadHeaderChecksums int `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum int `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength int `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize int `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength int `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber int `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop int `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived int `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup int `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow int `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout int `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk int `xml:"packets-reassembled-ok"` - PacketsForThisHost int `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol int `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded int `xml:"packets-forwarded"` - PacketsNotForwardable int `xml:"packets-not-forwardable"` - RedirectsSent int `xml:"redirects-sent"` - PacketsSentFromThisHost int `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader int `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs int `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute int `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented int `xml:"output-datagrams-fragmented"` - FragmentsCreated int `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented int `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions int `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError int `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions int `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions int `xml:"loose-source-and-record-route-options"` - RecordRouteOptions int `xml:"record-route-options"` - TimestampOptions int `xml:"timestamp-options"` - TimestampAndAddressOptions int `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions int `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit int `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions int `xml:"router-alert-options"` - MulticastPacketsDropped int `xml:"multicast-packets-dropped"` - PacketsDropped int `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface int `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist int `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived int `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped int `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent int `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped int `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer int `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered int `xml:"incoming-virtual-node-packets-delivered"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` } `xml:"ip"` } `xml:"statistics"` Cli struct { From b3b9438779f95c5d7669f58320d5fa2a3cc851db Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Tue, 15 Jul 2025 14:20:19 +0200 Subject: [PATCH 03/27] small change in name --- pkg/features/systemstatistics/systemstatisticsIPv4/collector.go | 2 +- pkg/features/systemstatistics/systemstatisticsIPv6/collector.go | 1 + pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 pkg/features/systemstatistics/systemstatisticsIPv6/collector.go create mode 100644 pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go index 963f5f74..945eb992 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go @@ -111,7 +111,7 @@ func NewCollector() collector.RPCCollector { } func (c *systemstatisticsIPv4Collector) Name() string { - return "systemstatistics" + return "systemstatisticsIPv4" } func (c *systemstatisticsIPv4Collector) Describe(ch chan<- *prometheus.Desc) { diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go new file mode 100644 index 00000000..c49fb85a --- /dev/null +++ b/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go @@ -0,0 +1 @@ +package systemstatisticsIPv6 diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go new file mode 100644 index 00000000..c49fb85a --- /dev/null +++ b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go @@ -0,0 +1 @@ +package systemstatisticsIPv6 From acf4d72c3b5313e0d5391f047e324e709c80dfc2 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Wed, 16 Jul 2025 10:22:18 +0200 Subject: [PATCH 04/27] added system statistics for ipv6 --- collectors.go | 2 + internal/config/config.go | 2 + main.go | 2 + .../systemstatisticsIPv6/collector.go | 207 ++++++++++++++++++ .../systemstatisticsIPv6/rpc.go | 66 ++++++ 5 files changed, 279 insertions(+) diff --git a/collectors.go b/collectors.go index 1a1d6fb5..8ed32815 100644 --- a/collectors.go +++ b/collectors.go @@ -8,6 +8,7 @@ import ( "github.com/czerwonk/junos_exporter/pkg/features/ddosprotection" "github.com/czerwonk/junos_exporter/pkg/features/poe" "github.com/czerwonk/junos_exporter/pkg/features/systemstatistics/systemstatisticsIPv4" + "github.com/czerwonk/junos_exporter/pkg/features/systemstatistics/systemstatisticsIPv6" "github.com/czerwonk/junos_exporter/internal/config" "github.com/czerwonk/junos_exporter/pkg/collector" @@ -132,6 +133,7 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device, descRe * c.addCollectorIfEnabledForDevice(device, "krt", f.KRT, krt.NewCollector) c.addCollectorIfEnabledForDevice(device, "twamp", f.TWAMP, twamp.NewCollector) c.addCollectorIfEnabledForDevice(device, "system_statistics_ipv4", f.SystemStatisticsIPv4, systemstatisticsIPv4.NewCollector) + c.addCollectorIfEnabledForDevice(device, "system_statistics_ipv6", f.SystemStatisticsIPv6, systemstatisticsIPv6.NewCollector) } func (c *collectors) addCollectorIfEnabledForDevice(device *connector.Device, key string, enabled bool, newCollector func() collector.RPCCollector) { diff --git a/internal/config/config.go b/internal/config/config.go index df066fe4..b3f414a4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -104,6 +104,7 @@ type FeatureConfig struct { KRT bool `yaml:"krt,omitempty"` TWAMP bool `yaml:"twamp,omitempty"` SystemStatisticsIPv4 bool `yaml:"system_statistics_ipv4,omitempty"` + SystemStatisticsIPv6 bool `yaml:"system_statistics_ipv6,omitempty"` } // New creates a new config @@ -184,6 +185,7 @@ func setDefaultValues(c *Config) { f.MACSec = true f.Poe = false f.SystemStatisticsIPv4 = true + f.SystemStatisticsIPv6 = true } // FeaturesForDevice gets the feature set configured for a device diff --git a/main.go b/main.go index 2a1a99ab..9bb53309 100644 --- a/main.go +++ b/main.go @@ -91,6 +91,7 @@ var ( krtEnabled = flag.Bool("krt.enabled", false, "Scrape KRT queue metrics") twampEnabled = flag.Bool("twamp.enabled", false, "Scrape TWAMP metrics") systemstatisticsIPv4Enabled = flag.Bool("systemstatisticsipv4.enabled", true, "Scrape system statistics IPv4 metrics") + systemstatisticsIPv6Enabled = flag.Bool("systemstatisticsipv6.enabled", true, "Scrape system statistics IPv6 metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager @@ -268,6 +269,7 @@ func loadConfigFromFlags() *config.Config { f.KRT = *krtEnabled f.TWAMP = *twampEnabled f.SystemStatisticsIPv4 = *systemstatisticsIPv4Enabled + f.SystemStatisticsIPv6 = *systemstatisticsIPv6Enabled return c } diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go index c49fb85a..cee440dd 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go @@ -1 +1,208 @@ package systemstatisticsIPv6 + +import ( + "github.com/prometheus/client_golang/prometheus" + + "github.com/czerwonk/junos_exporter/pkg/collector" +) + +const prefix string = "junos_systemstatistics_ipv6_" + +// Metrics to collect for the feature +var ( + totalPacketsReceivedDesc *prometheus.Desc + ip6PacketsWithSizeSmallerThanMinimumDesc *prometheus.Desc + packetsWithDatasizeLessThanDataLengthDesc *prometheus.Desc + ip6PacketsWithBadOptionsDesc *prometheus.Desc + ip6PacketsWithIncorrectVersionNumberDesc *prometheus.Desc + ip6FragmentsReceivedDesc *prometheus.Desc + duplicateOrOutOfSpaceFragmentsDroppedDesc *prometheus.Desc + ip6FragmentsDroppedAfterTimeoutDesc *prometheus.Desc + fragmentsThatExceededLimitDesc *prometheus.Desc + ip6PacketsReassembledOkDesc *prometheus.Desc + ip6PacketsForThisHostDesc *prometheus.Desc + ip6PacketsForwardedDesc *prometheus.Desc + ip6PacketsNotForwardableDesc *prometheus.Desc + ip6RedirectsSentDesc *prometheus.Desc + ip6PacketsSentFromThisHostDesc *prometheus.Desc + ip6PacketsSentWithFabricatedIpHeaderDesc *prometheus.Desc + ip6OutputPacketsDroppedDueToNoBufsDesc *prometheus.Desc + ip6OutputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc + ip6OutputDatagramsFragmentedDesc *prometheus.Desc + ip6FragmentsCreatedDesc *prometheus.Desc + ip6DatagramsThatCanNotBeFragmentedDesc *prometheus.Desc + packetsThatViolatedScopeRulesDesc *prometheus.Desc + multicastPacketsWhichWeDoNotJoinDesc *prometheus.Desc + ip6nhTcpDesc *prometheus.Desc + ip6nhUdpDesc *prometheus.Desc + ip6nhIcmp6Desc *prometheus.Desc + packetsWhoseHeadersAreNotContinuousDesc *prometheus.Desc + tunnelingPacketsThatCanNotFindGifDesc *prometheus.Desc + packetsDiscardedDueToTooMayHeadersDesc *prometheus.Desc + failuresOfSourceAddressSelectionDesc *prometheus.Desc + headerTypeLinkLocalsDesc *prometheus.Desc + headerTypeGlobalsDesc *prometheus.Desc + forwardCacheHitDesc *prometheus.Desc + forwardCacheMissDesc *prometheus.Desc + ip6PacketsDestinedToDeadNextHopDesc *prometheus.Desc + ip6OptionPacketsDroppedDueToRateLimitDesc *prometheus.Desc + ip6PacketsDroppedDesc *prometheus.Desc + packetsDroppedDueToBadProtocolDesc *prometheus.Desc + transitRePacketDroppedOnMgmtInterfaceDesc *prometheus.Desc + packetUsedFirstNexthopInEcmpUnilistDesc *prometheus.Desc +) + +func init() { + labels := []string{"target", "protocol"} + totalPacketsReceivedDesc = prometheus.NewDesc(prefix+"total_packets_received", "Total number of packets received", labels, nil) + ip6PacketsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"ip6_packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", labels, nil) + packetsWithDatasizeLessThanDataLengthDesc = prometheus.NewDesc(prefix+"packets_with_datasize_less_than_data_length", "Number of packets received with data length less than data length", labels, nil) + ip6PacketsWithBadOptionsDesc = prometheus.NewDesc(prefix+"ip6_packets_with_bad_options", "Number of packets received with bad options", labels, nil) + ip6PacketsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"ip6_packets_with_incorrect_version_number", "Number of packets received with incorrect version number", labels, nil) + ip6FragmentsReceivedDesc = prometheus.NewDesc(prefix+"ip6_fragments_received", "Number of fragments received", labels, nil) + duplicateOrOutOfSpaceFragmentsDroppedDesc = prometheus.NewDesc(prefix+"duplicate_or_out_of_space_fragments_dropped", "Number of duplicate or out of space fragments dropped", labels, nil) + ip6FragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"ip6_fragments_dropped_after_timeout", "Number of fragments dropped after timeout", labels, nil) + fragmentsThatExceededLimitDesc = prometheus.NewDesc(prefix+"fragments_that_exceeded_limit", "Number of fragments that exceeded limit", labels, nil) + ip6PacketsReassembledOkDesc = prometheus.NewDesc(prefix+"ip6_packets_reassembled_ok", "Number of packets reassembled ok", labels, nil) + ip6PacketsForThisHostDesc = prometheus.NewDesc(prefix+"ip6_packets_for_this_host", "Number of packets for this host", labels, nil) + ip6PacketsForwardedDesc = prometheus.NewDesc(prefix+"ip6_packets_forwarded", "Number of packets forwarded", labels, nil) + ip6PacketsNotForwardableDesc = prometheus.NewDesc(prefix+"ip6_packets_not_forwardable", "Number of packets not forwardable", labels, nil) + ip6RedirectsSentDesc = prometheus.NewDesc(prefix+"ip6_redirects_sent", "Number of redirects sent", labels, nil) + ip6PacketsSentFromThisHostDesc = prometheus.NewDesc(prefix+"ip6_packets_sent_from_this_host", "Number of packets sent from this host", labels, nil) + ip6PacketsSentWithFabricatedIpHeaderDesc = prometheus.NewDesc(prefix+"ip6_packets_sent_with_fabricated_ip_header", "Number of packets sent with fabricated ip header", labels, nil) + ip6OutputPacketsDroppedDueToNoBufsDesc = prometheus.NewDesc(prefix+"ip6_output_packets_dropped_due_to_no_bufs", "Number of output packets dropped due to no bufs", labels, nil) + ip6OutputPacketsDiscardedDueToNoRouteDesc = prometheus.NewDesc(prefix+"ip6_output_packets_discarded_due_to_no_route", "Number of output packets discarded due to no route", labels, nil) + ip6OutputDatagramsFragmentedDesc = prometheus.NewDesc(prefix+"ip6_output_datagrams_fragmented", "Number of output datagrams fragmented", labels, nil) + ip6FragmentsCreatedDesc = prometheus.NewDesc(prefix+"ip6_fragments_created", "Number of fragments created", labels, nil) + ip6DatagramsThatCanNotBeFragmentedDesc = prometheus.NewDesc(prefix+"ip6_datagrams_that_can_not_be_fragmented", "Number of datagrams that can not be fragmented", labels, nil) + packetsThatViolatedScopeRulesDesc = prometheus.NewDesc(prefix+"packets_that_violated_scope_rules", "Number of packets that violated scope rules", labels, nil) + multicastPacketsWhichWeDoNotJoinDesc = prometheus.NewDesc(prefix+"multicast_packets_which_we_do_not_join", "Number of multicast packets which we do not join", labels, nil) + ip6nhTcpDesc = prometheus.NewDesc(prefix+"ip6nh_tcp", "Number of packets with next header tcp", labels, nil) + ip6nhUdpDesc = prometheus.NewDesc(prefix+"ip6nh_udp", "Number of packets with next header udp", labels, nil) + ip6nhIcmp6Desc = prometheus.NewDesc(prefix+"ip6nh_icmp6", "Number of packets with next header icmp6", labels, nil) + packetsWhoseHeadersAreNotContinuousDesc = prometheus.NewDesc(prefix+"packets_whose_headers_are_not_continuous", "Number of packets whose headers are not continuous", labels, nil) + tunnelingPacketsThatCanNotFindGifDesc = prometheus.NewDesc(prefix+"tunneling_packets_that_can_not_find_gif", "Number of tunneling packets that can not find gif", labels, nil) + packetsDiscardedDueToTooMayHeadersDesc = prometheus.NewDesc(prefix+"packets_discarded_due_to_too_may_headers", "Number of packets discarded due to too may headers", labels, nil) + failuresOfSourceAddressSelectionDesc = prometheus.NewDesc(prefix+"failures_of_source_address_selection", "Number of failures of source address selection", labels, nil) + l := []string{"target", "protocol", "header_type"} + headerTypeLinkLocalsDesc = prometheus.NewDesc(prefix+"header_type_link_locals", "Number of packets with header type link locals", l, nil) + headerTypeGlobalsDesc = prometheus.NewDesc(prefix+"header_type_globals", "Number of packets with header type globals", l, nil) + forwardCacheHitDesc = prometheus.NewDesc(prefix+"forward_cache_hit", "Number of forward cache hit", labels, nil) + forwardCacheMissDesc = prometheus.NewDesc(prefix+"forward_cache_miss", "Number of forward cache miss", labels, nil) + ip6PacketsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"ip6_packets_destined_to_dead_next_hop", "Number of packets destined to dead next hop", labels, nil) + ip6OptionPacketsDroppedDueToRateLimitDesc = prometheus.NewDesc(prefix+"ip6_option_packets_dropped_due_to_rate_limit", "Number of option packets dropped due to rate limit", labels, nil) + ip6PacketsDroppedDesc = prometheus.NewDesc(prefix+"ip6_packets_dropped", "Number of packets dropped", labels, nil) + packetsDroppedDueToBadProtocolDesc = prometheus.NewDesc(prefix+"packets_dropped_due_to_bad_protocol", "Number of packets dropped due to bad protocol", labels, nil) + transitRePacketDroppedOnMgmtInterfaceDesc = prometheus.NewDesc(prefix+"transit_re_packet_dropped_on_mgmt_interface", "Number of transit re packet dropped on mgmt interface", labels, nil) + packetUsedFirstNexthopInEcmpUnilistDesc = prometheus.NewDesc(prefix+"packet_used_first_nexthop_in_ecmp_unilist", "Number of packet used first nexthop in ecmp unilist", labels, nil) +} + +type systemstatisticsIPv6Collector struct{} + +func NewCollector() collector.RPCCollector { + return &systemstatisticsIPv6Collector{} +} + +func (c *systemstatisticsIPv6Collector) Name() string { + return "systemstatisticsIPv6" +} + +func (c *systemstatisticsIPv6Collector) Describe(ch chan<- *prometheus.Desc) { + ch <- totalPacketsReceivedDesc + ch <- ip6PacketsWithSizeSmallerThanMinimumDesc + ch <- packetsWithDatasizeLessThanDataLengthDesc + ch <- ip6PacketsWithBadOptionsDesc + ch <- ip6PacketsWithIncorrectVersionNumberDesc + ch <- ip6FragmentsReceivedDesc + ch <- duplicateOrOutOfSpaceFragmentsDroppedDesc + ch <- ip6FragmentsDroppedAfterTimeoutDesc + ch <- fragmentsThatExceededLimitDesc + ch <- ip6PacketsReassembledOkDesc + ch <- ip6PacketsForThisHostDesc + ch <- ip6PacketsForwardedDesc + ch <- ip6PacketsNotForwardableDesc + ch <- ip6RedirectsSentDesc + ch <- ip6PacketsSentFromThisHostDesc + ch <- ip6PacketsSentWithFabricatedIpHeaderDesc + ch <- ip6OutputPacketsDroppedDueToNoBufsDesc + ch <- ip6OutputPacketsDiscardedDueToNoRouteDesc + ch <- ip6OutputDatagramsFragmentedDesc + ch <- ip6FragmentsCreatedDesc + ch <- ip6DatagramsThatCanNotBeFragmentedDesc + ch <- packetsThatViolatedScopeRulesDesc + ch <- multicastPacketsWhichWeDoNotJoinDesc + ch <- ip6nhTcpDesc + ch <- ip6nhUdpDesc + ch <- ip6nhIcmp6Desc + ch <- packetsWhoseHeadersAreNotContinuousDesc + ch <- tunnelingPacketsThatCanNotFindGifDesc + ch <- packetsDiscardedDueToTooMayHeadersDesc + ch <- failuresOfSourceAddressSelectionDesc + ch <- headerTypeLinkLocalsDesc + ch <- headerTypeGlobalsDesc + ch <- forwardCacheHitDesc + ch <- forwardCacheMissDesc + ch <- ip6PacketsDestinedToDeadNextHopDesc + ch <- ip6OptionPacketsDroppedDueToRateLimitDesc + ch <- ip6PacketsDroppedDesc + ch <- packetsDroppedDueToBadProtocolDesc + ch <- transitRePacketDroppedOnMgmtInterfaceDesc + ch <- packetUsedFirstNexthopInEcmpUnilistDesc +} + +func (c *systemstatisticsIPv6Collector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var s StatisticsIPv6 + err := client.RunCommandAndParse("show system statistics ip6", &s) + if err != nil { + return err + } + c.collectSystemStatisticsIPv6(ch, labelValues, s) + return nil +} + +func (c *systemstatisticsIPv6Collector) collectSystemStatisticsIPv6(ch chan<- prometheus.Metric, labelValues []string, s StatisticsIPv6) { + labels := append(labelValues, "ipv6") + ch <- prometheus.MustNewConstMetric(totalPacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip6.TotalPacketsReceived, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsWithSizeSmallerThanMinimumDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithSizeSmallerThanMinimum, labels...) + ch <- prometheus.MustNewConstMetric(packetsWithDatasizeLessThanDataLengthDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsWithDatasizeLessThanDataLength, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsWithBadOptionsDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithBadOptions, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsWithIncorrectVersionNumberDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithIncorrectVersionNumber, labels...) + ch <- prometheus.MustNewConstMetric(ip6FragmentsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsReceived, labels...) + ch <- prometheus.MustNewConstMetric(duplicateOrOutOfSpaceFragmentsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip6.DuplicateOrOutOfSpaceFragmentsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ip6FragmentsDroppedAfterTimeoutDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsDroppedAfterTimeout, labels...) + ch <- prometheus.MustNewConstMetric(fragmentsThatExceededLimitDesc, prometheus.CounterValue, s.Statistics.Ip6.FragmentsThatExceededLimit, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsReassembledOkDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsReassembledOk, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsForThisHostDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsForThisHost, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsForwardedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsForwarded, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsNotForwardableDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsNotForwardable, labels...) + ch <- prometheus.MustNewConstMetric(ip6RedirectsSentDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6RedirectsSent, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsSentFromThisHostDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsSentFromThisHost, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsSentWithFabricatedIpHeaderDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsSentWithFabricatedIpHeader, labels...) + ch <- prometheus.MustNewConstMetric(ip6OutputPacketsDroppedDueToNoBufsDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputPacketsDroppedDueToNoBufs, labels...) + ch <- prometheus.MustNewConstMetric(ip6OutputPacketsDiscardedDueToNoRouteDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputPacketsDiscardedDueToNoRoute, labels...) + ch <- prometheus.MustNewConstMetric(ip6OutputDatagramsFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputDatagramsFragmented, labels...) + ch <- prometheus.MustNewConstMetric(ip6FragmentsCreatedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsCreated, labels...) + ch <- prometheus.MustNewConstMetric(ip6DatagramsThatCanNotBeFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6DatagramsThatCanNotBeFragmented, labels...) + ch <- prometheus.MustNewConstMetric(packetsThatViolatedScopeRulesDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsThatViolatedScopeRules, labels...) + ch <- prometheus.MustNewConstMetric(multicastPacketsWhichWeDoNotJoinDesc, prometheus.CounterValue, s.Statistics.Ip6.MulticastPacketsWhichWeDoNotJoin, labels...) + ch <- prometheus.MustNewConstMetric(ip6nhTcpDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhTcp, labels...) + ch <- prometheus.MustNewConstMetric(ip6nhUdpDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhUdp, labels...) + ch <- prometheus.MustNewConstMetric(ip6nhIcmp6Desc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhIcmp6, labels...) + ch <- prometheus.MustNewConstMetric(packetsWhoseHeadersAreNotContinuousDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsWhoseHeadersAreNotContinuous, labels...) + ch <- prometheus.MustNewConstMetric(tunnelingPacketsThatCanNotFindGifDesc, prometheus.CounterValue, s.Statistics.Ip6.TunnelingPacketsThatCanNotFindGif, labels...) + ch <- prometheus.MustNewConstMetric(packetsDiscardedDueToTooMayHeadersDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsDiscardedDueToTooMayHeaders, labels...) + ch <- prometheus.MustNewConstMetric(failuresOfSourceAddressSelectionDesc, prometheus.CounterValue, s.Statistics.Ip6.FailuresOfSourceAddressSelection, labels...) + for _, header := range s.Statistics.Ip6.HeaderType { + labels := append(labelValues, "ipv6", header.HeaderForSourceAddressSelection) + ch <- prometheus.MustNewConstMetric(headerTypeLinkLocalsDesc, prometheus.CounterValue, header.LinkLocals, labels...) + ch <- prometheus.MustNewConstMetric(headerTypeGlobalsDesc, prometheus.CounterValue, header.Globals, labels...) + } + ch <- prometheus.MustNewConstMetric(forwardCacheHitDesc, prometheus.CounterValue, s.Statistics.Ip6.ForwardCacheHit, labels...) + ch <- prometheus.MustNewConstMetric(forwardCacheMissDesc, prometheus.CounterValue, s.Statistics.Ip6.ForwardCacheMiss, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsDestinedToDeadNextHopDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsDestinedToDeadNextHop, labels...) + ch <- prometheus.MustNewConstMetric(ip6OptionPacketsDroppedDueToRateLimitDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OptionPacketsDroppedDueToRateLimit, labels...) + ch <- prometheus.MustNewConstMetric(ip6PacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(packetsDroppedDueToBadProtocolDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsDroppedDueToBadProtocol, labels...) + ch <- prometheus.MustNewConstMetric(transitRePacketDroppedOnMgmtInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip6.TransitRePacketDroppedOnMgmtInterface, labels...) + ch <- prometheus.MustNewConstMetric(packetUsedFirstNexthopInEcmpUnilistDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketUsedFirstNexthopInEcmpUnilist, labels...) +} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go index c49fb85a..1a75b1de 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go @@ -1 +1,67 @@ package systemstatisticsIPv6 + +import "encoding/xml" + +type StatisticsIPv6 struct { + XMLName xml.Name `xml:"rpc-reply"` + Text string `xml:",chardata"` + Junos string `xml:"junos,attr"` + Statistics struct { + Text string `xml:",chardata"` + Ip6 struct { + Text string `xml:",chardata"` + TotalPacketsReceived float64 `xml:"total-packets-received"` + Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` + PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` + Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` + Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` + Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` + DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` + Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` + FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` + Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` + Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` + Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` + Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` + Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` + Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` + Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` + Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` + Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` + Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` + Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` + Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` + PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` + MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` + Histogram string `xml:"histogram"` + Ip6nhTcp float64 `xml:"ip6nh-tcp"` + Ip6nhUdp float64 `xml:"ip6nh-udp"` + Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` + PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` + TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` + PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` + FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` + HeaderType []struct { + Text string `xml:",chardata"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + LinkLocals float64 `xml:"link-locals"` + Globals float64 `xml:"globals"` + AddressScope string `xml:"address-scope"` + HexValue string `xml:"hex-value"` + } `xml:"header-type"` + ForwardCacheHit float64 `xml:"forward-cache-hit"` + ForwardCacheMiss float64 `xml:"forward-cache-miss"` + Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` + Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` + Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` + PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` + TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` + PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` + } `xml:"ip6"` + } `xml:"statistics"` + Cli struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + } `xml:"cli"` +} + From 5547ba83175420c635d961a6ffb8529a71dc7d66 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 24 Jul 2025 14:21:58 +0200 Subject: [PATCH 05/27] saving progress in tests --- .../systemstatisticsIPv4/rpc_test.go | 690 ++++++++++++++++++ 1 file changed, 690 insertions(+) create mode 100644 pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go new file mode 100644 index 00000000..48519325 --- /dev/null +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go @@ -0,0 +1,690 @@ +package systemstatisticsIPv4 + +import ( + "encoding/xml" + "testing" +) + +func TestStatisticsIPv4Unmarshaling(t *testing.T) { + //there is an array of tests called tests which has 3 elements + //each element includes the name, the xml input(example of device config) + //and expected result. First element is regular values, second one is zero values and + //third one is different big numbers + tests := []struct { + name string + xmlInput string + expected StatisticsIPv4 + }{ + { + name: "complete_ipv4_statistics", + xmlInput: ` + + + 1000 + 5 + 10 + 2 + 3 + 1 + 0 + 0 + 50 + 2 + 1 + 0 + 48 + 500 + 5 + 400 + 10 + 2 + 800 + 0 + 3 + 1 + 20 + 40 + 2 + 1 + 15 + 0 + 2 + 5 + 3 + 1 + 0 + 0 + 4 + 8 + 12 + 0 + 25 + 100 + 2 + 95 + 1 + 3 + 200 + + + + user@router> + + `, + expected: StatisticsIPv4{ + Statistics: struct { + Text string `xml:",chardata"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + }{ + Ip: struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + }{ + PacketsReceived: 1000, + BadHeaderChecksums: 5, + PacketsWithSizeSmallerThanMinimum: 10, + PacketsWithDataSizeLessThanDatalength: 2, + PacketsWithHeaderLengthLessThanDataSize: 3, + PacketsWithDataLengthLessThanHeaderlength: 1, + PacketsWithIncorrectVersionNumber: 0, + PacketsDestinedToDeadNextHop: 0, + FragmentsReceived: 50, + FragmentsDroppedDueToOutofspaceOrDup: 2, + FragmentsDroppedDueToQueueoverflow: 1, + FragmentsDroppedAfterTimeout: 0, + PacketsReassembledOk: 48, + PacketsForThisHost: 500, + PacketsForUnknownOrUnsupportedProtocol: 5, + PacketsForwarded: 400, + PacketsNotForwardable: 10, + RedirectsSent: 2, + PacketsSentFromThisHost: 800, + PacketsSentWithFabricatedIpHeader: 0, + OutputPacketsDroppedDueToNoBufs: 3, + OutputPacketsDiscardedDueToNoRoute: 1, + OutputDatagramsFragmented: 20, + FragmentsCreated: 40, + DatagramsThatCanNotBeFragmented: 2, + PacketsWithBadOptions: 1, + PacketsWithOptionsHandledWithoutError: 15, + StrictSourceAndRecordRouteOptions: 0, + LooseSourceAndRecordRouteOptions: 2, + RecordRouteOptions: 5, + TimestampOptions: 3, + TimestampAndAddressOptions: 1, + TimestampAndPrespecifiedAddressOptions: 0, + OptionPacketsDroppedDueToRateLimit: 0, + RouterAlertOptions: 4, + MulticastPacketsDropped: 8, + PacketsDropped: 12, + TransitRePacketsDroppedOnMgmtInterface: 0, + PacketsUsedFirstNexthopInEcmpUnilist: 25, + IncomingTtpoipPacketsReceived: 100, + IncomingTtpoipPacketsDropped: 2, + OutgoingTtpoipPacketsSent: 95, + OutgoingTtpoipPacketsDropped: 1, + IncomingRawipPacketsDroppedNoSocketBuffer: 3, + IncomingVirtualNodePacketsDelivered: 200, + }, + }, + Cli: struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + }{ + Banner: "user@router>", + }, + }, + }, + { + name: "empty_ipv4_statistics", + xmlInput: ` + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + user@router> + + `, + expected: StatisticsIPv4{ + Statistics: struct { + Text string `xml:",chardata"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + }{ + Ip: struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + }{ + // All fields are zero by default + }, + }, + Cli: struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + }{ + Banner: "user@router>", + }, + }, + }, + { + name: "high_values_ipv4_statistics", + xmlInput: ` + + + 999999999 + 12345 + 54321 + 1111 + 2222 + 3333 + 4444 + 5555 + 888888 + 6666 + 7777 + 8888 + 777777 + 555555 + 9999 + 444444 + 11111 + 12121 + 666666 + 13131 + 14141 + 15151 + 16161 + 17171 + 18181 + 19191 + 20202 + 21212 + 22222 + 23232 + 24242 + 25252 + 26262 + 27272 + 28282 + 29292 + 30303 + 31313 + 32323 + 33333 + 34343 + 35353 + 36363 + 37373 + 38383 + + + + admin@high-traffic-router> + + `, + expected: StatisticsIPv4{ + Statistics: struct { + Text string `xml:",chardata"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + }{ + Ip: struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + }{ + PacketsReceived: 999999999, + BadHeaderChecksums: 12345, + PacketsWithSizeSmallerThanMinimum: 54321, + PacketsWithDataSizeLessThanDatalength: 1111, + PacketsWithHeaderLengthLessThanDataSize: 2222, + PacketsWithDataLengthLessThanHeaderlength: 3333, + PacketsWithIncorrectVersionNumber: 4444, + PacketsDestinedToDeadNextHop: 5555, + FragmentsReceived: 888888, + FragmentsDroppedDueToOutofspaceOrDup: 6666, + FragmentsDroppedDueToQueueoverflow: 7777, + FragmentsDroppedAfterTimeout: 8888, + PacketsReassembledOk: 777777, + PacketsForThisHost: 555555, + PacketsForUnknownOrUnsupportedProtocol: 9999, + PacketsForwarded: 444444, + PacketsNotForwardable: 11111, + RedirectsSent: 12121, + PacketsSentFromThisHost: 666666, + PacketsSentWithFabricatedIpHeader: 13131, + OutputPacketsDroppedDueToNoBufs: 14141, + OutputPacketsDiscardedDueToNoRoute: 15151, + OutputDatagramsFragmented: 16161, + FragmentsCreated: 17171, + DatagramsThatCanNotBeFragmented: 18181, + PacketsWithBadOptions: 19191, + PacketsWithOptionsHandledWithoutError: 20202, + StrictSourceAndRecordRouteOptions: 21212, + LooseSourceAndRecordRouteOptions: 22222, + RecordRouteOptions: 23232, + TimestampOptions: 24242, + TimestampAndAddressOptions: 25252, + TimestampAndPrespecifiedAddressOptions: 26262, + OptionPacketsDroppedDueToRateLimit: 27272, + RouterAlertOptions: 28282, + MulticastPacketsDropped: 29292, + PacketsDropped: 30303, + TransitRePacketsDroppedOnMgmtInterface: 31313, + PacketsUsedFirstNexthopInEcmpUnilist: 32323, + IncomingTtpoipPacketsReceived: 33333, + IncomingTtpoipPacketsDropped: 34343, + OutgoingTtpoipPacketsSent: 35353, + OutgoingTtpoipPacketsDropped: 36363, + IncomingRawipPacketsDroppedNoSocketBuffer: 37373, + IncomingVirtualNodePacketsDelivered: 38383, + }, + }, + Cli: struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + }{ + Banner: "admin@high-traffic-router>", + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var result StatisticsIPv4 + err := xml.Unmarshal([]byte(tt.xmlInput), &result) + if err != nil { + t.Fatalf("Failed to unmarshal XML: %v", err) + } + + // Test individual fields + if result.Statistics.Ip.PacketsReceived != tt.expected.Statistics.Ip.PacketsReceived { + t.Errorf("PacketsReceived = %v, want %v", result.Statistics.Ip.PacketsReceived, tt.expected.Statistics.Ip.PacketsReceived) + } + if result.Statistics.Ip.BadHeaderChecksums != tt.expected.Statistics.Ip.BadHeaderChecksums { + t.Errorf("BadHeaderChecksums = %v, want %v", result.Statistics.Ip.BadHeaderChecksums, tt.expected.Statistics.Ip.BadHeaderChecksums) + } + if result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum != tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum { + t.Errorf("PacketsWithSizeSmallerThanMinimum = %v, want %v", result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum) + } + if result.Statistics.Ip.FragmentsReceived != tt.expected.Statistics.Ip.FragmentsReceived { + t.Errorf("FragmentsReceived = %v, want %v", result.Statistics.Ip.FragmentsReceived, tt.expected.Statistics.Ip.FragmentsReceived) + } + if result.Statistics.Ip.PacketsForwarded != tt.expected.Statistics.Ip.PacketsForwarded { + t.Errorf("PacketsForwarded = %v, want %v", result.Statistics.Ip.PacketsForwarded, tt.expected.Statistics.Ip.PacketsForwarded) + } + if result.Statistics.Ip.IncomingTtpoipPacketsReceived != tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived { + t.Errorf("IncomingTtpoipPacketsReceived = %v, want %v", result.Statistics.Ip.IncomingTtpoipPacketsReceived, tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived) + } + if result.Cli.Banner != tt.expected.Cli.Banner { + t.Errorf("Banner = %v, want %v", result.Cli.Banner, tt.expected.Cli.Banner) + } + }) + } +} + +func TestStatisticsIPv4UnmarshalingErrorCases(t *testing.T) { + tests := []struct { + name string + xmlInput string + wantErr bool + }{ + { + name: "invalid_xml", + xmlInput: ``, + wantErr: true, + }, + { + name: "empty_xml", + xmlInput: ``, + wantErr: true, + }, + { + name: "missing_statistics_section", + xmlInput: ` + + user@router> + + `, + wantErr: false, // Should not error, just have empty statistics + }, + { + name: "missing_ip_section", + xmlInput: ` + + + + user@router> + + `, + wantErr: false, // Should not error, just have empty IP statistics + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var result StatisticsIPv4 + err := xml.Unmarshal([]byte(tt.xmlInput), &result) + if (err != nil) != tt.wantErr { + t.Errorf("xml.Unmarshal() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} From bc0f32e81463a123c0d9a9b92413960945d35ae7 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 24 Jul 2025 17:14:04 +0200 Subject: [PATCH 06/27] added tests for systemstatisticsIPv6 --- .../systemstatisticsIPv6/rpc_test.go | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go new file mode 100644 index 00000000..15f29ddb --- /dev/null +++ b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go @@ -0,0 +1,178 @@ +package systemstatisticsIPv6 + +import ( + "encoding/xml" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestStatisticsIPv6Unmarshaling_AllNumericalFields(t *testing.T) { + tests := []struct { + name string + xmlInput string + expected map[string]float64 + }{ + { + name: "all_fields_nonzero", + xmlInput: ` + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + + + `, + expected: map[string]float64{ + "TotalPacketsReceived": 1, + "Ip6PacketsWithSizeSmallerThanMinimum": 2, + "PacketsWithDatasizeLessThanDataLength": 3, + "Ip6PacketsWithBadOptions": 4, + "Ip6PacketsWithIncorrectVersionNumber": 5, + "Ip6FragmentsReceived": 6, + "DuplicateOrOutOfSpaceFragmentsDropped": 7, + "Ip6FragmentsDroppedAfterTimeout": 8, + "FragmentsThatExceededLimit": 9, + "Ip6PacketsReassembledOk": 10, + "Ip6PacketsForThisHost": 11, + "Ip6PacketsForwarded": 12, + "Ip6PacketsNotForwardable": 13, + "Ip6RedirectsSent": 14, + "Ip6PacketsSentFromThisHost": 15, + "Ip6PacketsSentWithFabricatedIpHeader": 16, + "Ip6OutputPacketsDroppedDueToNoBufs": 17, + "Ip6OutputPacketsDiscardedDueToNoRoute": 18, + "Ip6OutputDatagramsFragmented": 19, + "Ip6FragmentsCreated": 20, + "Ip6DatagramsThatCanNotBeFragmented": 21, + "PacketsThatViolatedScopeRules": 22, + "MulticastPacketsWhichWeDoNotJoin": 23, + "Ip6nhTcp": 24, + "Ip6nhUdp": 25, + "Ip6nhIcmp6": 26, + }, + }, + { + name: "all_fields_zero", + xmlInput: ` + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + `, + expected: map[string]float64{ + "TotalPacketsReceived": 0, + "Ip6PacketsWithSizeSmallerThanMinimum": 0, + "PacketsWithDatasizeLessThanDataLength": 0, + "Ip6PacketsWithBadOptions": 0, + "Ip6PacketsWithIncorrectVersionNumber": 0, + "Ip6FragmentsReceived": 0, + "DuplicateOrOutOfSpaceFragmentsDropped": 0, + "Ip6FragmentsDroppedAfterTimeout": 0, + "FragmentsThatExceededLimit": 0, + "Ip6PacketsReassembledOk": 0, + "Ip6PacketsForThisHost": 0, + "Ip6PacketsForwarded": 0, + "Ip6PacketsNotForwardable": 0, + "Ip6RedirectsSent": 0, + "Ip6PacketsSentFromThisHost": 0, + "Ip6PacketsSentWithFabricatedIpHeader": 0, + "Ip6OutputPacketsDroppedDueToNoBufs": 0, + "Ip6OutputPacketsDiscardedDueToNoRoute": 0, + "Ip6OutputDatagramsFragmented": 0, + "Ip6FragmentsCreated": 0, + "Ip6DatagramsThatCanNotBeFragmented": 0, + "PacketsThatViolatedScopeRules": 0, + "MulticastPacketsWhichWeDoNotJoin": 0, + "Ip6nhTcp": 0, + "Ip6nhUdp": 0, + "Ip6nhIcmp6": 0, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var actual StatisticsIPv6 + err := xml.Unmarshal([]byte(tt.xmlInput), &actual) + assert.NoError(t, err) + + assert.Equal(t, tt.expected["TotalPacketsReceived"], actual.Statistics.Ip6.TotalPacketsReceived, "TotalPacketsReceived mismatch") + assert.Equal(t, tt.expected["Ip6PacketsWithSizeSmallerThanMinimum"], actual.Statistics.Ip6.Ip6PacketsWithSizeSmallerThanMinimum, "Ip6PacketsWithSizeSmallerThanMinimum mismatch") + assert.Equal(t, tt.expected["PacketsWithDatasizeLessThanDataLength"], actual.Statistics.Ip6.PacketsWithDatasizeLessThanDataLength, "PacketsWithDatasizeLessThanDataLength mismatch") + assert.Equal(t, tt.expected["Ip6PacketsWithBadOptions"], actual.Statistics.Ip6.Ip6PacketsWithBadOptions, "Ip6PacketsWithBadOptions mismatch") + assert.Equal(t, tt.expected["Ip6PacketsWithIncorrectVersionNumber"], actual.Statistics.Ip6.Ip6PacketsWithIncorrectVersionNumber, "Ip6PacketsWithIncorrectVersionNumber mismatch") + assert.Equal(t, tt.expected["Ip6FragmentsReceived"], actual.Statistics.Ip6.Ip6FragmentsReceived, "Ip6FragmentsReceived mismatch") + assert.Equal(t, tt.expected["DuplicateOrOutOfSpaceFragmentsDropped"], actual.Statistics.Ip6.DuplicateOrOutOfSpaceFragmentsDropped, "DuplicateOrOutOfSpaceFragmentsDropped mismatch") + assert.Equal(t, tt.expected["Ip6FragmentsDroppedAfterTimeout"], actual.Statistics.Ip6.Ip6FragmentsDroppedAfterTimeout, "Ip6FragmentsDroppedAfterTimeout mismatch") + assert.Equal(t, tt.expected["FragmentsThatExceededLimit"], actual.Statistics.Ip6.FragmentsThatExceededLimit, "FragmentsThatExceededLimit mismatch") + assert.Equal(t, tt.expected["Ip6PacketsReassembledOk"], actual.Statistics.Ip6.Ip6PacketsReassembledOk, "Ip6PacketsReassembledOk mismatch") + assert.Equal(t, tt.expected["Ip6PacketsForThisHost"], actual.Statistics.Ip6.Ip6PacketsForThisHost, "Ip6PacketsForThisHost mismatch") + assert.Equal(t, tt.expected["Ip6PacketsForwarded"], actual.Statistics.Ip6.Ip6PacketsForwarded, "Ip6PacketsForwarded mismatch") + assert.Equal(t, tt.expected["Ip6PacketsNotForwardable"], actual.Statistics.Ip6.Ip6PacketsNotForwardable, "Ip6PacketsNotForwardable mismatch") + assert.Equal(t, tt.expected["Ip6RedirectsSent"], actual.Statistics.Ip6.Ip6RedirectsSent, "Ip6RedirectsSent mismatch") + assert.Equal(t, tt.expected["Ip6PacketsSentFromThisHost"], actual.Statistics.Ip6.Ip6PacketsSentFromThisHost, "Ip6PacketsSentFromThisHost mismatch") + assert.Equal(t, tt.expected["Ip6PacketsSentWithFabricatedIpHeader"], actual.Statistics.Ip6.Ip6PacketsSentWithFabricatedIpHeader, "Ip6PacketsSentWithFabricatedIpHeader mismatch") + assert.Equal(t, tt.expected["Ip6OutputPacketsDroppedDueToNoBufs"], actual.Statistics.Ip6.Ip6OutputPacketsDroppedDueToNoBufs, "Ip6OutputPacketsDroppedDueToNoBufs mismatch") + assert.Equal(t, tt.expected["Ip6OutputPacketsDiscardedDueToNoRoute"], actual.Statistics.Ip6.Ip6OutputPacketsDiscardedDueToNoRoute, "Ip6OutputPacketsDiscardedDueToNoRoute mismatch") + assert.Equal(t, tt.expected["Ip6OutputDatagramsFragmented"], actual.Statistics.Ip6.Ip6OutputDatagramsFragmented, "Ip6OutputDatagramsFragmented mismatch") + assert.Equal(t, tt.expected["Ip6FragmentsCreated"], actual.Statistics.Ip6.Ip6FragmentsCreated, "Ip6FragmentsCreated mismatch") + assert.Equal(t, tt.expected["Ip6DatagramsThatCanNotBeFragmented"], actual.Statistics.Ip6.Ip6DatagramsThatCanNotBeFragmented, "Ip6DatagramsThatCanNotBeFragmented mismatch") + assert.Equal(t, tt.expected["PacketsThatViolatedScopeRules"], actual.Statistics.Ip6.PacketsThatViolatedScopeRules, "PacketsThatViolatedScopeRules mismatch") + assert.Equal(t, tt.expected["MulticastPacketsWhichWeDoNotJoin"], actual.Statistics.Ip6.MulticastPacketsWhichWeDoNotJoin, "MulticastPacketsWhichWeDoNotJoin mismatch") + assert.Equal(t, tt.expected["Ip6nhTcp"], actual.Statistics.Ip6.Ip6nhTcp, "Ip6nhTcp mismatch") + assert.Equal(t, tt.expected["Ip6nhUdp"], actual.Statistics.Ip6.Ip6nhUdp, "Ip6nhUdp mismatch") + assert.Equal(t, tt.expected["Ip6nhIcmp6"], actual.Statistics.Ip6.Ip6nhIcmp6, "Ip6nhIcmp6 mismatch") + }) + } +} \ No newline at end of file From 52ac6857db57bad0e79823a1066155130f93ca17 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 24 Jul 2025 17:15:00 +0200 Subject: [PATCH 07/27] saving some changes --- .../systemstatisticsIPv4/rpc_test.go | 126 +++++++----------- .../systemstatisticsIPv6/rpc.go | 15 +-- 2 files changed, 57 insertions(+), 84 deletions(-) diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go index 48519325..b762a504 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go @@ -3,13 +3,15 @@ package systemstatisticsIPv4 import ( "encoding/xml" "testing" + + "github.com/stretchr/testify/assert" ) func TestStatisticsIPv4Unmarshaling(t *testing.T) { - //there is an array of tests called tests which has 3 elements + //There is an array of tests called tests which has 3 elements //each element includes the name, the xml input(example of device config) //and expected result. First element is regular values, second one is zero values and - //third one is different big numbers + //third one is different rather bigger values tests := []struct { name string xmlInput string @@ -610,81 +612,53 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { t.Run(tt.name, func(t *testing.T) { var result StatisticsIPv4 err := xml.Unmarshal([]byte(tt.xmlInput), &result) - if err != nil { - t.Fatalf("Failed to unmarshal XML: %v", err) - } - - // Test individual fields - if result.Statistics.Ip.PacketsReceived != tt.expected.Statistics.Ip.PacketsReceived { - t.Errorf("PacketsReceived = %v, want %v", result.Statistics.Ip.PacketsReceived, tt.expected.Statistics.Ip.PacketsReceived) - } - if result.Statistics.Ip.BadHeaderChecksums != tt.expected.Statistics.Ip.BadHeaderChecksums { - t.Errorf("BadHeaderChecksums = %v, want %v", result.Statistics.Ip.BadHeaderChecksums, tt.expected.Statistics.Ip.BadHeaderChecksums) - } - if result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum != tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum { - t.Errorf("PacketsWithSizeSmallerThanMinimum = %v, want %v", result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum) - } - if result.Statistics.Ip.FragmentsReceived != tt.expected.Statistics.Ip.FragmentsReceived { - t.Errorf("FragmentsReceived = %v, want %v", result.Statistics.Ip.FragmentsReceived, tt.expected.Statistics.Ip.FragmentsReceived) - } - if result.Statistics.Ip.PacketsForwarded != tt.expected.Statistics.Ip.PacketsForwarded { - t.Errorf("PacketsForwarded = %v, want %v", result.Statistics.Ip.PacketsForwarded, tt.expected.Statistics.Ip.PacketsForwarded) - } - if result.Statistics.Ip.IncomingTtpoipPacketsReceived != tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived { - t.Errorf("IncomingTtpoipPacketsReceived = %v, want %v", result.Statistics.Ip.IncomingTtpoipPacketsReceived, tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived) - } - if result.Cli.Banner != tt.expected.Cli.Banner { - t.Errorf("Banner = %v, want %v", result.Cli.Banner, tt.expected.Cli.Banner) - } - }) - } -} + assert.NoError(t, err, "unmarshal should not return error") -func TestStatisticsIPv4UnmarshalingErrorCases(t *testing.T) { - tests := []struct { - name string - xmlInput string - wantErr bool - }{ - { - name: "invalid_xml", - xmlInput: ``, - wantErr: true, - }, - { - name: "empty_xml", - xmlInput: ``, - wantErr: true, - }, - { - name: "missing_statistics_section", - xmlInput: ` - - user@router> - - `, - wantErr: false, // Should not error, just have empty statistics - }, - { - name: "missing_ip_section", - xmlInput: ` - - - - user@router> - - `, - wantErr: false, // Should not error, just have empty IP statistics - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var result StatisticsIPv4 - err := xml.Unmarshal([]byte(tt.xmlInput), &result) - if (err != nil) != tt.wantErr { - t.Errorf("xml.Unmarshal() error = %v, wantErr %v", err, tt.wantErr) - } + assert.Equal(t, tt.expected.Statistics.Ip.PacketsReceived, result.Statistics.Ip.PacketsReceived, "PacketsReceived should match") + assert.Equal(t, tt.expected.Statistics.Ip.BadHeaderChecksums, result.Statistics.Ip.BadHeaderChecksums, "BadHeaderChecksums should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, "PacketsWithSizeSmallerThanMinimum should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, result.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, "PacketsWithDataSizeLessThanDatalength should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, result.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, "PacketsWithHeaderLengthLessThanDataSize should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, result.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, "PacketsWithDataLengthLessThanHeaderlength should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithIncorrectVersionNumber, result.Statistics.Ip.PacketsWithIncorrectVersionNumber, "PacketsWithIncorrectVersionNumber should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsDestinedToDeadNextHop, result.Statistics.Ip.PacketsDestinedToDeadNextHop, "PacketsDestinedToDeadNextHop should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsReceived, result.Statistics.Ip.FragmentsReceived, "FragmentsReceived should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, result.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, "FragmentsDroppedDueToOutofspaceOrDup should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, result.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, "FragmentsDroppedDueToQueueoverflow should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedAfterTimeout, result.Statistics.Ip.FragmentsDroppedAfterTimeout, "FragmentsDroppedAfterTimeout should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsReassembledOk, result.Statistics.Ip.PacketsReassembledOk, "PacketsReassembledOk should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsForThisHost, result.Statistics.Ip.PacketsForThisHost, "PacketsForThisHost should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, result.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, "PacketsForUnknownOrUnsupportedProtocol should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsForwarded, result.Statistics.Ip.PacketsForwarded, "PacketsForwarded should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsNotForwardable, result.Statistics.Ip.PacketsNotForwardable, "PacketsNotForwardable should match") + assert.Equal(t, tt.expected.Statistics.Ip.RedirectsSent, result.Statistics.Ip.RedirectsSent, "RedirectsSent should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentFromThisHost, result.Statistics.Ip.PacketsSentFromThisHost, "PacketsSentFromThisHost should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentWithFabricatedIpHeader, result.Statistics.Ip.PacketsSentWithFabricatedIpHeader, "PacketsSentWithFabricatedIpHeader should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, result.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, "OutputPacketsDroppedDueToNoBufs should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, result.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, "OutputPacketsDiscardedDueToNoRoute should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutputDatagramsFragmented, result.Statistics.Ip.OutputDatagramsFragmented, "OutputDatagramsFragmented should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsCreated, result.Statistics.Ip.FragmentsCreated, "FragmentsCreated should match") + assert.Equal(t, tt.expected.Statistics.Ip.DatagramsThatCanNotBeFragmented, result.Statistics.Ip.DatagramsThatCanNotBeFragmented, "DatagramsThatCanNotBeFragmented should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithBadOptions, result.Statistics.Ip.PacketsWithBadOptions, "PacketsWithBadOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithOptionsHandledWithoutError, result.Statistics.Ip.PacketsWithOptionsHandledWithoutError, "PacketsWithOptionsHandledWithoutError should match") + assert.Equal(t, tt.expected.Statistics.Ip.StrictSourceAndRecordRouteOptions, result.Statistics.Ip.StrictSourceAndRecordRouteOptions, "StrictSourceAndRecordRouteOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.LooseSourceAndRecordRouteOptions, result.Statistics.Ip.LooseSourceAndRecordRouteOptions, "LooseSourceAndRecordRouteOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.RecordRouteOptions, result.Statistics.Ip.RecordRouteOptions, "RecordRouteOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.TimestampOptions, result.Statistics.Ip.TimestampOptions, "TimestampOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndAddressOptions, result.Statistics.Ip.TimestampAndAddressOptions, "TimestampAndAddressOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, result.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, "TimestampAndPrespecifiedAddressOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, result.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, "OptionPacketsDroppedDueToRateLimit should match") + assert.Equal(t, tt.expected.Statistics.Ip.RouterAlertOptions, result.Statistics.Ip.RouterAlertOptions, "RouterAlertOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.MulticastPacketsDropped, result.Statistics.Ip.MulticastPacketsDropped, "MulticastPacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsDropped, result.Statistics.Ip.PacketsDropped, "PacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, result.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, "TransitRePacketsDroppedOnMgmtInterface should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, result.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, "PacketsUsedFirstNexthopInEcmpUnilist should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived, result.Statistics.Ip.IncomingTtpoipPacketsReceived, "IncomingTtpoipPacketsReceived should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsDropped, result.Statistics.Ip.IncomingTtpoipPacketsDropped, "IncomingTtpoipPacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsSent, result.Statistics.Ip.OutgoingTtpoipPacketsSent, "OutgoingTtpoipPacketsSent should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsDropped, result.Statistics.Ip.OutgoingTtpoipPacketsDropped, "OutgoingTtpoipPacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, result.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, "IncomingRawipPacketsDroppedNoSocketBuffer should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingVirtualNodePacketsDelivered, result.Statistics.Ip.IncomingVirtualNodePacketsDelivered, "IncomingVirtualNodePacketsDelivered should match") }) } } diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go index 1a75b1de..8014230e 100644 --- a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go +++ b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go @@ -9,7 +9,7 @@ type StatisticsIPv6 struct { Statistics struct { Text string `xml:",chardata"` Ip6 struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` TotalPacketsReceived float64 `xml:"total-packets-received"` Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` @@ -33,7 +33,7 @@ type StatisticsIPv6 struct { Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` - Histogram string `xml:"histogram"` + Histogram string `xml:"histogram"` Ip6nhTcp float64 `xml:"ip6nh-tcp"` Ip6nhUdp float64 `xml:"ip6nh-udp"` Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` @@ -42,12 +42,12 @@ type StatisticsIPv6 struct { PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` HeaderType []struct { - Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + Text string `xml:",chardata"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` LinkLocals float64 `xml:"link-locals"` Globals float64 `xml:"globals"` - AddressScope string `xml:"address-scope"` - HexValue string `xml:"hex-value"` + AddressScope string `xml:"address-scope"` + HexValue string `xml:"hex-value"` } `xml:"header-type"` ForwardCacheHit float64 `xml:"forward-cache-hit"` ForwardCacheMiss float64 `xml:"forward-cache-miss"` @@ -63,5 +63,4 @@ type StatisticsIPv6 struct { Text string `xml:",chardata"` Banner string `xml:"banner"` } `xml:"cli"` -} - +} \ No newline at end of file From 1cdde5875c7e1d4852a38d2457ca9843e79378cf Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Wed, 27 Aug 2025 17:43:32 +0200 Subject: [PATCH 08/27] started refactoring ipv4 and ipv6 --- collectors.go | 7 +- internal/config/config.go | 7 +- main.go | 6 +- pkg/features/systemstatistics/collector.go | 394 +++++++++++ pkg/features/systemstatistics/rpc.go | 437 ++++++++++++ .../systemstatisticsIPv4/collector.go | 220 ------ .../systemstatisticsIPv4/rpc.go | 64 -- .../systemstatisticsIPv4/rpc_test.go | 664 ------------------ .../systemstatisticsIPv6/collector.go | 208 ------ .../systemstatisticsIPv6/rpc.go | 66 -- .../systemstatisticsIPv6/rpc_test.go | 178 ----- 11 files changed, 839 insertions(+), 1412 deletions(-) create mode 100644 pkg/features/systemstatistics/collector.go create mode 100644 pkg/features/systemstatistics/rpc.go delete mode 100644 pkg/features/systemstatistics/systemstatisticsIPv4/collector.go delete mode 100644 pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go delete mode 100644 pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go delete mode 100644 pkg/features/systemstatistics/systemstatisticsIPv6/collector.go delete mode 100644 pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go delete mode 100644 pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go diff --git a/collectors.go b/collectors.go index 8ed32815..d2a8f484 100644 --- a/collectors.go +++ b/collectors.go @@ -7,8 +7,6 @@ import ( "github.com/czerwonk/junos_exporter/pkg/features/ddosprotection" "github.com/czerwonk/junos_exporter/pkg/features/poe" - "github.com/czerwonk/junos_exporter/pkg/features/systemstatistics/systemstatisticsIPv4" - "github.com/czerwonk/junos_exporter/pkg/features/systemstatistics/systemstatisticsIPv6" "github.com/czerwonk/junos_exporter/internal/config" "github.com/czerwonk/junos_exporter/pkg/collector" @@ -48,6 +46,7 @@ import ( "github.com/czerwonk/junos_exporter/pkg/features/storage" "github.com/czerwonk/junos_exporter/pkg/features/subscriber" "github.com/czerwonk/junos_exporter/pkg/features/system" + "github.com/czerwonk/junos_exporter/pkg/features/systemstatistics" "github.com/czerwonk/junos_exporter/pkg/features/twamp" "github.com/czerwonk/junos_exporter/pkg/features/vpws" "github.com/czerwonk/junos_exporter/pkg/features/vrrp" @@ -132,8 +131,8 @@ func (c *collectors) initCollectorsForDevices(device *connector.Device, descRe * c.addCollectorIfEnabledForDevice(device, "ddosprotection", f.DDOSProtection, ddosprotection.NewCollector) c.addCollectorIfEnabledForDevice(device, "krt", f.KRT, krt.NewCollector) c.addCollectorIfEnabledForDevice(device, "twamp", f.TWAMP, twamp.NewCollector) - c.addCollectorIfEnabledForDevice(device, "system_statistics_ipv4", f.SystemStatisticsIPv4, systemstatisticsIPv4.NewCollector) - c.addCollectorIfEnabledForDevice(device, "system_statistics_ipv6", f.SystemStatisticsIPv6, systemstatisticsIPv6.NewCollector) + c.addCollectorIfEnabledForDevice(device, "system_statistics", f.SystemStatistics, systemstatistics.NewCollector) + } func (c *collectors) addCollectorIfEnabledForDevice(device *connector.Device, key string, enabled bool, newCollector func() collector.RPCCollector) { diff --git a/internal/config/config.go b/internal/config/config.go index b3f414a4..3e0f9f4d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -103,8 +103,8 @@ type FeatureConfig struct { DDOSProtection bool `yaml:"ddos_protection,omitempty"` KRT bool `yaml:"krt,omitempty"` TWAMP bool `yaml:"twamp,omitempty"` - SystemStatisticsIPv4 bool `yaml:"system_statistics_ipv4,omitempty"` - SystemStatisticsIPv6 bool `yaml:"system_statistics_ipv6,omitempty"` + SystemStatistics bool `yaml:"system_statistics,omitempty"` + } // New creates a new config @@ -184,8 +184,7 @@ func setDefaultValues(c *Config) { f.License = false f.MACSec = true f.Poe = false - f.SystemStatisticsIPv4 = true - f.SystemStatisticsIPv6 = true + f.SystemStatistics = true } // FeaturesForDevice gets the feature set configured for a device diff --git a/main.go b/main.go index 9bb53309..164bdffd 100644 --- a/main.go +++ b/main.go @@ -90,8 +90,7 @@ var ( poeEnabled = flag.Bool("poe.enabled", true, "Scrape PoE metrics") krtEnabled = flag.Bool("krt.enabled", false, "Scrape KRT queue metrics") twampEnabled = flag.Bool("twamp.enabled", false, "Scrape TWAMP metrics") - systemstatisticsIPv4Enabled = flag.Bool("systemstatisticsipv4.enabled", true, "Scrape system statistics IPv4 metrics") - systemstatisticsIPv6Enabled = flag.Bool("systemstatisticsipv6.enabled", true, "Scrape system statistics IPv6 metrics") + systemstatisticsEnabled = flag.Bool("systemstatistics.enabled", true, "Scrape system statistics metrics") cfg *config.Config devices []*connector.Device connManager *connector.SSHConnectionManager @@ -268,8 +267,7 @@ func loadConfigFromFlags() *config.Config { f.Poe = *poeEnabled f.KRT = *krtEnabled f.TWAMP = *twampEnabled - f.SystemStatisticsIPv4 = *systemstatisticsIPv4Enabled - f.SystemStatisticsIPv6 = *systemstatisticsIPv6Enabled + f.SystemStatistics = *systemstatisticsEnabled return c } diff --git a/pkg/features/systemstatistics/collector.go b/pkg/features/systemstatistics/collector.go new file mode 100644 index 00000000..a704991d --- /dev/null +++ b/pkg/features/systemstatistics/collector.go @@ -0,0 +1,394 @@ +package systemstatistics + +import ( + "github.com/prometheus/client_golang/prometheus" + + "github.com/czerwonk/junos_exporter/pkg/collector" +) + +const prefix string = "junos_systemstatistics_" + +var ( + ipv4PacketsReceivedDesc *prometheus.Desc + ipv4BadHeaderChecksumsDesc *prometheus.Desc + ipv4PacketsWithSizeSmallerThanMinimumDesc *prometheus.Desc + ipv4PacketsWithDataSizeLessThanDatalengthDesc *prometheus.Desc + ipv4PacketsWithHeaderLengthLessThanDataSizeDesc *prometheus.Desc + ipv4PacketsWithIncorrectVersionNumberDesc *prometheus.Desc + ipv4PacketsDestinedToDeadNextHopDesc *prometheus.Desc + ipv4FragmentsReceivedDesc *prometheus.Desc + ipv4FragmentsDroppedDueToOutspaceOrDUPDesc *prometheus.Desc + ipv4FragmentsDroppedDueToQueueoverflowDesc *prometheus.Desc + ipv4FragmentsDroppedAfterTimeoutDesc *prometheus.Desc + ipv4PacketsReassembledOKDesc *prometheus.Desc + ipv4PacketsForThisHostDesc *prometheus.Desc + ipv4PacketsForUnknownOrUnsupportedProtocolDesc *prometheus.Desc + ipv4PacketsForwardedDesc *prometheus.Desc + ipv4PacketsNotForwardableDesc *prometheus.Desc + ipv4RedirectsSentDesc *prometheus.Desc + ipv4PacketsSentFromThisHostDesc *prometheus.Desc + ipv4PacketsSentWithFabricatedIPHeaderDesc *prometheus.Desc + ipv4OutputPacketsDroppedDueToNoBufsDesc *prometheus.Desc + ipv4OutputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc + ipv4OutputDatagramsFragmentedDesc *prometheus.Desc + ipv4FragmentsCreatedDesc *prometheus.Desc + ipv4DatagramsThatCanNotBeFragmentedDesc *prometheus.Desc + ipv4PacketsWithBadOptionsDesc *prometheus.Desc + ipv4PacketsWithOptionsHandledWithoutErrorDesc *prometheus.Desc + ipv4StrictSourceAndRecordRouteOptionsDesc *prometheus.Desc + ipv4LooseSourceAndRecordRouteOptionsDesc *prometheus.Desc + ipv4RecordRouteOptionsDesc *prometheus.Desc + ipv4TimestampOptionsDesc *prometheus.Desc + ipv4TimestampAndAddressOptionsDesc *prometheus.Desc + ipv4TimestampAndPrespecifiedAddressOptionsDesc *prometheus.Desc + ipv4OptionPacketsDroppedDueToRateLimitDesc *prometheus.Desc + ipv4RouterAlertOptionDesc *prometheus.Desc + ipv4MulticastPacketsDroppedDesc *prometheus.Desc + ipv4PacketsDroppedDesc *prometheus.Desc + ipv4TransitREPacketsDroppedonMGMTInterfaceDesc *prometheus.Desc + ipv4PacketsUsedFirstNexthopInECMPUnilistDesc *prometheus.Desc + ipv4IncomingTtpoipPacketsReceivedDesc *prometheus.Desc + ipv4IncomingTtpoipPacketsDroppedDesc *prometheus.Desc + ipv4OutgoingTtpoipPacketsSentDesc *prometheus.Desc + ipv4OutgoingTtpoipPacketsDroppedDesc *prometheus.Desc + ipv4IncomingRawIPPacketsDroppedNoSocketBufferDesc *prometheus.Desc + ipv4IncomingVirtualNodePacketsDeliveredDesc *prometheus.Desc + + ipv6TotalPacketsReceivedDesc *prometheus.Desc + ipv6PacketsWithSizeSmallerThanMinimumDesc *prometheus.Desc + ipv6PacketsWithDatasizeLessThanDataLengthDesc *prometheus.Desc + ipv6PacketsWithBadOptionsDesc *prometheus.Desc + ipv6PacketsWithIncorrectVersionNumberDesc *prometheus.Desc + ipv6FragmentsReceivedDesc *prometheus.Desc + ipv6DuplicateOrOutOfSpaceFragmentsDroppedDesc *prometheus.Desc + ipv6FragmentsDroppedAfterTimeoutDesc *prometheus.Desc + ipv6FragmentsThatExceededLimitDesc *prometheus.Desc + ipv6PacketsReassembledOkDesc *prometheus.Desc + ipv6PacketsForThisHostDesc *prometheus.Desc + ipv6PacketsForwardedDesc *prometheus.Desc + ipv6PacketsNotForwardableDesc *prometheus.Desc + ipv6RedirectsSentDesc *prometheus.Desc + ipv6PacketsSentFromThisHostDesc *prometheus.Desc + ipv6PacketsSentWithFabricatedIpHeaderDesc *prometheus.Desc + ipv6OutputPacketsDroppedDueToNoBufsDesc *prometheus.Desc + ipv6OutputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc + ipv6OutputDatagramsFragmentedDesc *prometheus.Desc + ipv6FragmentsCreatedDesc *prometheus.Desc + ipv6DatagramsThatCanNotBeFragmentedDesc *prometheus.Desc + ipv6PacketsThatViolatedScopeRulesDesc *prometheus.Desc + ipv6MulticastPacketsWhichWeDoNotJoinDesc *prometheus.Desc + ipv6NhTcpDesc *prometheus.Desc + ipv6NhUdpDesc *prometheus.Desc + ipv6NhIcmp6Desc *prometheus.Desc + ipv6PacketsWhoseHeadersAreNotContinuousDesc *prometheus.Desc + ipv6TunnelingPacketsThatCanNotFindGifDesc *prometheus.Desc + ipv6PacketsDiscardedDueToTooMayHeadersDesc *prometheus.Desc + ipv6FailuresOfSourceAddressSelectionDesc *prometheus.Desc + ipv6HeaderTypeLinkLocalsDesc *prometheus.Desc + ipv6HeaderTypeGlobalsDesc *prometheus.Desc + ipv6ForwardCacheHitDesc *prometheus.Desc + ipv6ForwardCacheMissDesc *prometheus.Desc + ipv6PacketsDestinedToDeadNextHopDesc *prometheus.Desc + ipv6OptionPacketsDroppedDueToRateLimitDesc *prometheus.Desc + ipv6PacketsDroppedDesc *prometheus.Desc + ipv6PacketsDroppedDueToBadProtocolDesc *prometheus.Desc + ipv6TransitRePacketDroppedOnMgmtInterfaceDesc *prometheus.Desc + ipv6PacketUsedFirstNexthopInEcmpUnilistDesc *prometheus.Desc +) + +func init() { + labelsIPV4 := []string{"target", "protocol"} + ipv4PacketsReceivedDesc = prometheus.NewDesc(prefix+"ipv4_packets_received", "Number of packets received", labelsIPV4, nil) + ipv4BadHeaderChecksumsDesc = prometheus.NewDesc(prefix+"ipv4_bad_header_checksums", "Number of packets received with bad header checksums", labelsIPV4, nil) + ipv4PacketsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"ipv4_packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", labelsIPV4, nil) + ipv4PacketsWithDataSizeLessThanDatalengthDesc = prometheus.NewDesc(prefix+"ipv4_packets_with_data_size_less_than_datalength", "Number of packets received with data size less than data length", labelsIPV4, nil) + ipv4PacketsWithHeaderLengthLessThanDataSizeDesc = prometheus.NewDesc(prefix+"ipv4_packets_with_header_length_less_than_data_size", "Number of packets received with header length less than data size", labelsIPV4, nil) + ipv4PacketsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"ipv4_packets_with_incorrect_version_number", "Number of packets received with incorrect version number", labelsIPV4, nil) + ipv4PacketsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"ipv4_packets_destined_to_dead_next_hop", "Number of packets received destined to dead next hop", labelsIPV4, nil) + ipv4FragmentsReceivedDesc = prometheus.NewDesc(prefix+"ipv4_fragments_received", "Number of fragments received", labelsIPV4, nil) + ipv4FragmentsDroppedDueToOutspaceOrDUPDesc = prometheus.NewDesc(prefix+"ipv4_fragments_dropped_due_to_outspace_or_dup", "Number of fragments dropped due to outspace or DUP", labelsIPV4, nil) + ipv4FragmentsDroppedDueToQueueoverflowDesc = prometheus.NewDesc(prefix+"ipv4_fragments_dropped_due_to_queueoverflow", "Number of fragments dropped due to queue overflow", labelsIPV4, nil) + ipv4FragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"ipv4_fragments_dropped_after_timeout", "Number of fragments dropped after timeout", labelsIPV4, nil) + ipv4PacketsReassembledOKDesc = prometheus.NewDesc(prefix+"ipv4_packets_reassembled_ok", "Number of packets reassembled OK", labelsIPV4, nil) + ipv4PacketsForThisHostDesc = prometheus.NewDesc(prefix+"ipv4_packets_for_this_host", "Number of packets for this host", labelsIPV4, nil) + ipv4PacketsForUnknownOrUnsupportedProtocolDesc = prometheus.NewDesc(prefix+"ipv4_packets_for_unknown_or_unsupported_protocol", "Number of packets for unknown or unsupported protocol", labelsIPV4, nil) + ipv4PacketsForwardedDesc = prometheus.NewDesc(prefix+"ipv4_packets_forwarded", "Number of packets forwarded", labelsIPV4, nil) + ipv4PacketsNotForwardableDesc = prometheus.NewDesc(prefix+"ipv4_packets_not_forwardable", "Number of packets not forwardable", labelsIPV4, nil) + ipv4RedirectsSentDesc = prometheus.NewDesc(prefix+"ipv4_redirects_sent", "Number of redirects sent", labelsIPV4, nil) + ipv4PacketsSentFromThisHostDesc = prometheus.NewDesc(prefix+"ipv4_packets_sent_from_this_host", "Number of packets sent from this host", labelsIPV4, nil) + ipv4PacketsSentWithFabricatedIPHeaderDesc = prometheus.NewDesc(prefix+"ipv4_packets_sent_with_fabricated_ip_header", "Number of packets sent with fabricated IP header", labelsIPV4, nil) + ipv4OutputPacketsDroppedDueToNoBufsDesc = prometheus.NewDesc(prefix+"ipv4_output_packets_dropped_due_to_no_bufs", "Number of output packets dropped due to no bufs", labelsIPV4, nil) + ipv4OutputPacketsDiscardedDueToNoRouteDesc = prometheus.NewDesc(prefix+"ipv4_output_packets_discarded_due_to_no_route", "Number of output packets discarded due to no route", labelsIPV4, nil) + ipv4OutputDatagramsFragmentedDesc = prometheus.NewDesc(prefix+"ipv4_output_datagrams_fragmented", "Number of output datagrams fragmented", labelsIPV4, nil) + ipv4FragmentsCreatedDesc = prometheus.NewDesc(prefix+"ipv4_fragments_created", "Number of fragments created", labelsIPV4, nil) + ipv4DatagramsThatCanNotBeFragmentedDesc = prometheus.NewDesc(prefix+"ipv4_datagrams_that_can_not_be_fragmented", "Number of datagrams that can not be fragmented", labelsIPV4, nil) + ipv4PacketsWithBadOptionsDesc = prometheus.NewDesc(prefix+"ipv4_packets_with_bad_options", "Number of packets with bad options", labelsIPV4, nil) + ipv4PacketsWithOptionsHandledWithoutErrorDesc = prometheus.NewDesc(prefix+"ipv4_packets_with_options_handled_without_error", "Number of packets with options handled without error", labelsIPV4, nil) + ipv4StrictSourceAndRecordRouteOptionsDesc = prometheus.NewDesc(prefix+"ipv4_strict_source_and_record_route_options", "Number of packets with strict source and record route options", labelsIPV4, nil) + ipv4LooseSourceAndRecordRouteOptionsDesc = prometheus.NewDesc(prefix+"ipv4_loose_source_and_record_route_options", "Number of packets with loose source and record route options", labelsIPV4, nil) + ipv4RecordRouteOptionsDesc = prometheus.NewDesc(prefix+"ipv4_record_route_options", "Number of packets with record route options", labelsIPV4, nil) + ipv4TimestampOptionsDesc = prometheus.NewDesc(prefix+"ipv4_timestamp_options", "Number of packets with timestamp options", labelsIPV4, nil) + ipv4TimestampAndAddressOptionsDesc = prometheus.NewDesc(prefix+"ipv4_timestamp_and_address_options", "Number of packets with timestamp and address options", labelsIPV4, nil) + ipv4TimestampAndPrespecifiedAddressOptionsDesc = prometheus.NewDesc(prefix+"ipv4_timestamp_and_prespecified_address_options", "Number of packets with timestamp and prespecified address options", labelsIPV4, nil) + ipv4OptionPacketsDroppedDueToRateLimitDesc = prometheus.NewDesc(prefix+"ipv4_option_packets_dropped_due_to_rate_limit", "Number of option packets dropped due to rate limit", labelsIPV4, nil) + ipv4RouterAlertOptionDesc = prometheus.NewDesc(prefix+"ipv4_router_alert_option", "Number of packets with router alert option", labelsIPV4, nil) + ipv4MulticastPacketsDroppedDesc = prometheus.NewDesc(prefix+"ipv4_multicast_packets_dropped", "Number of multicast packets dropped", labelsIPV4, nil) + ipv4PacketsDroppedDesc = prometheus.NewDesc(prefix+"ipv4_packets_dropped", "Number of packets dropped", labelsIPV4, nil) + ipv4TransitREPacketsDroppedonMGMTInterfaceDesc = prometheus.NewDesc(prefix+"ipv4_transit_re_packets_droppedon_mgt_interface", "Number of transit RE packets dropped on MGMT interface", labelsIPV4, nil) + ipv4PacketsUsedFirstNexthopInECMPUnilistDesc = prometheus.NewDesc(prefix+"ipv4_packets_used_first_nexthop_in_ecmp_unilist", "Number of packets used first nexthop in ECMP unilist", labelsIPV4, nil) + ipv4IncomingTtpoipPacketsReceivedDesc = prometheus.NewDesc(prefix+"ipv4_incoming_ttpoip_packets_received", "Number of incoming TTPoIP packets received", labelsIPV4, nil) + ipv4IncomingTtpoipPacketsDroppedDesc = prometheus.NewDesc(prefix+"ipv4_incoming_ttpoip_packets_dropped", "Number of incoming TTPoIP packets dropped", labelsIPV4, nil) + ipv4OutgoingTtpoipPacketsSentDesc = prometheus.NewDesc(prefix+"ipv4_outgoing_ttpoip_packets_sent", "Number of outgoing TTPoIP packets sent", labelsIPV4, nil) + ipv4OutgoingTtpoipPacketsDroppedDesc = prometheus.NewDesc(prefix+"ipv4_outgoing_ttpoip_packets_dropped", "Number of outgoing TTPoIP packets dropped", labelsIPV4, nil) + ipv4IncomingRawIPPacketsDroppedNoSocketBufferDesc = prometheus.NewDesc(prefix+"ipv4_incoming_raw_ip_packets_dropped_no_socket_buffer", "Number of incoming raw IP packets dropped due to no socket buffer", labelsIPV4, nil) + ipv4IncomingVirtualNodePacketsDeliveredDesc = prometheus.NewDesc(prefix+"ipv4_incoming_virtual_node_packets_delivered", "Number of incoming virtual node packets delivered", labelsIPV4, nil) + + labelsIPV6 := []string{"target", "protocol"} + ipv6TotalPacketsReceivedDesc = prometheus.NewDesc(prefix+"ipv6_total_packets_received", "Total number of packets received", labelsIPV6, nil) + ipv6PacketsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"ipv6_packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", labelsIPV6, nil) + ipv6PacketsWithDatasizeLessThanDataLengthDesc = prometheus.NewDesc(prefix+"ipv6_packets_with_datasize_less_than_data_length", "Number of packets received with data length less than data length", labelsIPV6, nil) + ipv6PacketsWithBadOptionsDesc = prometheus.NewDesc(prefix+"ipv6_packets_with_bad_options", "Number of packets received with bad options", labelsIPV6, nil) + ipv6PacketsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"ipv6_packets_with_incorrect_version_number", "Number of packets received with incorrect version number", labelsIPV6, nil) + ipv6FragmentsReceivedDesc = prometheus.NewDesc(prefix+"ipv6_fragments_received", "Number of fragments received", labelsIPV6, nil) + ipv6DuplicateOrOutOfSpaceFragmentsDroppedDesc = prometheus.NewDesc(prefix+"ipv6_duplicate_or_out_of_space_fragments_dropped", "Number of duplicate or out of space fragments dropped", labelsIPV6, nil) + ipv6FragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"ipv6_fragments_dropped_after_timeout", "Number of fragments dropped after timeout", labelsIPV6, nil) + ipv6FragmentsThatExceededLimitDesc = prometheus.NewDesc(prefix+"ipv6_fragments_that_exceeded_limit", "Number of fragments that exceeded limit", labelsIPV6, nil) + ipv6PacketsReassembledOkDesc = prometheus.NewDesc(prefix+"ipv6_packets_reassembled_ok", "Number of packets reassembled ok", labelsIPV6, nil) + ipv6PacketsForThisHostDesc = prometheus.NewDesc(prefix+"ipv6_packets_for_this_host", "Number of packets for this host", labelsIPV6, nil) + ipv6PacketsForwardedDesc = prometheus.NewDesc(prefix+"ipv6_packets_forwarded", "Number of packets forwarded", labelsIPV6, nil) + ipv6PacketsNotForwardableDesc = prometheus.NewDesc(prefix+"ipv6_packets_not_forwardable", "Number of packets not forwardable", labelsIPV6, nil) + ipv6RedirectsSentDesc = prometheus.NewDesc(prefix+"ipv6_redirects_sent", "Number of redirects sent", labelsIPV6, nil) + ipv6PacketsSentFromThisHostDesc = prometheus.NewDesc(prefix+"ipv6_packets_sent_from_this_host", "Number of packets sent from this host", labelsIPV6, nil) + ipv6PacketsSentWithFabricatedIpHeaderDesc = prometheus.NewDesc(prefix+"ipv6_packets_sent_with_fabricated_ip_header", "Number of packets sent with fabricated ip header", labelsIPV6, nil) + ipv6OutputPacketsDroppedDueToNoBufsDesc = prometheus.NewDesc(prefix+"ipv6_output_packets_dropped_due_to_no_bufs", "Number of output packets dropped due to no bufs", labelsIPV6, nil) + ipv6OutputPacketsDiscardedDueToNoRouteDesc = prometheus.NewDesc(prefix+"ipv6_output_packets_discarded_due_to_no_route", "Number of output packets discarded due to no route", labelsIPV6, nil) + ipv6OutputDatagramsFragmentedDesc = prometheus.NewDesc(prefix+"ipv6_output_datagrams_fragmented", "Number of output datagrams fragmented", labelsIPV6, nil) + ipv6FragmentsCreatedDesc = prometheus.NewDesc(prefix+"ipv6_fragments_created", "Number of fragments created", labelsIPV6, nil) + ipv6DatagramsThatCanNotBeFragmentedDesc = prometheus.NewDesc(prefix+"ipv6_datagrams_that_can_not_be_fragmented", "Number of datagrams that can not be fragmented", labelsIPV6, nil) + ipv6PacketsThatViolatedScopeRulesDesc = prometheus.NewDesc(prefix+"ipv6_packets_that_violated_scope_rules", "Number of packets that violated scope rules", labelsIPV6, nil) + ipv6MulticastPacketsWhichWeDoNotJoinDesc = prometheus.NewDesc(prefix+"ipv6_multicast_packets_which_we_do_not_join", "Number of multicast packets which we do not join", labelsIPV6, nil) + ipv6NhTcpDesc = prometheus.NewDesc(prefix+"ipv6_nh_tcp", "Number of packets with next header tcp", labelsIPV6, nil) + ipv6NhUdpDesc = prometheus.NewDesc(prefix+"ipv6_nh_udp", "Number of packets with next header udp", labelsIPV6, nil) + ipv6NhIcmp6Desc = prometheus.NewDesc(prefix+"ipv6_nh_icmp6", "Number of packets with next header icmp6", labelsIPV6, nil) + ipv6PacketsWhoseHeadersAreNotContinuousDesc = prometheus.NewDesc(prefix+"ipv6_packets_whose_headers_are_not_continuous", "Number of packets whose headers are not continuous", labelsIPV6, nil) + ipv6TunnelingPacketsThatCanNotFindGifDesc = prometheus.NewDesc(prefix+"ipv6_tunneling_packets_that_can_not_find_gif", "Number of tunneling packets that can not find gif", labelsIPV6, nil) + ipv6PacketsDiscardedDueToTooMayHeadersDesc = prometheus.NewDesc(prefix+"ipv6_packets_discarded_due_to_too_may_headers", "Number of packets discarded due to too may headers", labelsIPV6, nil) + ipv6FailuresOfSourceAddressSelectionDesc = prometheus.NewDesc(prefix+"ipv6_failures_of_source_address_selection", "Number of failures of source address selection", labelsIPV6, nil) + labelsIPV6Header := []string{"target", "protocol", "header_type"} + ipv6HeaderTypeLinkLocalsDesc = prometheus.NewDesc(prefix+"ipv6_header_type_link_locals", "Number of packets with header type link locals", labelsIPV6Header, nil) + ipv6HeaderTypeGlobalsDesc = prometheus.NewDesc(prefix+"ipv6_header_type_globals", "Number of packets with header type globals", labelsIPV6Header, nil) + ipv6ForwardCacheHitDesc = prometheus.NewDesc(prefix+"ipv6_forward_cache_hit", "Number of forward cache hit", labelsIPV6, nil) + ipv6ForwardCacheMissDesc = prometheus.NewDesc(prefix+"ipv6_forward_cache_miss", "Number of forward cache miss", labelsIPV6, nil) + ipv6PacketsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"ipv6_packets_destined_to_dead_next_hop", "Number of packets destined to dead next hop", labelsIPV6, nil) + ipv6OptionPacketsDroppedDueToRateLimitDesc = prometheus.NewDesc(prefix+"ipv6_option_packets_dropped_due_to_rate_limit", "Number of option packets dropped due to rate limit", labelsIPV6, nil) + ipv6PacketsDroppedDesc = prometheus.NewDesc(prefix+"ipv6_packets_dropped", "Number of packets dropped", labelsIPV6, nil) + ipv6PacketsDroppedDueToBadProtocolDesc = prometheus.NewDesc(prefix+"ipv6_packets_dropped_due_to_bad_protocol", "Number of packets dropped due to bad protocol", labelsIPV6, nil) + ipv6TransitRePacketDroppedOnMgmtInterfaceDesc = prometheus.NewDesc(prefix+"ipv6_transit_re_packet_dropped_on_mgmt_interface", "Number of transit re packet dropped on mgmt interface", labelsIPV6, nil) + ipv6PacketUsedFirstNexthopInEcmpUnilistDesc = prometheus.NewDesc(prefix+"ipv6_packet_used_first_nexthop_in_ecmp_unilist", "Number of packet used first nexthop in ecmp unilist", labelsIPV6, nil) + +} + +type systemstatisticsCollector struct{} + +func NewCollector() collector.RPCCollector { + return &systemstatisticsCollector{} +} + +func (c *systemstatisticsCollector) Name() string { + return "systemstatistics" +} + +func (c *systemstatisticsCollector) Describe(ch chan<- *prometheus.Desc) { + ch <- ipv4PacketsReceivedDesc + ch <- ipv4BadHeaderChecksumsDesc + ch <- ipv4PacketsWithSizeSmallerThanMinimumDesc + ch <- ipv4PacketsWithDataSizeLessThanDatalengthDesc + ch <- ipv4PacketsWithHeaderLengthLessThanDataSizeDesc + ch <- ipv4PacketsWithIncorrectVersionNumberDesc + ch <- ipv4PacketsDestinedToDeadNextHopDesc + ch <- ipv4FragmentsReceivedDesc + ch <- ipv4FragmentsDroppedDueToOutspaceOrDUPDesc + ch <- ipv4FragmentsDroppedDueToQueueoverflowDesc + ch <- ipv4FragmentsDroppedAfterTimeoutDesc + ch <- ipv4PacketsReassembledOKDesc + ch <- ipv4PacketsForThisHostDesc + ch <- ipv4PacketsForUnknownOrUnsupportedProtocolDesc + ch <- ipv4PacketsForwardedDesc + ch <- ipv4PacketsNotForwardableDesc + ch <- ipv4RedirectsSentDesc + ch <- ipv4PacketsSentFromThisHostDesc + ch <- ipv4PacketsSentWithFabricatedIPHeaderDesc + ch <- ipv4OutputPacketsDroppedDueToNoBufsDesc + ch <- ipv4OutputPacketsDiscardedDueToNoRouteDesc + ch <- ipv4OutputDatagramsFragmentedDesc + ch <- ipv4FragmentsCreatedDesc + ch <- ipv4DatagramsThatCanNotBeFragmentedDesc + ch <- ipv4PacketsWithBadOptionsDesc + ch <- ipv4PacketsWithOptionsHandledWithoutErrorDesc + ch <- ipv4StrictSourceAndRecordRouteOptionsDesc + ch <- ipv4LooseSourceAndRecordRouteOptionsDesc + ch <- ipv4RecordRouteOptionsDesc + ch <- ipv4TimestampOptionsDesc + ch <- ipv4TimestampAndAddressOptionsDesc + ch <- ipv4TimestampAndPrespecifiedAddressOptionsDesc + ch <- ipv4OptionPacketsDroppedDueToRateLimitDesc + ch <- ipv4RouterAlertOptionDesc + ch <- ipv4MulticastPacketsDroppedDesc + ch <- ipv4PacketsDroppedDesc + ch <- ipv4TransitREPacketsDroppedonMGMTInterfaceDesc + ch <- ipv4PacketsUsedFirstNexthopInECMPUnilistDesc + ch <- ipv4IncomingTtpoipPacketsReceivedDesc + ch <- ipv4IncomingTtpoipPacketsDroppedDesc + ch <- ipv4OutgoingTtpoipPacketsSentDesc + ch <- ipv4OutgoingTtpoipPacketsDroppedDesc + ch <- ipv4IncomingRawIPPacketsDroppedNoSocketBufferDesc + ch <- ipv4IncomingVirtualNodePacketsDeliveredDesc + + ch <- ipv6TotalPacketsReceivedDesc + ch <- ipv6PacketsWithSizeSmallerThanMinimumDesc + ch <- ipv6PacketsWithDatasizeLessThanDataLengthDesc + ch <- ipv6PacketsWithBadOptionsDesc + ch <- ipv6PacketsWithIncorrectVersionNumberDesc + ch <- ipv6FragmentsReceivedDesc + ch <- ipv6DuplicateOrOutOfSpaceFragmentsDroppedDesc + ch <- ipv6FragmentsDroppedAfterTimeoutDesc + ch <- ipv6FragmentsThatExceededLimitDesc + ch <- ipv6PacketsReassembledOkDesc + ch <- ipv6PacketsForThisHostDesc + ch <- ipv6PacketsForwardedDesc + ch <- ipv6PacketsNotForwardableDesc + ch <- ipv6RedirectsSentDesc + ch <- ipv6PacketsSentFromThisHostDesc + ch <- ipv6PacketsSentWithFabricatedIpHeaderDesc + ch <- ipv6OutputPacketsDroppedDueToNoBufsDesc + ch <- ipv6OutputPacketsDiscardedDueToNoRouteDesc + ch <- ipv6OutputDatagramsFragmentedDesc + ch <- ipv6FragmentsCreatedDesc + ch <- ipv6DatagramsThatCanNotBeFragmentedDesc + ch <- ipv6PacketsThatViolatedScopeRulesDesc + ch <- ipv6MulticastPacketsWhichWeDoNotJoinDesc + ch <- ipv6NhTcpDesc + ch <- ipv6NhUdpDesc + ch <- ipv6NhIcmp6Desc + ch <- ipv6PacketsWhoseHeadersAreNotContinuousDesc + ch <- ipv6TunnelingPacketsThatCanNotFindGifDesc + ch <- ipv6PacketsDiscardedDueToTooMayHeadersDesc + ch <- ipv6FailuresOfSourceAddressSelectionDesc + ch <- ipv6HeaderTypeLinkLocalsDesc + ch <- ipv6HeaderTypeGlobalsDesc + ch <- ipv6ForwardCacheHitDesc + ch <- ipv6ForwardCacheMissDesc + ch <- ipv6PacketsDestinedToDeadNextHopDesc + ch <- ipv6OptionPacketsDroppedDueToRateLimitDesc + ch <- ipv6PacketsDroppedDesc + ch <- ipv6PacketsDroppedDueToBadProtocolDesc + ch <- ipv6TransitRePacketDroppedOnMgmtInterfaceDesc + ch <- ipv6PacketUsedFirstNexthopInEcmpUnilistDesc +} + +func (c *systemstatisticsCollector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { + var s SystemStatistics + err := client.RunCommandAndParse("show system statistics ip", &s) + if err != nil { + return err + } + c.collectSystemStatisticsIPV4(ch, labelValues, s) + c.collectSystemStatisticsIPV6(ch, labelValues, s) + return nil +} + +func (c *systemstatisticsCollector) collectSystemStatisticsIPV4(ch chan<- prometheus.Metric, labelValues []string, s SystemStatistics) { + labels := append(labelValues, "ipv4") + ch <- prometheus.MustNewConstMetric(ipv4PacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsReceived, labels...) + ch <- prometheus.MustNewConstMetric(ipv4BadHeaderChecksumsDesc, prometheus.CounterValue, s.Statistics.Ip.BadHeaderChecksums, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsWithSizeSmallerThanMinimumDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsWithDataSizeLessThanDatalengthDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsWithHeaderLengthLessThanDataSizeDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsWithIncorrectVersionNumberDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithIncorrectVersionNumber, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsDestinedToDeadNextHopDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsDestinedToDeadNextHop, labels...) + ch <- prometheus.MustNewConstMetric(ipv4FragmentsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsReceived, labels...) + ch <- prometheus.MustNewConstMetric(ipv4FragmentsDroppedDueToOutspaceOrDUPDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, labels...) + ch <- prometheus.MustNewConstMetric(ipv4FragmentsDroppedDueToQueueoverflowDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, labels...) + ch <- prometheus.MustNewConstMetric(ipv4FragmentsDroppedAfterTimeoutDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedAfterTimeout, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsReassembledOKDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsReassembledOk, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsForThisHostDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForThisHost, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsForUnknownOrUnsupportedProtocolDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsForwardedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForwarded, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsNotForwardableDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsNotForwardable, labels...) + ch <- prometheus.MustNewConstMetric(ipv4RedirectsSentDesc, prometheus.CounterValue, s.Statistics.Ip.RedirectsSent, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsSentFromThisHostDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsSentFromThisHost, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsSentWithFabricatedIPHeaderDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsSentWithFabricatedIpHeader, labels...) + ch <- prometheus.MustNewConstMetric(ipv4OutputPacketsDroppedDueToNoBufsDesc, prometheus.CounterValue, s.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, labels...) + ch <- prometheus.MustNewConstMetric(ipv4OutputPacketsDiscardedDueToNoRouteDesc, prometheus.CounterValue, s.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, labels...) + ch <- prometheus.MustNewConstMetric(ipv4OutputDatagramsFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip.OutputDatagramsFragmented, labels...) + ch <- prometheus.MustNewConstMetric(ipv4FragmentsCreatedDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsCreated, labels...) + ch <- prometheus.MustNewConstMetric(ipv4DatagramsThatCanNotBeFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip.DatagramsThatCanNotBeFragmented, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsWithBadOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithBadOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsWithOptionsHandledWithoutErrorDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithOptionsHandledWithoutError, labels...) + ch <- prometheus.MustNewConstMetric(ipv4StrictSourceAndRecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.StrictSourceAndRecordRouteOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4LooseSourceAndRecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.LooseSourceAndRecordRouteOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4RecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.RecordRouteOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4TimestampOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4TimestampAndAddressOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampAndAddressOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4TimestampAndPrespecifiedAddressOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4OptionPacketsDroppedDueToRateLimitDesc, prometheus.CounterValue, s.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, labels...) + ch <- prometheus.MustNewConstMetric(ipv4RouterAlertOptionDesc, prometheus.CounterValue, s.Statistics.Ip.RouterAlertOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv4MulticastPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.MulticastPacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ipv4TransitREPacketsDroppedonMGMTInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, labels...) + ch <- prometheus.MustNewConstMetric(ipv4PacketsUsedFirstNexthopInECMPUnilistDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, labels...) + ch <- prometheus.MustNewConstMetric(ipv4IncomingTtpoipPacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingTtpoipPacketsReceived, labels...) + ch <- prometheus.MustNewConstMetric(ipv4IncomingTtpoipPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingTtpoipPacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ipv4OutgoingTtpoipPacketsSentDesc, prometheus.CounterValue, s.Statistics.Ip.OutgoingTtpoipPacketsSent, labels...) + ch <- prometheus.MustNewConstMetric(ipv4OutgoingTtpoipPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.OutgoingTtpoipPacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ipv4IncomingRawIPPacketsDroppedNoSocketBufferDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, labels...) + ch <- prometheus.MustNewConstMetric(ipv4IncomingVirtualNodePacketsDeliveredDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingVirtualNodePacketsDelivered, labels...) +} + +func (c *systemstatisticsCollector) collectSystemStatisticsIPV6(ch chan<- prometheus.Metric, labelValues []string, s SystemStatistics) { + labels := append(labelValues, "ipv6") + ch <- prometheus.MustNewConstMetric(ipv6TotalPacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip6.TotalPacketsReceived, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsWithSizeSmallerThanMinimumDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithSizeSmallerThanMinimum, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsWithDatasizeLessThanDataLengthDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsWithDatasizeLessThanDataLength, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsWithBadOptionsDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithBadOptions, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsWithIncorrectVersionNumberDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithIncorrectVersionNumber, labels...) + ch <- prometheus.MustNewConstMetric(ipv6FragmentsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsReceived, labels...) + ch <- prometheus.MustNewConstMetric(ipv6DuplicateOrOutOfSpaceFragmentsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip6.DuplicateOrOutOfSpaceFragmentsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ipv6FragmentsDroppedAfterTimeoutDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsDroppedAfterTimeout, labels...) + ch <- prometheus.MustNewConstMetric(ipv6FragmentsThatExceededLimitDesc, prometheus.CounterValue, s.Statistics.Ip6.FragmentsThatExceededLimit, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsReassembledOkDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsReassembledOk, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsForThisHostDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsForThisHost, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsForwardedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsForwarded, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsNotForwardableDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsNotForwardable, labels...) + ch <- prometheus.MustNewConstMetric(ipv6RedirectsSentDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6RedirectsSent, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsSentFromThisHostDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsSentFromThisHost, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsSentWithFabricatedIpHeaderDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsSentWithFabricatedIpHeader, labels...) + ch <- prometheus.MustNewConstMetric(ipv6OutputPacketsDroppedDueToNoBufsDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputPacketsDroppedDueToNoBufs, labels...) + ch <- prometheus.MustNewConstMetric(ipv6OutputPacketsDiscardedDueToNoRouteDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputPacketsDiscardedDueToNoRoute, labels...) + ch <- prometheus.MustNewConstMetric(ipv6OutputDatagramsFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputDatagramsFragmented, labels...) + ch <- prometheus.MustNewConstMetric(ipv6FragmentsCreatedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsCreated, labels...) + ch <- prometheus.MustNewConstMetric(ipv6DatagramsThatCanNotBeFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6DatagramsThatCanNotBeFragmented, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsThatViolatedScopeRulesDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsThatViolatedScopeRules, labels...) + ch <- prometheus.MustNewConstMetric(ipv6MulticastPacketsWhichWeDoNotJoinDesc, prometheus.CounterValue, s.Statistics.Ip6.MulticastPacketsWhichWeDoNotJoin, labels...) + ch <- prometheus.MustNewConstMetric(ipv6NhTcpDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhTcp, labels...) + ch <- prometheus.MustNewConstMetric(ipv6NhUdpDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhUdp, labels...) + ch <- prometheus.MustNewConstMetric(ipv6NhIcmp6Desc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhIcmp6, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsWhoseHeadersAreNotContinuousDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsWhoseHeadersAreNotContinuous, labels...) + ch <- prometheus.MustNewConstMetric(ipv6TunnelingPacketsThatCanNotFindGifDesc, prometheus.CounterValue, s.Statistics.Ip6.TunnelingPacketsThatCanNotFindGif, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsDiscardedDueToTooMayHeadersDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsDiscardedDueToTooMayHeaders, labels...) + ch <- prometheus.MustNewConstMetric(ipv6FailuresOfSourceAddressSelectionDesc, prometheus.CounterValue, s.Statistics.Ip6.FailuresOfSourceAddressSelection, labels...) + for _, header := range s.Statistics.Ip6.HeaderType { + labels := append(labelValues, "ipv6", header.HeaderForSourceAddressSelection) + ch <- prometheus.MustNewConstMetric(ipv6HeaderTypeLinkLocalsDesc, prometheus.CounterValue, header.LinkLocals, labels...) + ch <- prometheus.MustNewConstMetric(ipv6HeaderTypeGlobalsDesc, prometheus.CounterValue, header.Globals, labels...) + } + ch <- prometheus.MustNewConstMetric(ipv6ForwardCacheHitDesc, prometheus.CounterValue, s.Statistics.Ip6.ForwardCacheHit, labels...) + ch <- prometheus.MustNewConstMetric(ipv6ForwardCacheMissDesc, prometheus.CounterValue, s.Statistics.Ip6.ForwardCacheMiss, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsDestinedToDeadNextHopDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsDestinedToDeadNextHop, labels...) + ch <- prometheus.MustNewConstMetric(ipv6OptionPacketsDroppedDueToRateLimitDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OptionPacketsDroppedDueToRateLimit, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsDropped, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketsDroppedDueToBadProtocolDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsDroppedDueToBadProtocol, labels...) + ch <- prometheus.MustNewConstMetric(ipv6TransitRePacketDroppedOnMgmtInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip6.TransitRePacketDroppedOnMgmtInterface, labels...) + ch <- prometheus.MustNewConstMetric(ipv6PacketUsedFirstNexthopInEcmpUnilistDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketUsedFirstNexthopInEcmpUnilist, labels...) + +} \ No newline at end of file diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go new file mode 100644 index 00000000..5c0b0212 --- /dev/null +++ b/pkg/features/systemstatistics/rpc.go @@ -0,0 +1,437 @@ +package systemstatistics + +import "encoding/xml" + +type SystemStatistics struct { + XMLName xml.Name `xml:"rpc-reply"` + Text string `xml:",chardata"` + Junos string `xml:"junos,attr"` + Statistics struct { + Text string `xml:",chardata"` + Tcp struct { + Text string `xml:",chardata"` + PacketsSent float64 `xml:"packets-sent"` + SentDataPackets string `xml:"sent-data-packets"` + DataPacketsBytes string `xml:"data-packets-bytes"` + SentDataPacketsRetransmitted string `xml:"sent-data-packets-retransmitted"` + RetransmittedBytes string `xml:"retransmitted-bytes"` + SentDataUnnecessaryRetransmitted string `xml:"sent-data-unnecessary-retransmitted"` + SentResendsByMtuDiscovery string `xml:"sent-resends-by-mtu-discovery"` + SentAckOnlyPackets string `xml:"sent-ack-only-packets"` + SentPacketsDelayed string `xml:"sent-packets-delayed"` + SentUrgOnlyPackets string `xml:"sent-urg-only-packets"` + SentWindowProbePackets string `xml:"sent-window-probe-packets"` + SentWindowUpdatePackets string `xml:"sent-window-update-packets"` + SentControlPackets string `xml:"sent-control-packets"` + PacketsReceived string `xml:"packets-received"` + ReceivedAcks string `xml:"received-acks"` + AcksBytes string `xml:"acks-bytes"` + ReceivedDuplicateAcks string `xml:"received-duplicate-acks"` + ReceivedAcksForUnsentData string `xml:"received-acks-for-unsent-data"` + PacketsReceivedInSequence string `xml:"packets-received-in-sequence"` + InSequenceBytes string `xml:"in-sequence-bytes"` + ReceivedCompletelyDuplicatePacket string `xml:"received-completely-duplicate-packet"` + DuplicateInBytes string `xml:"duplicate-in-bytes"` + ReceivedOldDuplicatePackets string `xml:"received-old-duplicate-packets"` + ReceivedPacketsWithSomeDupliacteData string `xml:"received-packets-with-some-dupliacte-data"` + SomeDuplicateInBytes string `xml:"some-duplicate-in-bytes"` + ReceivedOutOfOrderPackets string `xml:"received-out-of-order-packets"` + OutOfOrderInBytes string `xml:"out-of-order-in-bytes"` + ReceivedPacketsOfDataAfterWindow string `xml:"received-packets-of-data-after-window"` + Bytes string `xml:"bytes"` + ReceivedWindowProbes string `xml:"received-window-probes"` + ReceivedWindowUpdatePackets string `xml:"received-window-update-packets"` + PacketsReceivedAfterClose string `xml:"packets-received-after-close"` + ReceivedDiscardedForBadChecksum string `xml:"received-discarded-for-bad-checksum"` + ReceivedDiscardedForBadHeaderOffset string `xml:"received-discarded-for-bad-header-offset"` + ReceivedDiscardedBecausePacketTooShort string `xml:"received-discarded-because-packet-too-short"` + ConnectionRequests string `xml:"connection-requests"` + ConnectionAccepts string `xml:"connection-accepts"` + BadConnectionAttempts string `xml:"bad-connection-attempts"` + ListenQueueOverflows string `xml:"listen-queue-overflows"` + BadRstWindow string `xml:"bad-rst-window"` + ConnectionsEstablished string `xml:"connections-established"` + ConnectionsClosed string `xml:"connections-closed"` + Drops string `xml:"drops"` + ConnectionsUpdatedRttOnClose string `xml:"connections-updated-rtt-on-close"` + ConnectionsUpdatedVarianceOnClose string `xml:"connections-updated-variance-on-close"` + ConnectionsUpdatedSsthreshOnClose string `xml:"connections-updated-ssthresh-on-close"` + EmbryonicConnectionsDropped string `xml:"embryonic-connections-dropped"` + SegmentsUpdatedRtt string `xml:"segments-updated-rtt"` + Attempts string `xml:"attempts"` + RetransmitTimeouts string `xml:"retransmit-timeouts"` + ConnectionsDroppedByRetransmitTimeout string `xml:"connections-dropped-by-retransmit-timeout"` + PersistTimeouts string `xml:"persist-timeouts"` + ConnectionsDroppedByPersistTimeout string `xml:"connections-dropped-by-persist-timeout"` + KeepaliveTimeouts string `xml:"keepalive-timeouts"` + KeepaliveProbesSent string `xml:"keepalive-probes-sent"` + KeepaliveConnectionsDropped string `xml:"keepalive-connections-dropped"` + AckHeaderPredictions string `xml:"ack-header-predictions"` + DataPacketHeaderPredictions string `xml:"data-packet-header-predictions"` + SyncacheEntriesAdded string `xml:"syncache-entries-added"` + Retransmitted string `xml:"retransmitted"` + Dupsyn string `xml:"dupsyn"` + Dropped string `xml:"dropped"` + Completed string `xml:"completed"` + BucketOverflow string `xml:"bucket-overflow"` + CacheOverflow string `xml:"cache-overflow"` + Reset string `xml:"reset"` + Stale string `xml:"stale"` + Aborted string `xml:"aborted"` + Badack string `xml:"badack"` + Unreach string `xml:"unreach"` + ZoneFailures string `xml:"zone-failures"` + CookiesSent string `xml:"cookies-sent"` + CookiesReceived string `xml:"cookies-received"` + SackRecoveryEpisodes string `xml:"sack-recovery-episodes"` + SegmentRetransmits string `xml:"segment-retransmits"` + ByteRetransmits string `xml:"byte-retransmits"` + SackOptionsReceived string `xml:"sack-options-received"` + SackOpitionsSent string `xml:"sack-opitions-sent"` + SackScoreboardOverflow string `xml:"sack-scoreboard-overflow"` + AcksSentInResponseButNotExactRsts string `xml:"acks-sent-in-response-but-not-exact-rsts"` + AcksSentInResponseToSynsOnEstablishedConnections string `xml:"acks-sent-in-response-to-syns-on-established-connections"` + RcvPacketsDroppedDueToBadAddress string `xml:"rcv-packets-dropped-due-to-bad-address"` + OutOfSequenceSegmentDrops string `xml:"out-of-sequence-segment-drops"` + RstPackets string `xml:"rst-packets"` + IcmpPacketsIgnored string `xml:"icmp-packets-ignored"` + SendPacketsDropped string `xml:"send-packets-dropped"` + RcvPacketsDropped string `xml:"rcv-packets-dropped"` + OutgoingSegmentsDropped string `xml:"outgoing-segments-dropped"` + ReceivedSynfinDropped string `xml:"received-synfin-dropped"` + ReceivedIpsecDropped string `xml:"received-ipsec-dropped"` + ReceivedMacDropped string `xml:"received-mac-dropped"` + ReceivedMinttlExceeded string `xml:"received-minttl-exceeded"` + ListenstateBadflagsDropped string `xml:"listenstate-badflags-dropped"` + FinwaitstateBadflagsDropped string `xml:"finwaitstate-badflags-dropped"` + ReceivedDosAttack string `xml:"received-dos-attack"` + ReceivedBadSynack string `xml:"received-bad-synack"` + SyncacheZoneFull string `xml:"syncache-zone-full"` + ReceivedRstFirewallfilter string `xml:"received-rst-firewallfilter"` + ReceivedNoackTimewait string `xml:"received-noack-timewait"` + ReceivedNoTimewaitState string `xml:"received-no-timewait-state"` + ReceivedRstTimewaitState string `xml:"received-rst-timewait-state"` + ReceivedTimewaitDrops string `xml:"received-timewait-drops"` + ReceivedBadaddrTimewaitState string `xml:"received-badaddr-timewait-state"` + ReceivedAckoffInSynSentrcvd string `xml:"received-ackoff-in-syn-sentrcvd"` + ReceivedBadaddrFirewall string `xml:"received-badaddr-firewall"` + ReceivedNosynSynSent string `xml:"received-nosyn-syn-sent"` + ReceivedBadrstSynSent string `xml:"received-badrst-syn-sent"` + ReceivedBadrstListenState string `xml:"received-badrst-listen-state"` + OptionMaxsegmentLength string `xml:"option-maxsegment-length"` + OptionWindowLength string `xml:"option-window-length"` + OptionTimestampLength string `xml:"option-timestamp-length"` + OptionMd5Length string `xml:"option-md5-length"` + OptionAuthLength string `xml:"option-auth-length"` + OptionSackpermittedLength string `xml:"option-sackpermitted-length"` + OptionSackLength string `xml:"option-sack-length"` + OptionAuthoptionLength string `xml:"option-authoption-length"` + } `xml:"tcp"` + Udp struct { + Text string `xml:",chardata"` + DatagramsReceived string `xml:"datagrams-received"` + DatagramsWithIncompleteHeader string `xml:"datagrams-with-incomplete-header"` + DatagramsWithBadDatalengthField string `xml:"datagrams-with-bad-datalength-field"` + DatagramsWithBadChecksum string `xml:"datagrams-with-bad-checksum"` + DatagramsDroppedDueToNoSocket string `xml:"datagrams-dropped-due-to-no-socket"` + BroadcastOrMulticastDatagramsDroppedDueToNoSocket string `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` + DatagramsDroppedDueToFullSocketBuffers string `xml:"datagrams-dropped-due-to-full-socket-buffers"` + DatagramsNotForHashedPcb string `xml:"datagrams-not-for-hashed-pcb"` + DatagramsDelivered string `xml:"datagrams-delivered"` + DatagramsOutput string `xml:"datagrams-output"` + } `xml:"udp"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + Icmp struct { + Text string `xml:",chardata"` + DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` + CallsToIcmpError string `xml:"calls-to-icmp-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` + Histogram []struct { + Text string `xml:",chardata"` + TypeOfHistogram string `xml:"type-of-histogram"` + IcmpEchoReply string `xml:"icmp-echo-reply"` + DestinationUnreachable string `xml:"destination-unreachable"` + IcmpEcho string `xml:"icmp-echo"` + TimeStampReply string `xml:"time-stamp-reply"` + TimeExceeded string `xml:"time-exceeded"` + TimeStamp string `xml:"time-stamp"` + AddressMaskRequest string `xml:"address-mask-request"` + AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` + } `xml:"histogram"` + MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` + MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` + MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` + MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` + MessagesWithBadLength string `xml:"messages-with-bad-length"` + EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` + TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` + MessageResponsesGenerated string `xml:"message-responses-generated"` + } `xml:"icmp"` + Arp struct { + Text string `xml:",chardata"` + DatagramsReceived string `xml:"datagrams-received"` + ArpRequestsReceived string `xml:"arp-requests-received"` + ArpRepliesReceived string `xml:"arp-replies-received"` + ResolutionRequestReceived string `xml:"resolution-request-received"` + ResolutionRequestDropped string `xml:"resolution-request-dropped"` + UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` + RestrictedProxyRequests string `xml:"restricted-proxy-requests"` + ReceivedProxyRequests string `xml:"received-proxy-requests"` + ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` + RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` + DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` + DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` + DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` + DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` + DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` + DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` + DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` + DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` + DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` + DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` + DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` + DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` + DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` + PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` + PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` + ArpRequestsSent string `xml:"arp-requests-sent"` + ArpRepliesSent string `xml:"arp-replies-sent"` + RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` + RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` + RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` + RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` + RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` + NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` + RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` + RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` + RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` + ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` + ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` + ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` + ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` + ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` + SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` + ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` + ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` + ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` + ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` + GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` + ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` + ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` + ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` + ArpSystemMax string `xml:"arp-system-max"` + ArpPublicMax string `xml:"arp-public-max"` + ArpIriMax string `xml:"arp-iri-max"` + ArpMgtMax string `xml:"arp-mgt-max"` + ArpPublicCnt string `xml:"arp-public-cnt"` + ArpIriCnt string `xml:"arp-iri-cnt"` + ArpMgtCnt string `xml:"arp-mgt-cnt"` + ArpSystemDrop string `xml:"arp-system-drop"` + ArpPublicDrop string `xml:"arp-public-drop"` + ArpIriDrop string `xml:"arp-iri-drop"` + ArpMgtDrop string `xml:"arp-mgt-drop"` + } `xml:"arp"` + Ip6 struct { + Text string `xml:",chardata"` + TotalPacketsReceived float64 `xml:"total-packets-received"` + Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` + PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` + Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` + Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` + Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` + DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` + Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` + FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` + Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` + Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` + Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` + Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` + Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` + Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` + Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` + Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` + Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` + Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` + Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` + Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` + PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` + MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` + Histogram float64 `xml:"histogram"` + Ip6nhTcp float64 `xml:"ip6nh-tcp"` + Ip6nhUdp float64 `xml:"ip6nh-udp"` + Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` + PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` + TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` + PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` + FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` + HeaderType []struct { + Text string `xml:",chardata"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + LinkLocals float64 `xml:"link-locals"` + Globals float64 `xml:"globals"` + AddressScope float64 `xml:"address-scope"` + HexValue float64 `xml:"hex-value"` + } `xml:"header-type"` + ForwardCacheHit float64 `xml:"forward-cache-hit"` + ForwardCacheMiss float64 `xml:"forward-cache-miss"` + Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` + Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` + Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` + PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` + TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` + PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` + } `xml:"ip6"` + Icmp6 struct { + Text string `xml:",chardata"` + ProtocolName string `xml:"protocol-name"` + CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` + ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` + OutputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"output-histogram"` + Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` + MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` + BadChecksums string `xml:"bad-checksums"` + Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` + InputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"input-histogram"` + HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` + NoRoute string `xml:"no-route"` + AdministrativelyProhibited string `xml:"administratively-prohibited"` + BeyondScope string `xml:"beyond-scope"` + AddressUnreachable string `xml:"address-unreachable"` + PortUnreachable string `xml:"port-unreachable"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceedTransit string `xml:"time-exceed-transit"` + TimeExceedReassembly string `xml:"time-exceed-reassembly"` + ErroneousHeaderField string `xml:"erroneous-header-field"` + UnrecognizedNextHeader string `xml:"unrecognized-next-header"` + UnrecognizedOption string `xml:"unrecognized-option"` + Redirect string `xml:"redirect"` + Unknown string `xml:"unknown"` + Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` + MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` + NdSystemMax string `xml:"nd-system-max"` + NdPublicMax string `xml:"nd-public-max"` + NdIriMax string `xml:"nd-iri-max"` + NdMgtMax string `xml:"nd-mgt-max"` + NdPublicCnt string `xml:"nd-public-cnt"` + NdIriCnt string `xml:"nd-iri-cnt"` + NdMgtCnt string `xml:"nd-mgt-cnt"` + NdSystemDrop string `xml:"nd-system-drop"` + NdPublicDrop string `xml:"nd-public-drop"` + NdIriDrop string `xml:"nd-iri-drop"` + NdMgtDrop string `xml:"nd-mgt-drop"` + Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` + Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` + Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` + Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` + Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` + Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` + Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` + Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` + Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` + Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` + Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` + Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` + Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` + Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` + Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` + Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` + Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` + Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` + } `xml:"icmp6"` + Mpls struct { + Text string `xml:",chardata"` + TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` + PacketsForwarded string `xml:"packets-forwarded"` + PacketsDropped string `xml:"packets-dropped"` + PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` + AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` + PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` + PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` + PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` + LspPingPackets string `xml:"lsp-ping-packets"` + PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` + PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` + PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` + PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` + PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` + PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` + PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` + } `xml:"mpls"` + } `xml:"statistics"` + Cli struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + } `xml:"cli"` +} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go deleted file mode 100644 index 945eb992..00000000 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/collector.go +++ /dev/null @@ -1,220 +0,0 @@ -package systemstatisticsIPv4 - -import ( - "github.com/prometheus/client_golang/prometheus" - - "github.com/czerwonk/junos_exporter/pkg/collector" -) - -const prefix string = "junos_systemstatistics_ipv4_" - -// Metrics to collect for the feature -var ( - packetsReceivedDesc *prometheus.Desc - badHeaderChecksumsDesc *prometheus.Desc - packetsWithSizeSmallerThanMinimumDesc *prometheus.Desc - packetsWithDataSizeLessThanDatalengthDesc *prometheus.Desc - PacketsWithHeaderLengthLessThanDataSizeDesc *prometheus.Desc - packetsWithIncorrectVersionNumberDesc *prometheus.Desc - packetsDestinedToDeadNextHopDesc *prometheus.Desc - fragmentsReceivedDesc *prometheus.Desc - fragmentsDroppedDueToOutspaceOrDUPDesc *prometheus.Desc - fragmentsDroppedDueToQueueoverflowDesc *prometheus.Desc - fragmentsDroppedAfterTimeoutDesc *prometheus.Desc - packetsReassembledOKDesc *prometheus.Desc - packetsForThisHostDesc *prometheus.Desc - packetsForUnknownOrUnsupportedProtocolDesc *prometheus.Desc - packetsForwardedDesc *prometheus.Desc - packetsNotForwardableDesc *prometheus.Desc - redirectsSentDesc *prometheus.Desc - packetsSentFromThisHostDesc *prometheus.Desc - packetsSentWithFabricatedIPHeaderDesc *prometheus.Desc - outputPacketsDroppedDueToNoBufsDesc *prometheus.Desc - outputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc - outputDatagramsFragmentedDesc *prometheus.Desc - fragmentsCreatedDesc *prometheus.Desc - datagramsThatCanNotBeFragmentedDesc *prometheus.Desc - packetsWithBadOptionsDesc *prometheus.Desc - packetsWithOptionsHandledWithoutErrorDesc *prometheus.Desc - strictSourceAndRecordRouteOptionsDesc *prometheus.Desc - looseSourceAndRecordRouteOptionsDesc *prometheus.Desc - recordRouteOptionsDesc *prometheus.Desc - timestampOptionsDesc *prometheus.Desc - timestampAndAddressOptionsDesc *prometheus.Desc - timestampAndPrespecifiedAddressOptionsDesc *prometheus.Desc - optionPacketsDroppedDueToRateLimitDesc *prometheus.Desc - routerAlertOptionDesc *prometheus.Desc - multicastPacketsDroppedDesc *prometheus.Desc - packetsDroppedDesc *prometheus.Desc - transitREPacketsDroppedonMGMTInterfaceDesc *prometheus.Desc - packetsUsedFirstNexthopInECMPUnilistDesc *prometheus.Desc - incomingTtpoipPacketsReceivedDesc *prometheus.Desc - incomingTtpoipPacketsDroppedDesc *prometheus.Desc - outgoingTtpoipPacketsSentDesc *prometheus.Desc - outgoingTtpoipPacketsDroppedDesc *prometheus.Desc - incomingRawIPPacketsDroppedNoSocketBufferDesc *prometheus.Desc - incomingVirtualNodePacketsDeliveredDesc *prometheus.Desc -) - -func init() { - l := []string{"target", "protocol"} - packetsReceivedDesc = prometheus.NewDesc(prefix+"packets_received", "Number of packets received", l, nil) - badHeaderChecksumsDesc = prometheus.NewDesc(prefix+"bad_header_checksums", "Number of packets received with bad header checksums", l, nil) - packetsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", l, nil) - packetsWithDataSizeLessThanDatalengthDesc = prometheus.NewDesc(prefix+"packets_with_data_size_less_than_datalength", "Number of packets received with data size less than data length", l, nil) - PacketsWithHeaderLengthLessThanDataSizeDesc = prometheus.NewDesc(prefix+"packets_with_header_length_less_than_data_size", "Number of packets received with header length less than data size", l, nil) - packetsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"packets_with_incorrect_version_number", "Number of packets received with incorrect version number", l, nil) - packetsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"packets_destined_to_dead_next_hop", "Number of packets received destined to dead next hop", l, nil) - fragmentsReceivedDesc = prometheus.NewDesc(prefix+"fragments_received", "Number of fragments received", l, nil) - fragmentsDroppedDueToOutspaceOrDUPDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_outspace_or_dup", "Number of fragments dropped due to outspace or DUP", l, nil) - fragmentsDroppedDueToQueueoverflowDesc = prometheus.NewDesc(prefix+"fragments_dropped_due_to_queueoverflow", "Number of fragments dropped due to queue overflow", l, nil) - fragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"fragments_dropped_after_timeout", "Number of fragments dropped after timeout", l, nil) - packetsReassembledOKDesc = prometheus.NewDesc(prefix+"packets_reassembled_ok", "Number of packets reassembled OK", l, nil) - packetsForThisHostDesc = prometheus.NewDesc(prefix+"packets_for_this_host", "Number of packets for this host", l, nil) - packetsForUnknownOrUnsupportedProtocolDesc = prometheus.NewDesc(prefix+"packets_for_unknown_or_unsupported_protocol", "Number of packets for unknown or unsupported protocol", l, nil) - packetsForwardedDesc = prometheus.NewDesc(prefix+"packets_forwarded", "Number of packets forwarded", l, nil) - packetsNotForwardableDesc = prometheus.NewDesc(prefix+"packets_not_forwardable", "Number of packets not forwardable", l, nil) - redirectsSentDesc = prometheus.NewDesc(prefix+"redirects_sent", "Number of redirects sent", l, nil) - packetsSentFromThisHostDesc = prometheus.NewDesc(prefix+"packets_sent_from_this_host", "Number of packets sent from this host", l, nil) - packetsSentWithFabricatedIPHeaderDesc = prometheus.NewDesc(prefix+"packets_sent_with_fabricated_ip_header", "Number of packets sent with fabricated IP header", l, nil) - outputPacketsDroppedDueToNoBufsDesc = prometheus.NewDesc(prefix+"output_packets_dropped_due_to_no_bufs", "Number of output packets dropped due to no bufs", l, nil) - outputPacketsDiscardedDueToNoRouteDesc = prometheus.NewDesc(prefix+"output_packets_discarded_due_to_no_route", "Number of output packets discarded due to no route", l, nil) - outputDatagramsFragmentedDesc = prometheus.NewDesc(prefix+"output_datagrams_fragmented", "Number of output datagrams fragmented", l, nil) - fragmentsCreatedDesc = prometheus.NewDesc(prefix+"fragments_created", "Number of fragments created", l, nil) - datagramsThatCanNotBeFragmentedDesc = prometheus.NewDesc(prefix+"datagrams_that_can_not_be_fragmented", "Number of datagrams that can not be fragmented", l, nil) - packetsWithBadOptionsDesc = prometheus.NewDesc(prefix+"packets_with_bad_options", "Number of packets with bad options", l, nil) - packetsWithOptionsHandledWithoutErrorDesc = prometheus.NewDesc(prefix+"packets_with_options_handled_without_error", "Number of packets with options handled without error", l, nil) - strictSourceAndRecordRouteOptionsDesc = prometheus.NewDesc(prefix+"strict_source_and_record_route_options", "Number of packets with strict source and record route options", l, nil) - looseSourceAndRecordRouteOptionsDesc = prometheus.NewDesc(prefix+"loose_source_and_record_route_options", "Number of packets with loose source and record route options", l, nil) - recordRouteOptionsDesc = prometheus.NewDesc(prefix+"record_route_options", "Number of packets with record route options", l, nil) - timestampOptionsDesc = prometheus.NewDesc(prefix+"timestamp_options", "Number of packets with timestamp options", l, nil) - timestampAndAddressOptionsDesc = prometheus.NewDesc(prefix+"timestamp_and_address_options", "Number of packets with timestamp and address options", l, nil) - timestampAndPrespecifiedAddressOptionsDesc = prometheus.NewDesc(prefix+"timestamp_and_prespecified_address_options", "Number of packets with timestamp and prespecified address options", l, nil) - optionPacketsDroppedDueToRateLimitDesc = prometheus.NewDesc(prefix+"option_packets_dropped_due_to_rate_limit", "Number of option packets dropped due to rate limit", l, nil) - routerAlertOptionDesc = prometheus.NewDesc(prefix+"router_alert_option", "Number of packets with router alert option", l, nil) - multicastPacketsDroppedDesc = prometheus.NewDesc(prefix+"multicast_packets_dropped", "Number of multicast packets dropped", l, nil) - packetsDroppedDesc = prometheus.NewDesc(prefix+"packets_dropped", "Number of packets dropped", l, nil) - transitREPacketsDroppedonMGMTInterfaceDesc = prometheus.NewDesc(prefix+"transit_re_packets_droppedon_mgt_interface", "Number of transit RE packets dropped on MGMT interface", l, nil) - packetsUsedFirstNexthopInECMPUnilistDesc = prometheus.NewDesc(prefix+"packets_used_first_nexthop_in_ecmp_unilist", "Number of packets used first nexthop in ECMP unilist", l, nil) - incomingTtpoipPacketsReceivedDesc = prometheus.NewDesc(prefix+"incoming_ttpoip_packets_received", "Number of incoming TTPoIP packets received", l, nil) - incomingTtpoipPacketsDroppedDesc = prometheus.NewDesc(prefix+"incoming_ttpoip_packets_dropped", "Number of incoming TTPoIP packets dropped", l, nil) - outgoingTtpoipPacketsSentDesc = prometheus.NewDesc(prefix+"outgoing_ttpoip_packets_sent", "Number of outgoing TTPoIP packets sent", l, nil) - outgoingTtpoipPacketsDroppedDesc = prometheus.NewDesc(prefix+"outgoing_ttpoip_packets_dropped", "Number of outgoing TTPoIP packets dropped", l, nil) - incomingRawIPPacketsDroppedNoSocketBufferDesc = prometheus.NewDesc(prefix+"incoming_raw_ip_packets_dropped_no_socket_buffer", "Number of incoming raw IP packets dropped due to no socket buffer", l, nil) - incomingVirtualNodePacketsDeliveredDesc = prometheus.NewDesc(prefix+"incoming_virtual_node_packets_delivered", "Number of incoming virtual node packets delivered", l, nil) -} - -type systemstatisticsIPv4Collector struct{} - -func NewCollector() collector.RPCCollector { - return &systemstatisticsIPv4Collector{} -} - -func (c *systemstatisticsIPv4Collector) Name() string { - return "systemstatisticsIPv4" -} - -func (c *systemstatisticsIPv4Collector) Describe(ch chan<- *prometheus.Desc) { - ch <- packetsReceivedDesc - ch <- badHeaderChecksumsDesc - ch <- packetsWithSizeSmallerThanMinimumDesc - ch <- packetsWithDataSizeLessThanDatalengthDesc - ch <- PacketsWithHeaderLengthLessThanDataSizeDesc - ch <- packetsWithIncorrectVersionNumberDesc - ch <- packetsDestinedToDeadNextHopDesc - ch <- fragmentsReceivedDesc - ch <- fragmentsDroppedDueToOutspaceOrDUPDesc - ch <- fragmentsDroppedDueToQueueoverflowDesc - ch <- fragmentsDroppedAfterTimeoutDesc - ch <- packetsReassembledOKDesc - ch <- packetsForThisHostDesc - ch <- packetsForUnknownOrUnsupportedProtocolDesc - ch <- packetsForwardedDesc - ch <- packetsNotForwardableDesc - ch <- redirectsSentDesc - ch <- packetsSentFromThisHostDesc - ch <- packetsSentWithFabricatedIPHeaderDesc - ch <- outputPacketsDroppedDueToNoBufsDesc - ch <- outputPacketsDiscardedDueToNoRouteDesc - ch <- outputDatagramsFragmentedDesc - ch <- fragmentsCreatedDesc - ch <- datagramsThatCanNotBeFragmentedDesc - ch <- packetsWithBadOptionsDesc - ch <- packetsWithOptionsHandledWithoutErrorDesc - ch <- strictSourceAndRecordRouteOptionsDesc - ch <- looseSourceAndRecordRouteOptionsDesc - ch <- recordRouteOptionsDesc - ch <- timestampOptionsDesc - ch <- timestampAndAddressOptionsDesc - ch <- timestampAndPrespecifiedAddressOptionsDesc - ch <- optionPacketsDroppedDueToRateLimitDesc - ch <- routerAlertOptionDesc - ch <- multicastPacketsDroppedDesc - ch <- packetsDroppedDesc - ch <- transitREPacketsDroppedonMGMTInterfaceDesc - ch <- packetsUsedFirstNexthopInECMPUnilistDesc - ch <- incomingTtpoipPacketsReceivedDesc - ch <- incomingTtpoipPacketsDroppedDesc - ch <- outgoingTtpoipPacketsSentDesc - ch <- outgoingTtpoipPacketsDroppedDesc - ch <- incomingRawIPPacketsDroppedNoSocketBufferDesc - ch <- incomingVirtualNodePacketsDeliveredDesc -} - -func (c *systemstatisticsIPv4Collector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { - var s StatisticsIPv4 - err := client.RunCommandAndParse("show system statistics ip", &s) - if err != nil { - return err - } - c.collectSystemStatisticsIPv4(ch, labelValues, s) - return nil -} - -func (c *systemstatisticsIPv4Collector) collectSystemStatisticsIPv4(ch chan<- prometheus.Metric, labelValues []string, s StatisticsIPv4) { - labels := append(labelValues, "ipv4") - ch <- prometheus.MustNewConstMetric(packetsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsReceived, labels...) - ch <- prometheus.MustNewConstMetric(badHeaderChecksumsDesc, prometheus.CounterValue, s.Statistics.Ip.BadHeaderChecksums, labels...) - ch <- prometheus.MustNewConstMetric(packetsWithSizeSmallerThanMinimumDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, labels...) - ch <- prometheus.MustNewConstMetric(packetsWithDataSizeLessThanDatalengthDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, labels...) - ch <- prometheus.MustNewConstMetric(PacketsWithHeaderLengthLessThanDataSizeDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, labels...) - ch <- prometheus.MustNewConstMetric(packetsWithIncorrectVersionNumberDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithIncorrectVersionNumber, labels...) - ch <- prometheus.MustNewConstMetric(packetsDestinedToDeadNextHopDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsDestinedToDeadNextHop, labels...) - ch <- prometheus.MustNewConstMetric(fragmentsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsReceived, labels...) - ch <- prometheus.MustNewConstMetric(fragmentsDroppedDueToOutspaceOrDUPDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, labels...) - ch <- prometheus.MustNewConstMetric(fragmentsDroppedDueToQueueoverflowDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, labels...) - ch <- prometheus.MustNewConstMetric(fragmentsDroppedAfterTimeoutDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsDroppedAfterTimeout, labels...) - ch <- prometheus.MustNewConstMetric(packetsReassembledOKDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsReassembledOk, labels...) - ch <- prometheus.MustNewConstMetric(packetsForThisHostDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForThisHost, labels...) - ch <- prometheus.MustNewConstMetric(packetsForUnknownOrUnsupportedProtocolDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, labels...) - ch <- prometheus.MustNewConstMetric(packetsForwardedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsForwarded, labels...) - ch <- prometheus.MustNewConstMetric(packetsNotForwardableDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsNotForwardable, labels...) - ch <- prometheus.MustNewConstMetric(redirectsSentDesc, prometheus.CounterValue, s.Statistics.Ip.RedirectsSent, labels...) - ch <- prometheus.MustNewConstMetric(packetsSentFromThisHostDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsSentFromThisHost, labels...) - ch <- prometheus.MustNewConstMetric(packetsSentWithFabricatedIPHeaderDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsSentWithFabricatedIpHeader, labels...) - ch <- prometheus.MustNewConstMetric(outputPacketsDroppedDueToNoBufsDesc, prometheus.CounterValue, s.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, labels...) - ch <- prometheus.MustNewConstMetric(outputPacketsDiscardedDueToNoRouteDesc, prometheus.CounterValue, s.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, labels...) - ch <- prometheus.MustNewConstMetric(outputDatagramsFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip.OutputDatagramsFragmented, labels...) - ch <- prometheus.MustNewConstMetric(fragmentsCreatedDesc, prometheus.CounterValue, s.Statistics.Ip.FragmentsCreated, labels...) - ch <- prometheus.MustNewConstMetric(datagramsThatCanNotBeFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip.DatagramsThatCanNotBeFragmented, labels...) - ch <- prometheus.MustNewConstMetric(packetsWithBadOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithBadOptions, labels...) - ch <- prometheus.MustNewConstMetric(packetsWithOptionsHandledWithoutErrorDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsWithOptionsHandledWithoutError, labels...) - ch <- prometheus.MustNewConstMetric(strictSourceAndRecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.StrictSourceAndRecordRouteOptions, labels...) - ch <- prometheus.MustNewConstMetric(looseSourceAndRecordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.LooseSourceAndRecordRouteOptions, labels...) - ch <- prometheus.MustNewConstMetric(recordRouteOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.RecordRouteOptions, labels...) - ch <- prometheus.MustNewConstMetric(timestampOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampOptions, labels...) - ch <- prometheus.MustNewConstMetric(timestampAndAddressOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampAndAddressOptions, labels...) - ch <- prometheus.MustNewConstMetric(timestampAndPrespecifiedAddressOptionsDesc, prometheus.CounterValue, s.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, labels...) - ch <- prometheus.MustNewConstMetric(optionPacketsDroppedDueToRateLimitDesc, prometheus.CounterValue, s.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, labels...) - ch <- prometheus.MustNewConstMetric(routerAlertOptionDesc, prometheus.CounterValue, s.Statistics.Ip.RouterAlertOptions, labels...) - ch <- prometheus.MustNewConstMetric(multicastPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.MulticastPacketsDropped, labels...) - ch <- prometheus.MustNewConstMetric(packetsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsDropped, labels...) - ch <- prometheus.MustNewConstMetric(transitREPacketsDroppedonMGMTInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, labels...) - ch <- prometheus.MustNewConstMetric(packetsUsedFirstNexthopInECMPUnilistDesc, prometheus.CounterValue, s.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, labels...) - ch <- prometheus.MustNewConstMetric(incomingTtpoipPacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingTtpoipPacketsReceived, labels...) - ch <- prometheus.MustNewConstMetric(incomingTtpoipPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingTtpoipPacketsDropped, labels...) - ch <- prometheus.MustNewConstMetric(outgoingTtpoipPacketsSentDesc, prometheus.CounterValue, s.Statistics.Ip.OutgoingTtpoipPacketsSent, labels...) - ch <- prometheus.MustNewConstMetric(outgoingTtpoipPacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip.OutgoingTtpoipPacketsDropped, labels...) - ch <- prometheus.MustNewConstMetric(incomingRawIPPacketsDroppedNoSocketBufferDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, labels...) - ch <- prometheus.MustNewConstMetric(incomingVirtualNodePacketsDeliveredDesc, prometheus.CounterValue, s.Statistics.Ip.IncomingVirtualNodePacketsDelivered, labels...) -} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go deleted file mode 100644 index f4278c40..00000000 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc.go +++ /dev/null @@ -1,64 +0,0 @@ -package systemstatisticsIPv4 - -import "encoding/xml" - -type StatisticsIPv4 struct { - XMLName xml.Name `xml:"rpc-reply"` - Text string `xml:",chardata"` - Junos string `xml:"junos,attr"` - Statistics struct { - Text string `xml:",chardata"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - } `xml:"statistics"` - Cli struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - } `xml:"cli"` -} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go b/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go deleted file mode 100644 index b762a504..00000000 --- a/pkg/features/systemstatistics/systemstatisticsIPv4/rpc_test.go +++ /dev/null @@ -1,664 +0,0 @@ -package systemstatisticsIPv4 - -import ( - "encoding/xml" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestStatisticsIPv4Unmarshaling(t *testing.T) { - //There is an array of tests called tests which has 3 elements - //each element includes the name, the xml input(example of device config) - //and expected result. First element is regular values, second one is zero values and - //third one is different rather bigger values - tests := []struct { - name string - xmlInput string - expected StatisticsIPv4 - }{ - { - name: "complete_ipv4_statistics", - xmlInput: ` - - - 1000 - 5 - 10 - 2 - 3 - 1 - 0 - 0 - 50 - 2 - 1 - 0 - 48 - 500 - 5 - 400 - 10 - 2 - 800 - 0 - 3 - 1 - 20 - 40 - 2 - 1 - 15 - 0 - 2 - 5 - 3 - 1 - 0 - 0 - 4 - 8 - 12 - 0 - 25 - 100 - 2 - 95 - 1 - 3 - 200 - - - - user@router> - - `, - expected: StatisticsIPv4{ - Statistics: struct { - Text string `xml:",chardata"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - }{ - Ip: struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - }{ - PacketsReceived: 1000, - BadHeaderChecksums: 5, - PacketsWithSizeSmallerThanMinimum: 10, - PacketsWithDataSizeLessThanDatalength: 2, - PacketsWithHeaderLengthLessThanDataSize: 3, - PacketsWithDataLengthLessThanHeaderlength: 1, - PacketsWithIncorrectVersionNumber: 0, - PacketsDestinedToDeadNextHop: 0, - FragmentsReceived: 50, - FragmentsDroppedDueToOutofspaceOrDup: 2, - FragmentsDroppedDueToQueueoverflow: 1, - FragmentsDroppedAfterTimeout: 0, - PacketsReassembledOk: 48, - PacketsForThisHost: 500, - PacketsForUnknownOrUnsupportedProtocol: 5, - PacketsForwarded: 400, - PacketsNotForwardable: 10, - RedirectsSent: 2, - PacketsSentFromThisHost: 800, - PacketsSentWithFabricatedIpHeader: 0, - OutputPacketsDroppedDueToNoBufs: 3, - OutputPacketsDiscardedDueToNoRoute: 1, - OutputDatagramsFragmented: 20, - FragmentsCreated: 40, - DatagramsThatCanNotBeFragmented: 2, - PacketsWithBadOptions: 1, - PacketsWithOptionsHandledWithoutError: 15, - StrictSourceAndRecordRouteOptions: 0, - LooseSourceAndRecordRouteOptions: 2, - RecordRouteOptions: 5, - TimestampOptions: 3, - TimestampAndAddressOptions: 1, - TimestampAndPrespecifiedAddressOptions: 0, - OptionPacketsDroppedDueToRateLimit: 0, - RouterAlertOptions: 4, - MulticastPacketsDropped: 8, - PacketsDropped: 12, - TransitRePacketsDroppedOnMgmtInterface: 0, - PacketsUsedFirstNexthopInEcmpUnilist: 25, - IncomingTtpoipPacketsReceived: 100, - IncomingTtpoipPacketsDropped: 2, - OutgoingTtpoipPacketsSent: 95, - OutgoingTtpoipPacketsDropped: 1, - IncomingRawipPacketsDroppedNoSocketBuffer: 3, - IncomingVirtualNodePacketsDelivered: 200, - }, - }, - Cli: struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - }{ - Banner: "user@router>", - }, - }, - }, - { - name: "empty_ipv4_statistics", - xmlInput: ` - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - - user@router> - - `, - expected: StatisticsIPv4{ - Statistics: struct { - Text string `xml:",chardata"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - }{ - Ip: struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - }{ - // All fields are zero by default - }, - }, - Cli: struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - }{ - Banner: "user@router>", - }, - }, - }, - { - name: "high_values_ipv4_statistics", - xmlInput: ` - - - 999999999 - 12345 - 54321 - 1111 - 2222 - 3333 - 4444 - 5555 - 888888 - 6666 - 7777 - 8888 - 777777 - 555555 - 9999 - 444444 - 11111 - 12121 - 666666 - 13131 - 14141 - 15151 - 16161 - 17171 - 18181 - 19191 - 20202 - 21212 - 22222 - 23232 - 24242 - 25252 - 26262 - 27272 - 28282 - 29292 - 30303 - 31313 - 32323 - 33333 - 34343 - 35353 - 36363 - 37373 - 38383 - - - - admin@high-traffic-router> - - `, - expected: StatisticsIPv4{ - Statistics: struct { - Text string `xml:",chardata"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - }{ - Ip: struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - }{ - PacketsReceived: 999999999, - BadHeaderChecksums: 12345, - PacketsWithSizeSmallerThanMinimum: 54321, - PacketsWithDataSizeLessThanDatalength: 1111, - PacketsWithHeaderLengthLessThanDataSize: 2222, - PacketsWithDataLengthLessThanHeaderlength: 3333, - PacketsWithIncorrectVersionNumber: 4444, - PacketsDestinedToDeadNextHop: 5555, - FragmentsReceived: 888888, - FragmentsDroppedDueToOutofspaceOrDup: 6666, - FragmentsDroppedDueToQueueoverflow: 7777, - FragmentsDroppedAfterTimeout: 8888, - PacketsReassembledOk: 777777, - PacketsForThisHost: 555555, - PacketsForUnknownOrUnsupportedProtocol: 9999, - PacketsForwarded: 444444, - PacketsNotForwardable: 11111, - RedirectsSent: 12121, - PacketsSentFromThisHost: 666666, - PacketsSentWithFabricatedIpHeader: 13131, - OutputPacketsDroppedDueToNoBufs: 14141, - OutputPacketsDiscardedDueToNoRoute: 15151, - OutputDatagramsFragmented: 16161, - FragmentsCreated: 17171, - DatagramsThatCanNotBeFragmented: 18181, - PacketsWithBadOptions: 19191, - PacketsWithOptionsHandledWithoutError: 20202, - StrictSourceAndRecordRouteOptions: 21212, - LooseSourceAndRecordRouteOptions: 22222, - RecordRouteOptions: 23232, - TimestampOptions: 24242, - TimestampAndAddressOptions: 25252, - TimestampAndPrespecifiedAddressOptions: 26262, - OptionPacketsDroppedDueToRateLimit: 27272, - RouterAlertOptions: 28282, - MulticastPacketsDropped: 29292, - PacketsDropped: 30303, - TransitRePacketsDroppedOnMgmtInterface: 31313, - PacketsUsedFirstNexthopInEcmpUnilist: 32323, - IncomingTtpoipPacketsReceived: 33333, - IncomingTtpoipPacketsDropped: 34343, - OutgoingTtpoipPacketsSent: 35353, - OutgoingTtpoipPacketsDropped: 36363, - IncomingRawipPacketsDroppedNoSocketBuffer: 37373, - IncomingVirtualNodePacketsDelivered: 38383, - }, - }, - Cli: struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - }{ - Banner: "admin@high-traffic-router>", - }, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var result StatisticsIPv4 - err := xml.Unmarshal([]byte(tt.xmlInput), &result) - assert.NoError(t, err, "unmarshal should not return error") - - assert.Equal(t, tt.expected.Statistics.Ip.PacketsReceived, result.Statistics.Ip.PacketsReceived, "PacketsReceived should match") - assert.Equal(t, tt.expected.Statistics.Ip.BadHeaderChecksums, result.Statistics.Ip.BadHeaderChecksums, "BadHeaderChecksums should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, "PacketsWithSizeSmallerThanMinimum should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, result.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, "PacketsWithDataSizeLessThanDatalength should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, result.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, "PacketsWithHeaderLengthLessThanDataSize should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, result.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, "PacketsWithDataLengthLessThanHeaderlength should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithIncorrectVersionNumber, result.Statistics.Ip.PacketsWithIncorrectVersionNumber, "PacketsWithIncorrectVersionNumber should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsDestinedToDeadNextHop, result.Statistics.Ip.PacketsDestinedToDeadNextHop, "PacketsDestinedToDeadNextHop should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsReceived, result.Statistics.Ip.FragmentsReceived, "FragmentsReceived should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, result.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, "FragmentsDroppedDueToOutofspaceOrDup should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, result.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, "FragmentsDroppedDueToQueueoverflow should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedAfterTimeout, result.Statistics.Ip.FragmentsDroppedAfterTimeout, "FragmentsDroppedAfterTimeout should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsReassembledOk, result.Statistics.Ip.PacketsReassembledOk, "PacketsReassembledOk should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsForThisHost, result.Statistics.Ip.PacketsForThisHost, "PacketsForThisHost should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, result.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, "PacketsForUnknownOrUnsupportedProtocol should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsForwarded, result.Statistics.Ip.PacketsForwarded, "PacketsForwarded should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsNotForwardable, result.Statistics.Ip.PacketsNotForwardable, "PacketsNotForwardable should match") - assert.Equal(t, tt.expected.Statistics.Ip.RedirectsSent, result.Statistics.Ip.RedirectsSent, "RedirectsSent should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentFromThisHost, result.Statistics.Ip.PacketsSentFromThisHost, "PacketsSentFromThisHost should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentWithFabricatedIpHeader, result.Statistics.Ip.PacketsSentWithFabricatedIpHeader, "PacketsSentWithFabricatedIpHeader should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, result.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, "OutputPacketsDroppedDueToNoBufs should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, result.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, "OutputPacketsDiscardedDueToNoRoute should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutputDatagramsFragmented, result.Statistics.Ip.OutputDatagramsFragmented, "OutputDatagramsFragmented should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsCreated, result.Statistics.Ip.FragmentsCreated, "FragmentsCreated should match") - assert.Equal(t, tt.expected.Statistics.Ip.DatagramsThatCanNotBeFragmented, result.Statistics.Ip.DatagramsThatCanNotBeFragmented, "DatagramsThatCanNotBeFragmented should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithBadOptions, result.Statistics.Ip.PacketsWithBadOptions, "PacketsWithBadOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithOptionsHandledWithoutError, result.Statistics.Ip.PacketsWithOptionsHandledWithoutError, "PacketsWithOptionsHandledWithoutError should match") - assert.Equal(t, tt.expected.Statistics.Ip.StrictSourceAndRecordRouteOptions, result.Statistics.Ip.StrictSourceAndRecordRouteOptions, "StrictSourceAndRecordRouteOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.LooseSourceAndRecordRouteOptions, result.Statistics.Ip.LooseSourceAndRecordRouteOptions, "LooseSourceAndRecordRouteOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.RecordRouteOptions, result.Statistics.Ip.RecordRouteOptions, "RecordRouteOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.TimestampOptions, result.Statistics.Ip.TimestampOptions, "TimestampOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndAddressOptions, result.Statistics.Ip.TimestampAndAddressOptions, "TimestampAndAddressOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, result.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, "TimestampAndPrespecifiedAddressOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, result.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, "OptionPacketsDroppedDueToRateLimit should match") - assert.Equal(t, tt.expected.Statistics.Ip.RouterAlertOptions, result.Statistics.Ip.RouterAlertOptions, "RouterAlertOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.MulticastPacketsDropped, result.Statistics.Ip.MulticastPacketsDropped, "MulticastPacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsDropped, result.Statistics.Ip.PacketsDropped, "PacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, result.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, "TransitRePacketsDroppedOnMgmtInterface should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, result.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, "PacketsUsedFirstNexthopInEcmpUnilist should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived, result.Statistics.Ip.IncomingTtpoipPacketsReceived, "IncomingTtpoipPacketsReceived should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsDropped, result.Statistics.Ip.IncomingTtpoipPacketsDropped, "IncomingTtpoipPacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsSent, result.Statistics.Ip.OutgoingTtpoipPacketsSent, "OutgoingTtpoipPacketsSent should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsDropped, result.Statistics.Ip.OutgoingTtpoipPacketsDropped, "OutgoingTtpoipPacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, result.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, "IncomingRawipPacketsDroppedNoSocketBuffer should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingVirtualNodePacketsDelivered, result.Statistics.Ip.IncomingVirtualNodePacketsDelivered, "IncomingVirtualNodePacketsDelivered should match") - }) - } -} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go b/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go deleted file mode 100644 index cee440dd..00000000 --- a/pkg/features/systemstatistics/systemstatisticsIPv6/collector.go +++ /dev/null @@ -1,208 +0,0 @@ -package systemstatisticsIPv6 - -import ( - "github.com/prometheus/client_golang/prometheus" - - "github.com/czerwonk/junos_exporter/pkg/collector" -) - -const prefix string = "junos_systemstatistics_ipv6_" - -// Metrics to collect for the feature -var ( - totalPacketsReceivedDesc *prometheus.Desc - ip6PacketsWithSizeSmallerThanMinimumDesc *prometheus.Desc - packetsWithDatasizeLessThanDataLengthDesc *prometheus.Desc - ip6PacketsWithBadOptionsDesc *prometheus.Desc - ip6PacketsWithIncorrectVersionNumberDesc *prometheus.Desc - ip6FragmentsReceivedDesc *prometheus.Desc - duplicateOrOutOfSpaceFragmentsDroppedDesc *prometheus.Desc - ip6FragmentsDroppedAfterTimeoutDesc *prometheus.Desc - fragmentsThatExceededLimitDesc *prometheus.Desc - ip6PacketsReassembledOkDesc *prometheus.Desc - ip6PacketsForThisHostDesc *prometheus.Desc - ip6PacketsForwardedDesc *prometheus.Desc - ip6PacketsNotForwardableDesc *prometheus.Desc - ip6RedirectsSentDesc *prometheus.Desc - ip6PacketsSentFromThisHostDesc *prometheus.Desc - ip6PacketsSentWithFabricatedIpHeaderDesc *prometheus.Desc - ip6OutputPacketsDroppedDueToNoBufsDesc *prometheus.Desc - ip6OutputPacketsDiscardedDueToNoRouteDesc *prometheus.Desc - ip6OutputDatagramsFragmentedDesc *prometheus.Desc - ip6FragmentsCreatedDesc *prometheus.Desc - ip6DatagramsThatCanNotBeFragmentedDesc *prometheus.Desc - packetsThatViolatedScopeRulesDesc *prometheus.Desc - multicastPacketsWhichWeDoNotJoinDesc *prometheus.Desc - ip6nhTcpDesc *prometheus.Desc - ip6nhUdpDesc *prometheus.Desc - ip6nhIcmp6Desc *prometheus.Desc - packetsWhoseHeadersAreNotContinuousDesc *prometheus.Desc - tunnelingPacketsThatCanNotFindGifDesc *prometheus.Desc - packetsDiscardedDueToTooMayHeadersDesc *prometheus.Desc - failuresOfSourceAddressSelectionDesc *prometheus.Desc - headerTypeLinkLocalsDesc *prometheus.Desc - headerTypeGlobalsDesc *prometheus.Desc - forwardCacheHitDesc *prometheus.Desc - forwardCacheMissDesc *prometheus.Desc - ip6PacketsDestinedToDeadNextHopDesc *prometheus.Desc - ip6OptionPacketsDroppedDueToRateLimitDesc *prometheus.Desc - ip6PacketsDroppedDesc *prometheus.Desc - packetsDroppedDueToBadProtocolDesc *prometheus.Desc - transitRePacketDroppedOnMgmtInterfaceDesc *prometheus.Desc - packetUsedFirstNexthopInEcmpUnilistDesc *prometheus.Desc -) - -func init() { - labels := []string{"target", "protocol"} - totalPacketsReceivedDesc = prometheus.NewDesc(prefix+"total_packets_received", "Total number of packets received", labels, nil) - ip6PacketsWithSizeSmallerThanMinimumDesc = prometheus.NewDesc(prefix+"ip6_packets_with_size_smaller_than_minimum", "Number of packets received with size smaller than minimum", labels, nil) - packetsWithDatasizeLessThanDataLengthDesc = prometheus.NewDesc(prefix+"packets_with_datasize_less_than_data_length", "Number of packets received with data length less than data length", labels, nil) - ip6PacketsWithBadOptionsDesc = prometheus.NewDesc(prefix+"ip6_packets_with_bad_options", "Number of packets received with bad options", labels, nil) - ip6PacketsWithIncorrectVersionNumberDesc = prometheus.NewDesc(prefix+"ip6_packets_with_incorrect_version_number", "Number of packets received with incorrect version number", labels, nil) - ip6FragmentsReceivedDesc = prometheus.NewDesc(prefix+"ip6_fragments_received", "Number of fragments received", labels, nil) - duplicateOrOutOfSpaceFragmentsDroppedDesc = prometheus.NewDesc(prefix+"duplicate_or_out_of_space_fragments_dropped", "Number of duplicate or out of space fragments dropped", labels, nil) - ip6FragmentsDroppedAfterTimeoutDesc = prometheus.NewDesc(prefix+"ip6_fragments_dropped_after_timeout", "Number of fragments dropped after timeout", labels, nil) - fragmentsThatExceededLimitDesc = prometheus.NewDesc(prefix+"fragments_that_exceeded_limit", "Number of fragments that exceeded limit", labels, nil) - ip6PacketsReassembledOkDesc = prometheus.NewDesc(prefix+"ip6_packets_reassembled_ok", "Number of packets reassembled ok", labels, nil) - ip6PacketsForThisHostDesc = prometheus.NewDesc(prefix+"ip6_packets_for_this_host", "Number of packets for this host", labels, nil) - ip6PacketsForwardedDesc = prometheus.NewDesc(prefix+"ip6_packets_forwarded", "Number of packets forwarded", labels, nil) - ip6PacketsNotForwardableDesc = prometheus.NewDesc(prefix+"ip6_packets_not_forwardable", "Number of packets not forwardable", labels, nil) - ip6RedirectsSentDesc = prometheus.NewDesc(prefix+"ip6_redirects_sent", "Number of redirects sent", labels, nil) - ip6PacketsSentFromThisHostDesc = prometheus.NewDesc(prefix+"ip6_packets_sent_from_this_host", "Number of packets sent from this host", labels, nil) - ip6PacketsSentWithFabricatedIpHeaderDesc = prometheus.NewDesc(prefix+"ip6_packets_sent_with_fabricated_ip_header", "Number of packets sent with fabricated ip header", labels, nil) - ip6OutputPacketsDroppedDueToNoBufsDesc = prometheus.NewDesc(prefix+"ip6_output_packets_dropped_due_to_no_bufs", "Number of output packets dropped due to no bufs", labels, nil) - ip6OutputPacketsDiscardedDueToNoRouteDesc = prometheus.NewDesc(prefix+"ip6_output_packets_discarded_due_to_no_route", "Number of output packets discarded due to no route", labels, nil) - ip6OutputDatagramsFragmentedDesc = prometheus.NewDesc(prefix+"ip6_output_datagrams_fragmented", "Number of output datagrams fragmented", labels, nil) - ip6FragmentsCreatedDesc = prometheus.NewDesc(prefix+"ip6_fragments_created", "Number of fragments created", labels, nil) - ip6DatagramsThatCanNotBeFragmentedDesc = prometheus.NewDesc(prefix+"ip6_datagrams_that_can_not_be_fragmented", "Number of datagrams that can not be fragmented", labels, nil) - packetsThatViolatedScopeRulesDesc = prometheus.NewDesc(prefix+"packets_that_violated_scope_rules", "Number of packets that violated scope rules", labels, nil) - multicastPacketsWhichWeDoNotJoinDesc = prometheus.NewDesc(prefix+"multicast_packets_which_we_do_not_join", "Number of multicast packets which we do not join", labels, nil) - ip6nhTcpDesc = prometheus.NewDesc(prefix+"ip6nh_tcp", "Number of packets with next header tcp", labels, nil) - ip6nhUdpDesc = prometheus.NewDesc(prefix+"ip6nh_udp", "Number of packets with next header udp", labels, nil) - ip6nhIcmp6Desc = prometheus.NewDesc(prefix+"ip6nh_icmp6", "Number of packets with next header icmp6", labels, nil) - packetsWhoseHeadersAreNotContinuousDesc = prometheus.NewDesc(prefix+"packets_whose_headers_are_not_continuous", "Number of packets whose headers are not continuous", labels, nil) - tunnelingPacketsThatCanNotFindGifDesc = prometheus.NewDesc(prefix+"tunneling_packets_that_can_not_find_gif", "Number of tunneling packets that can not find gif", labels, nil) - packetsDiscardedDueToTooMayHeadersDesc = prometheus.NewDesc(prefix+"packets_discarded_due_to_too_may_headers", "Number of packets discarded due to too may headers", labels, nil) - failuresOfSourceAddressSelectionDesc = prometheus.NewDesc(prefix+"failures_of_source_address_selection", "Number of failures of source address selection", labels, nil) - l := []string{"target", "protocol", "header_type"} - headerTypeLinkLocalsDesc = prometheus.NewDesc(prefix+"header_type_link_locals", "Number of packets with header type link locals", l, nil) - headerTypeGlobalsDesc = prometheus.NewDesc(prefix+"header_type_globals", "Number of packets with header type globals", l, nil) - forwardCacheHitDesc = prometheus.NewDesc(prefix+"forward_cache_hit", "Number of forward cache hit", labels, nil) - forwardCacheMissDesc = prometheus.NewDesc(prefix+"forward_cache_miss", "Number of forward cache miss", labels, nil) - ip6PacketsDestinedToDeadNextHopDesc = prometheus.NewDesc(prefix+"ip6_packets_destined_to_dead_next_hop", "Number of packets destined to dead next hop", labels, nil) - ip6OptionPacketsDroppedDueToRateLimitDesc = prometheus.NewDesc(prefix+"ip6_option_packets_dropped_due_to_rate_limit", "Number of option packets dropped due to rate limit", labels, nil) - ip6PacketsDroppedDesc = prometheus.NewDesc(prefix+"ip6_packets_dropped", "Number of packets dropped", labels, nil) - packetsDroppedDueToBadProtocolDesc = prometheus.NewDesc(prefix+"packets_dropped_due_to_bad_protocol", "Number of packets dropped due to bad protocol", labels, nil) - transitRePacketDroppedOnMgmtInterfaceDesc = prometheus.NewDesc(prefix+"transit_re_packet_dropped_on_mgmt_interface", "Number of transit re packet dropped on mgmt interface", labels, nil) - packetUsedFirstNexthopInEcmpUnilistDesc = prometheus.NewDesc(prefix+"packet_used_first_nexthop_in_ecmp_unilist", "Number of packet used first nexthop in ecmp unilist", labels, nil) -} - -type systemstatisticsIPv6Collector struct{} - -func NewCollector() collector.RPCCollector { - return &systemstatisticsIPv6Collector{} -} - -func (c *systemstatisticsIPv6Collector) Name() string { - return "systemstatisticsIPv6" -} - -func (c *systemstatisticsIPv6Collector) Describe(ch chan<- *prometheus.Desc) { - ch <- totalPacketsReceivedDesc - ch <- ip6PacketsWithSizeSmallerThanMinimumDesc - ch <- packetsWithDatasizeLessThanDataLengthDesc - ch <- ip6PacketsWithBadOptionsDesc - ch <- ip6PacketsWithIncorrectVersionNumberDesc - ch <- ip6FragmentsReceivedDesc - ch <- duplicateOrOutOfSpaceFragmentsDroppedDesc - ch <- ip6FragmentsDroppedAfterTimeoutDesc - ch <- fragmentsThatExceededLimitDesc - ch <- ip6PacketsReassembledOkDesc - ch <- ip6PacketsForThisHostDesc - ch <- ip6PacketsForwardedDesc - ch <- ip6PacketsNotForwardableDesc - ch <- ip6RedirectsSentDesc - ch <- ip6PacketsSentFromThisHostDesc - ch <- ip6PacketsSentWithFabricatedIpHeaderDesc - ch <- ip6OutputPacketsDroppedDueToNoBufsDesc - ch <- ip6OutputPacketsDiscardedDueToNoRouteDesc - ch <- ip6OutputDatagramsFragmentedDesc - ch <- ip6FragmentsCreatedDesc - ch <- ip6DatagramsThatCanNotBeFragmentedDesc - ch <- packetsThatViolatedScopeRulesDesc - ch <- multicastPacketsWhichWeDoNotJoinDesc - ch <- ip6nhTcpDesc - ch <- ip6nhUdpDesc - ch <- ip6nhIcmp6Desc - ch <- packetsWhoseHeadersAreNotContinuousDesc - ch <- tunnelingPacketsThatCanNotFindGifDesc - ch <- packetsDiscardedDueToTooMayHeadersDesc - ch <- failuresOfSourceAddressSelectionDesc - ch <- headerTypeLinkLocalsDesc - ch <- headerTypeGlobalsDesc - ch <- forwardCacheHitDesc - ch <- forwardCacheMissDesc - ch <- ip6PacketsDestinedToDeadNextHopDesc - ch <- ip6OptionPacketsDroppedDueToRateLimitDesc - ch <- ip6PacketsDroppedDesc - ch <- packetsDroppedDueToBadProtocolDesc - ch <- transitRePacketDroppedOnMgmtInterfaceDesc - ch <- packetUsedFirstNexthopInEcmpUnilistDesc -} - -func (c *systemstatisticsIPv6Collector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { - var s StatisticsIPv6 - err := client.RunCommandAndParse("show system statistics ip6", &s) - if err != nil { - return err - } - c.collectSystemStatisticsIPv6(ch, labelValues, s) - return nil -} - -func (c *systemstatisticsIPv6Collector) collectSystemStatisticsIPv6(ch chan<- prometheus.Metric, labelValues []string, s StatisticsIPv6) { - labels := append(labelValues, "ipv6") - ch <- prometheus.MustNewConstMetric(totalPacketsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip6.TotalPacketsReceived, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsWithSizeSmallerThanMinimumDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithSizeSmallerThanMinimum, labels...) - ch <- prometheus.MustNewConstMetric(packetsWithDatasizeLessThanDataLengthDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsWithDatasizeLessThanDataLength, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsWithBadOptionsDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithBadOptions, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsWithIncorrectVersionNumberDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsWithIncorrectVersionNumber, labels...) - ch <- prometheus.MustNewConstMetric(ip6FragmentsReceivedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsReceived, labels...) - ch <- prometheus.MustNewConstMetric(duplicateOrOutOfSpaceFragmentsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip6.DuplicateOrOutOfSpaceFragmentsDropped, labels...) - ch <- prometheus.MustNewConstMetric(ip6FragmentsDroppedAfterTimeoutDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsDroppedAfterTimeout, labels...) - ch <- prometheus.MustNewConstMetric(fragmentsThatExceededLimitDesc, prometheus.CounterValue, s.Statistics.Ip6.FragmentsThatExceededLimit, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsReassembledOkDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsReassembledOk, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsForThisHostDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsForThisHost, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsForwardedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsForwarded, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsNotForwardableDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsNotForwardable, labels...) - ch <- prometheus.MustNewConstMetric(ip6RedirectsSentDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6RedirectsSent, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsSentFromThisHostDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsSentFromThisHost, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsSentWithFabricatedIpHeaderDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsSentWithFabricatedIpHeader, labels...) - ch <- prometheus.MustNewConstMetric(ip6OutputPacketsDroppedDueToNoBufsDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputPacketsDroppedDueToNoBufs, labels...) - ch <- prometheus.MustNewConstMetric(ip6OutputPacketsDiscardedDueToNoRouteDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputPacketsDiscardedDueToNoRoute, labels...) - ch <- prometheus.MustNewConstMetric(ip6OutputDatagramsFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OutputDatagramsFragmented, labels...) - ch <- prometheus.MustNewConstMetric(ip6FragmentsCreatedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6FragmentsCreated, labels...) - ch <- prometheus.MustNewConstMetric(ip6DatagramsThatCanNotBeFragmentedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6DatagramsThatCanNotBeFragmented, labels...) - ch <- prometheus.MustNewConstMetric(packetsThatViolatedScopeRulesDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsThatViolatedScopeRules, labels...) - ch <- prometheus.MustNewConstMetric(multicastPacketsWhichWeDoNotJoinDesc, prometheus.CounterValue, s.Statistics.Ip6.MulticastPacketsWhichWeDoNotJoin, labels...) - ch <- prometheus.MustNewConstMetric(ip6nhTcpDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhTcp, labels...) - ch <- prometheus.MustNewConstMetric(ip6nhUdpDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhUdp, labels...) - ch <- prometheus.MustNewConstMetric(ip6nhIcmp6Desc, prometheus.CounterValue, s.Statistics.Ip6.Ip6nhIcmp6, labels...) - ch <- prometheus.MustNewConstMetric(packetsWhoseHeadersAreNotContinuousDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsWhoseHeadersAreNotContinuous, labels...) - ch <- prometheus.MustNewConstMetric(tunnelingPacketsThatCanNotFindGifDesc, prometheus.CounterValue, s.Statistics.Ip6.TunnelingPacketsThatCanNotFindGif, labels...) - ch <- prometheus.MustNewConstMetric(packetsDiscardedDueToTooMayHeadersDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsDiscardedDueToTooMayHeaders, labels...) - ch <- prometheus.MustNewConstMetric(failuresOfSourceAddressSelectionDesc, prometheus.CounterValue, s.Statistics.Ip6.FailuresOfSourceAddressSelection, labels...) - for _, header := range s.Statistics.Ip6.HeaderType { - labels := append(labelValues, "ipv6", header.HeaderForSourceAddressSelection) - ch <- prometheus.MustNewConstMetric(headerTypeLinkLocalsDesc, prometheus.CounterValue, header.LinkLocals, labels...) - ch <- prometheus.MustNewConstMetric(headerTypeGlobalsDesc, prometheus.CounterValue, header.Globals, labels...) - } - ch <- prometheus.MustNewConstMetric(forwardCacheHitDesc, prometheus.CounterValue, s.Statistics.Ip6.ForwardCacheHit, labels...) - ch <- prometheus.MustNewConstMetric(forwardCacheMissDesc, prometheus.CounterValue, s.Statistics.Ip6.ForwardCacheMiss, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsDestinedToDeadNextHopDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsDestinedToDeadNextHop, labels...) - ch <- prometheus.MustNewConstMetric(ip6OptionPacketsDroppedDueToRateLimitDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6OptionPacketsDroppedDueToRateLimit, labels...) - ch <- prometheus.MustNewConstMetric(ip6PacketsDroppedDesc, prometheus.CounterValue, s.Statistics.Ip6.Ip6PacketsDropped, labels...) - ch <- prometheus.MustNewConstMetric(packetsDroppedDueToBadProtocolDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketsDroppedDueToBadProtocol, labels...) - ch <- prometheus.MustNewConstMetric(transitRePacketDroppedOnMgmtInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip6.TransitRePacketDroppedOnMgmtInterface, labels...) - ch <- prometheus.MustNewConstMetric(packetUsedFirstNexthopInEcmpUnilistDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketUsedFirstNexthopInEcmpUnilist, labels...) -} diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go deleted file mode 100644 index 8014230e..00000000 --- a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc.go +++ /dev/null @@ -1,66 +0,0 @@ -package systemstatisticsIPv6 - -import "encoding/xml" - -type StatisticsIPv6 struct { - XMLName xml.Name `xml:"rpc-reply"` - Text string `xml:",chardata"` - Junos string `xml:"junos,attr"` - Statistics struct { - Text string `xml:",chardata"` - Ip6 struct { - Text string `xml:",chardata"` - TotalPacketsReceived float64 `xml:"total-packets-received"` - Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` - PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` - Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` - Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` - Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` - DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` - Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` - FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` - Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` - Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` - Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` - Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` - Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` - Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` - Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` - Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` - Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` - Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` - Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` - Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` - PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` - MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` - Histogram string `xml:"histogram"` - Ip6nhTcp float64 `xml:"ip6nh-tcp"` - Ip6nhUdp float64 `xml:"ip6nh-udp"` - Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` - PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` - TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` - PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` - FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` - HeaderType []struct { - Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` - LinkLocals float64 `xml:"link-locals"` - Globals float64 `xml:"globals"` - AddressScope string `xml:"address-scope"` - HexValue string `xml:"hex-value"` - } `xml:"header-type"` - ForwardCacheHit float64 `xml:"forward-cache-hit"` - ForwardCacheMiss float64 `xml:"forward-cache-miss"` - Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` - Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` - Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` - PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` - TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` - PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` - } `xml:"ip6"` - } `xml:"statistics"` - Cli struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - } `xml:"cli"` -} \ No newline at end of file diff --git a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go b/pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go deleted file mode 100644 index 15f29ddb..00000000 --- a/pkg/features/systemstatistics/systemstatisticsIPv6/rpc_test.go +++ /dev/null @@ -1,178 +0,0 @@ -package systemstatisticsIPv6 - -import ( - "encoding/xml" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestStatisticsIPv6Unmarshaling_AllNumericalFields(t *testing.T) { - tests := []struct { - name string - xmlInput string - expected map[string]float64 - }{ - { - name: "all_fields_nonzero", - xmlInput: ` - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - - - `, - expected: map[string]float64{ - "TotalPacketsReceived": 1, - "Ip6PacketsWithSizeSmallerThanMinimum": 2, - "PacketsWithDatasizeLessThanDataLength": 3, - "Ip6PacketsWithBadOptions": 4, - "Ip6PacketsWithIncorrectVersionNumber": 5, - "Ip6FragmentsReceived": 6, - "DuplicateOrOutOfSpaceFragmentsDropped": 7, - "Ip6FragmentsDroppedAfterTimeout": 8, - "FragmentsThatExceededLimit": 9, - "Ip6PacketsReassembledOk": 10, - "Ip6PacketsForThisHost": 11, - "Ip6PacketsForwarded": 12, - "Ip6PacketsNotForwardable": 13, - "Ip6RedirectsSent": 14, - "Ip6PacketsSentFromThisHost": 15, - "Ip6PacketsSentWithFabricatedIpHeader": 16, - "Ip6OutputPacketsDroppedDueToNoBufs": 17, - "Ip6OutputPacketsDiscardedDueToNoRoute": 18, - "Ip6OutputDatagramsFragmented": 19, - "Ip6FragmentsCreated": 20, - "Ip6DatagramsThatCanNotBeFragmented": 21, - "PacketsThatViolatedScopeRules": 22, - "MulticastPacketsWhichWeDoNotJoin": 23, - "Ip6nhTcp": 24, - "Ip6nhUdp": 25, - "Ip6nhIcmp6": 26, - }, - }, - { - name: "all_fields_zero", - xmlInput: ` - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - `, - expected: map[string]float64{ - "TotalPacketsReceived": 0, - "Ip6PacketsWithSizeSmallerThanMinimum": 0, - "PacketsWithDatasizeLessThanDataLength": 0, - "Ip6PacketsWithBadOptions": 0, - "Ip6PacketsWithIncorrectVersionNumber": 0, - "Ip6FragmentsReceived": 0, - "DuplicateOrOutOfSpaceFragmentsDropped": 0, - "Ip6FragmentsDroppedAfterTimeout": 0, - "FragmentsThatExceededLimit": 0, - "Ip6PacketsReassembledOk": 0, - "Ip6PacketsForThisHost": 0, - "Ip6PacketsForwarded": 0, - "Ip6PacketsNotForwardable": 0, - "Ip6RedirectsSent": 0, - "Ip6PacketsSentFromThisHost": 0, - "Ip6PacketsSentWithFabricatedIpHeader": 0, - "Ip6OutputPacketsDroppedDueToNoBufs": 0, - "Ip6OutputPacketsDiscardedDueToNoRoute": 0, - "Ip6OutputDatagramsFragmented": 0, - "Ip6FragmentsCreated": 0, - "Ip6DatagramsThatCanNotBeFragmented": 0, - "PacketsThatViolatedScopeRules": 0, - "MulticastPacketsWhichWeDoNotJoin": 0, - "Ip6nhTcp": 0, - "Ip6nhUdp": 0, - "Ip6nhIcmp6": 0, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - var actual StatisticsIPv6 - err := xml.Unmarshal([]byte(tt.xmlInput), &actual) - assert.NoError(t, err) - - assert.Equal(t, tt.expected["TotalPacketsReceived"], actual.Statistics.Ip6.TotalPacketsReceived, "TotalPacketsReceived mismatch") - assert.Equal(t, tt.expected["Ip6PacketsWithSizeSmallerThanMinimum"], actual.Statistics.Ip6.Ip6PacketsWithSizeSmallerThanMinimum, "Ip6PacketsWithSizeSmallerThanMinimum mismatch") - assert.Equal(t, tt.expected["PacketsWithDatasizeLessThanDataLength"], actual.Statistics.Ip6.PacketsWithDatasizeLessThanDataLength, "PacketsWithDatasizeLessThanDataLength mismatch") - assert.Equal(t, tt.expected["Ip6PacketsWithBadOptions"], actual.Statistics.Ip6.Ip6PacketsWithBadOptions, "Ip6PacketsWithBadOptions mismatch") - assert.Equal(t, tt.expected["Ip6PacketsWithIncorrectVersionNumber"], actual.Statistics.Ip6.Ip6PacketsWithIncorrectVersionNumber, "Ip6PacketsWithIncorrectVersionNumber mismatch") - assert.Equal(t, tt.expected["Ip6FragmentsReceived"], actual.Statistics.Ip6.Ip6FragmentsReceived, "Ip6FragmentsReceived mismatch") - assert.Equal(t, tt.expected["DuplicateOrOutOfSpaceFragmentsDropped"], actual.Statistics.Ip6.DuplicateOrOutOfSpaceFragmentsDropped, "DuplicateOrOutOfSpaceFragmentsDropped mismatch") - assert.Equal(t, tt.expected["Ip6FragmentsDroppedAfterTimeout"], actual.Statistics.Ip6.Ip6FragmentsDroppedAfterTimeout, "Ip6FragmentsDroppedAfterTimeout mismatch") - assert.Equal(t, tt.expected["FragmentsThatExceededLimit"], actual.Statistics.Ip6.FragmentsThatExceededLimit, "FragmentsThatExceededLimit mismatch") - assert.Equal(t, tt.expected["Ip6PacketsReassembledOk"], actual.Statistics.Ip6.Ip6PacketsReassembledOk, "Ip6PacketsReassembledOk mismatch") - assert.Equal(t, tt.expected["Ip6PacketsForThisHost"], actual.Statistics.Ip6.Ip6PacketsForThisHost, "Ip6PacketsForThisHost mismatch") - assert.Equal(t, tt.expected["Ip6PacketsForwarded"], actual.Statistics.Ip6.Ip6PacketsForwarded, "Ip6PacketsForwarded mismatch") - assert.Equal(t, tt.expected["Ip6PacketsNotForwardable"], actual.Statistics.Ip6.Ip6PacketsNotForwardable, "Ip6PacketsNotForwardable mismatch") - assert.Equal(t, tt.expected["Ip6RedirectsSent"], actual.Statistics.Ip6.Ip6RedirectsSent, "Ip6RedirectsSent mismatch") - assert.Equal(t, tt.expected["Ip6PacketsSentFromThisHost"], actual.Statistics.Ip6.Ip6PacketsSentFromThisHost, "Ip6PacketsSentFromThisHost mismatch") - assert.Equal(t, tt.expected["Ip6PacketsSentWithFabricatedIpHeader"], actual.Statistics.Ip6.Ip6PacketsSentWithFabricatedIpHeader, "Ip6PacketsSentWithFabricatedIpHeader mismatch") - assert.Equal(t, tt.expected["Ip6OutputPacketsDroppedDueToNoBufs"], actual.Statistics.Ip6.Ip6OutputPacketsDroppedDueToNoBufs, "Ip6OutputPacketsDroppedDueToNoBufs mismatch") - assert.Equal(t, tt.expected["Ip6OutputPacketsDiscardedDueToNoRoute"], actual.Statistics.Ip6.Ip6OutputPacketsDiscardedDueToNoRoute, "Ip6OutputPacketsDiscardedDueToNoRoute mismatch") - assert.Equal(t, tt.expected["Ip6OutputDatagramsFragmented"], actual.Statistics.Ip6.Ip6OutputDatagramsFragmented, "Ip6OutputDatagramsFragmented mismatch") - assert.Equal(t, tt.expected["Ip6FragmentsCreated"], actual.Statistics.Ip6.Ip6FragmentsCreated, "Ip6FragmentsCreated mismatch") - assert.Equal(t, tt.expected["Ip6DatagramsThatCanNotBeFragmented"], actual.Statistics.Ip6.Ip6DatagramsThatCanNotBeFragmented, "Ip6DatagramsThatCanNotBeFragmented mismatch") - assert.Equal(t, tt.expected["PacketsThatViolatedScopeRules"], actual.Statistics.Ip6.PacketsThatViolatedScopeRules, "PacketsThatViolatedScopeRules mismatch") - assert.Equal(t, tt.expected["MulticastPacketsWhichWeDoNotJoin"], actual.Statistics.Ip6.MulticastPacketsWhichWeDoNotJoin, "MulticastPacketsWhichWeDoNotJoin mismatch") - assert.Equal(t, tt.expected["Ip6nhTcp"], actual.Statistics.Ip6.Ip6nhTcp, "Ip6nhTcp mismatch") - assert.Equal(t, tt.expected["Ip6nhUdp"], actual.Statistics.Ip6.Ip6nhUdp, "Ip6nhUdp mismatch") - assert.Equal(t, tt.expected["Ip6nhIcmp6"], actual.Statistics.Ip6.Ip6nhIcmp6, "Ip6nhIcmp6 mismatch") - }) - } -} \ No newline at end of file From 06bb8d827c1ee27420ffcad555289fcf4ceab780 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 28 Aug 2025 13:26:53 +0200 Subject: [PATCH 09/27] refactored ipv4, ipv6 and udp and added tests for ipv4 --- pkg/features/systemstatistics/collector.go | 48 + pkg/features/systemstatistics/rpc.go | 250 ++-- pkg/features/systemstatistics/rpc_test.go | 1305 ++++++++++++++++++++ 3 files changed, 1478 insertions(+), 125 deletions(-) create mode 100644 pkg/features/systemstatistics/rpc_test.go diff --git a/pkg/features/systemstatistics/collector.go b/pkg/features/systemstatistics/collector.go index a704991d..e959b449 100644 --- a/pkg/features/systemstatistics/collector.go +++ b/pkg/features/systemstatistics/collector.go @@ -94,6 +94,17 @@ var ( ipv6PacketsDroppedDueToBadProtocolDesc *prometheus.Desc ipv6TransitRePacketDroppedOnMgmtInterfaceDesc *prometheus.Desc ipv6PacketUsedFirstNexthopInEcmpUnilistDesc *prometheus.Desc + + udpDatagramsReceivedDesc *prometheus.Desc + udpDatagramsWithIncompleteHeaderDesc *prometheus.Desc + udpDatagramsWithBadDatalengthFieldDesc *prometheus.Desc + udpDatagramsWithBadChecksumDesc *prometheus.Desc + udpDatagramsDroppedDueToNoSocketDesc *prometheus.Desc + udpBroadcastOrMulticastDatagramsDroppedDueToNoSocketDesc *prometheus.Desc + udpDatagramsDroppedDueToFullSocketBuffersDesc *prometheus.Desc + udpDatagramsNotForHashedPcbDesc *prometheus.Desc + udpDatagramsDeliveredDesc *prometheus.Desc + udpDatagramsOutputDesc *prometheus.Desc ) func init() { @@ -186,6 +197,17 @@ func init() { ipv6TransitRePacketDroppedOnMgmtInterfaceDesc = prometheus.NewDesc(prefix+"ipv6_transit_re_packet_dropped_on_mgmt_interface", "Number of transit re packet dropped on mgmt interface", labelsIPV6, nil) ipv6PacketUsedFirstNexthopInEcmpUnilistDesc = prometheus.NewDesc(prefix+"ipv6_packet_used_first_nexthop_in_ecmp_unilist", "Number of packet used first nexthop in ecmp unilist", labelsIPV6, nil) + labelsUDP := []string{"target", "protocol"} + udpDatagramsReceivedDesc = prometheus.NewDesc(prefix+"udp_datagrams_received", "Number of UDP datagrams received", labelsUDP, nil) + udpDatagramsWithIncompleteHeaderDesc = prometheus.NewDesc(prefix+"udp_datagrams_with_incomplete_header", "Number of UDP datagrams with incomplete header", labelsUDP, nil) + udpDatagramsWithBadDatalengthFieldDesc = prometheus.NewDesc(prefix+"udp_datagrams_with_bad_datalength_field", "Number of UDP datagrams with bad datalength field", labelsUDP, nil) + udpDatagramsWithBadChecksumDesc = prometheus.NewDesc(prefix+"udp_datagrams_with_bad_checksum", "Number of UDP datagrams with bad checksum", labelsUDP, nil) + udpDatagramsDroppedDueToNoSocketDesc = prometheus.NewDesc(prefix+"udp_datagrams_dropped_due_to_no_socket", "Number of UDP datagrams dropped due to no socket", labelsUDP, nil) + udpBroadcastOrMulticastDatagramsDroppedDueToNoSocketDesc = prometheus.NewDesc(prefix+"udp_broadcast_or_multicast_datagrams_dropped_due_to_no_socket", "Number of UDP broadcast or multicast datagrams dropped due to no socket", labelsUDP, nil) + udpDatagramsDroppedDueToFullSocketBuffersDesc = prometheus.NewDesc(prefix+"udp_datagrams_dropped_due_to_full_socket_buffers", "Number of UDP datagrams dropped due to full socket buffers", labelsUDP, nil) + udpDatagramsNotForHashedPcbDesc = prometheus.NewDesc(prefix+"udp_datagrams_not_for_hashed_pcb", "Number of UDP datagrams not for hashed pcb", labelsUDP, nil) + udpDatagramsDeliveredDesc = prometheus.NewDesc(prefix+"udp_datagrams_delivered", "Number of UDP datagrams delivered", labelsUDP, nil) + udpDatagramsOutputDesc = prometheus.NewDesc(prefix+"udp_datagrams_output", "Number of UDP datagrams output", labelsUDP, nil) } type systemstatisticsCollector struct{} @@ -284,6 +306,17 @@ func (c *systemstatisticsCollector) Describe(ch chan<- *prometheus.Desc) { ch <- ipv6PacketsDroppedDueToBadProtocolDesc ch <- ipv6TransitRePacketDroppedOnMgmtInterfaceDesc ch <- ipv6PacketUsedFirstNexthopInEcmpUnilistDesc + + ch <- udpDatagramsReceivedDesc + ch <- udpDatagramsWithIncompleteHeaderDesc + ch <- udpDatagramsWithBadDatalengthFieldDesc + ch <- udpDatagramsWithBadChecksumDesc + ch <- udpDatagramsDroppedDueToNoSocketDesc + ch <- udpBroadcastOrMulticastDatagramsDroppedDueToNoSocketDesc + ch <- udpDatagramsDroppedDueToFullSocketBuffersDesc + ch <- udpDatagramsNotForHashedPcbDesc + ch <- udpDatagramsDeliveredDesc + ch <- udpDatagramsOutputDesc } func (c *systemstatisticsCollector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { @@ -294,6 +327,7 @@ func (c *systemstatisticsCollector) Collect(client collector.Client, ch chan<- p } c.collectSystemStatisticsIPV4(ch, labelValues, s) c.collectSystemStatisticsIPV6(ch, labelValues, s) + c.collectSystemStatisticsUDP(ch, labelValues, s) return nil } @@ -391,4 +425,18 @@ func (c *systemstatisticsCollector) collectSystemStatisticsIPV6(ch chan<- promet ch <- prometheus.MustNewConstMetric(ipv6TransitRePacketDroppedOnMgmtInterfaceDesc, prometheus.CounterValue, s.Statistics.Ip6.TransitRePacketDroppedOnMgmtInterface, labels...) ch <- prometheus.MustNewConstMetric(ipv6PacketUsedFirstNexthopInEcmpUnilistDesc, prometheus.CounterValue, s.Statistics.Ip6.PacketUsedFirstNexthopInEcmpUnilist, labels...) +} + +func (c *systemstatisticsCollector) collectSystemStatisticsUDP(ch chan<- prometheus.Metric, labelValues []string, s SystemStatistics) { + l := append(labelValues, "udp") + ch <- prometheus.MustNewConstMetric(udpDatagramsReceivedDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsReceived, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsWithIncompleteHeaderDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsWithIncompleteHeader, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsWithBadDatalengthFieldDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsWithBadDatalengthField, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsWithBadChecksumDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsWithBadChecksum, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsDroppedDueToNoSocketDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsDroppedDueToNoSocket, l...) + ch <- prometheus.MustNewConstMetric(udpBroadcastOrMulticastDatagramsDroppedDueToNoSocketDesc, prometheus.CounterValue, s.Statistics.Udp.BroadcastOrMulticastDatagramsDroppedDueToNoSocket, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsDroppedDueToFullSocketBuffersDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsDroppedDueToFullSocketBuffers, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsNotForHashedPcbDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsNotForHashedPcb, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsDeliveredDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsDelivered, l...) + ch <- prometheus.MustNewConstMetric(udpDatagramsOutputDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsOutput, l...) } \ No newline at end of file diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go index 5c0b0212..eaa74bc8 100644 --- a/pkg/features/systemstatistics/rpc.go +++ b/pkg/features/systemstatistics/rpc.go @@ -11,134 +11,134 @@ type SystemStatistics struct { Tcp struct { Text string `xml:",chardata"` PacketsSent float64 `xml:"packets-sent"` - SentDataPackets string `xml:"sent-data-packets"` - DataPacketsBytes string `xml:"data-packets-bytes"` - SentDataPacketsRetransmitted string `xml:"sent-data-packets-retransmitted"` - RetransmittedBytes string `xml:"retransmitted-bytes"` - SentDataUnnecessaryRetransmitted string `xml:"sent-data-unnecessary-retransmitted"` - SentResendsByMtuDiscovery string `xml:"sent-resends-by-mtu-discovery"` - SentAckOnlyPackets string `xml:"sent-ack-only-packets"` - SentPacketsDelayed string `xml:"sent-packets-delayed"` - SentUrgOnlyPackets string `xml:"sent-urg-only-packets"` - SentWindowProbePackets string `xml:"sent-window-probe-packets"` - SentWindowUpdatePackets string `xml:"sent-window-update-packets"` - SentControlPackets string `xml:"sent-control-packets"` - PacketsReceived string `xml:"packets-received"` - ReceivedAcks string `xml:"received-acks"` - AcksBytes string `xml:"acks-bytes"` - ReceivedDuplicateAcks string `xml:"received-duplicate-acks"` - ReceivedAcksForUnsentData string `xml:"received-acks-for-unsent-data"` - PacketsReceivedInSequence string `xml:"packets-received-in-sequence"` - InSequenceBytes string `xml:"in-sequence-bytes"` - ReceivedCompletelyDuplicatePacket string `xml:"received-completely-duplicate-packet"` - DuplicateInBytes string `xml:"duplicate-in-bytes"` - ReceivedOldDuplicatePackets string `xml:"received-old-duplicate-packets"` - ReceivedPacketsWithSomeDupliacteData string `xml:"received-packets-with-some-dupliacte-data"` - SomeDuplicateInBytes string `xml:"some-duplicate-in-bytes"` - ReceivedOutOfOrderPackets string `xml:"received-out-of-order-packets"` - OutOfOrderInBytes string `xml:"out-of-order-in-bytes"` - ReceivedPacketsOfDataAfterWindow string `xml:"received-packets-of-data-after-window"` - Bytes string `xml:"bytes"` - ReceivedWindowProbes string `xml:"received-window-probes"` - ReceivedWindowUpdatePackets string `xml:"received-window-update-packets"` - PacketsReceivedAfterClose string `xml:"packets-received-after-close"` - ReceivedDiscardedForBadChecksum string `xml:"received-discarded-for-bad-checksum"` - ReceivedDiscardedForBadHeaderOffset string `xml:"received-discarded-for-bad-header-offset"` - ReceivedDiscardedBecausePacketTooShort string `xml:"received-discarded-because-packet-too-short"` - ConnectionRequests string `xml:"connection-requests"` - ConnectionAccepts string `xml:"connection-accepts"` - BadConnectionAttempts string `xml:"bad-connection-attempts"` - ListenQueueOverflows string `xml:"listen-queue-overflows"` - BadRstWindow string `xml:"bad-rst-window"` - ConnectionsEstablished string `xml:"connections-established"` - ConnectionsClosed string `xml:"connections-closed"` - Drops string `xml:"drops"` - ConnectionsUpdatedRttOnClose string `xml:"connections-updated-rtt-on-close"` - ConnectionsUpdatedVarianceOnClose string `xml:"connections-updated-variance-on-close"` - ConnectionsUpdatedSsthreshOnClose string `xml:"connections-updated-ssthresh-on-close"` - EmbryonicConnectionsDropped string `xml:"embryonic-connections-dropped"` - SegmentsUpdatedRtt string `xml:"segments-updated-rtt"` - Attempts string `xml:"attempts"` - RetransmitTimeouts string `xml:"retransmit-timeouts"` - ConnectionsDroppedByRetransmitTimeout string `xml:"connections-dropped-by-retransmit-timeout"` - PersistTimeouts string `xml:"persist-timeouts"` - ConnectionsDroppedByPersistTimeout string `xml:"connections-dropped-by-persist-timeout"` - KeepaliveTimeouts string `xml:"keepalive-timeouts"` - KeepaliveProbesSent string `xml:"keepalive-probes-sent"` - KeepaliveConnectionsDropped string `xml:"keepalive-connections-dropped"` - AckHeaderPredictions string `xml:"ack-header-predictions"` - DataPacketHeaderPredictions string `xml:"data-packet-header-predictions"` - SyncacheEntriesAdded string `xml:"syncache-entries-added"` - Retransmitted string `xml:"retransmitted"` - Dupsyn string `xml:"dupsyn"` - Dropped string `xml:"dropped"` - Completed string `xml:"completed"` - BucketOverflow string `xml:"bucket-overflow"` - CacheOverflow string `xml:"cache-overflow"` - Reset string `xml:"reset"` - Stale string `xml:"stale"` - Aborted string `xml:"aborted"` - Badack string `xml:"badack"` - Unreach string `xml:"unreach"` - ZoneFailures string `xml:"zone-failures"` - CookiesSent string `xml:"cookies-sent"` - CookiesReceived string `xml:"cookies-received"` - SackRecoveryEpisodes string `xml:"sack-recovery-episodes"` - SegmentRetransmits string `xml:"segment-retransmits"` - ByteRetransmits string `xml:"byte-retransmits"` - SackOptionsReceived string `xml:"sack-options-received"` - SackOpitionsSent string `xml:"sack-opitions-sent"` - SackScoreboardOverflow string `xml:"sack-scoreboard-overflow"` - AcksSentInResponseButNotExactRsts string `xml:"acks-sent-in-response-but-not-exact-rsts"` - AcksSentInResponseToSynsOnEstablishedConnections string `xml:"acks-sent-in-response-to-syns-on-established-connections"` - RcvPacketsDroppedDueToBadAddress string `xml:"rcv-packets-dropped-due-to-bad-address"` - OutOfSequenceSegmentDrops string `xml:"out-of-sequence-segment-drops"` - RstPackets string `xml:"rst-packets"` - IcmpPacketsIgnored string `xml:"icmp-packets-ignored"` - SendPacketsDropped string `xml:"send-packets-dropped"` - RcvPacketsDropped string `xml:"rcv-packets-dropped"` - OutgoingSegmentsDropped string `xml:"outgoing-segments-dropped"` - ReceivedSynfinDropped string `xml:"received-synfin-dropped"` - ReceivedIpsecDropped string `xml:"received-ipsec-dropped"` - ReceivedMacDropped string `xml:"received-mac-dropped"` - ReceivedMinttlExceeded string `xml:"received-minttl-exceeded"` - ListenstateBadflagsDropped string `xml:"listenstate-badflags-dropped"` - FinwaitstateBadflagsDropped string `xml:"finwaitstate-badflags-dropped"` - ReceivedDosAttack string `xml:"received-dos-attack"` - ReceivedBadSynack string `xml:"received-bad-synack"` - SyncacheZoneFull string `xml:"syncache-zone-full"` - ReceivedRstFirewallfilter string `xml:"received-rst-firewallfilter"` - ReceivedNoackTimewait string `xml:"received-noack-timewait"` - ReceivedNoTimewaitState string `xml:"received-no-timewait-state"` - ReceivedRstTimewaitState string `xml:"received-rst-timewait-state"` - ReceivedTimewaitDrops string `xml:"received-timewait-drops"` - ReceivedBadaddrTimewaitState string `xml:"received-badaddr-timewait-state"` - ReceivedAckoffInSynSentrcvd string `xml:"received-ackoff-in-syn-sentrcvd"` - ReceivedBadaddrFirewall string `xml:"received-badaddr-firewall"` - ReceivedNosynSynSent string `xml:"received-nosyn-syn-sent"` - ReceivedBadrstSynSent string `xml:"received-badrst-syn-sent"` - ReceivedBadrstListenState string `xml:"received-badrst-listen-state"` - OptionMaxsegmentLength string `xml:"option-maxsegment-length"` - OptionWindowLength string `xml:"option-window-length"` - OptionTimestampLength string `xml:"option-timestamp-length"` - OptionMd5Length string `xml:"option-md5-length"` - OptionAuthLength string `xml:"option-auth-length"` - OptionSackpermittedLength string `xml:"option-sackpermitted-length"` - OptionSackLength string `xml:"option-sack-length"` - OptionAuthoptionLength string `xml:"option-authoption-length"` + SentDataPackets float64 `xml:"sent-data-packets"` + DataPacketsBytes float64 `xml:"data-packets-bytes"` + SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` + RetransmittedBytes float64 `xml:"retransmitted-bytes"` + SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` + SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` + SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` + SentPacketsDelayed float64 `xml:"sent-packets-delayed"` + SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` + SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` + SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` + SentControlPackets float64 `xml:"sent-control-packets"` + PacketsReceived float64 `xml:"packets-received"` + ReceivedAcks float64 `xml:"received-acks"` + AcksBytes float64 `xml:"acks-bytes"` + ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` + ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` + PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` + InSequenceBytes float64 `xml:"in-sequence-bytes"` + ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` + DuplicateInBytes float64 `xml:"duplicate-in-bytes"` + ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` + ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` + SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` + ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` + OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` + ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` + Bytes float64 `xml:"bytes"` + ReceivedWindowProbes float64 `xml:"received-window-probes"` + ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` + PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` + ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` + ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` + ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` + ConnectionRequests float64 `xml:"connection-requests"` + ConnectionAccepts float64 `xml:"connection-accepts"` + BadConnectionAttempts float64 `xml:"bad-connection-attempts"` + ListenQueueOverflows float64 `xml:"listen-queue-overflows"` + BadRstWindow float64 `xml:"bad-rst-window"` + ConnectionsEstablished float64 `xml:"connections-established"` + ConnectionsClosed float64 `xml:"connections-closed"` + Drops float64 `xml:"drops"` + ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` + ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` + ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` + EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` + SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` + Attempts float64 `xml:"attempts"` + RetransmitTimeouts float64 `xml:"retransmit-timeouts"` + ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` + PersistTimeouts float64 `xml:"persist-timeouts"` + ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` + KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` + KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` + KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` + AckHeaderPredictions float64 `xml:"ack-header-predictions"` + DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` + SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` + Retransmitted float64 `xml:"retransmitted"` + Dupsyn float64 `xml:"dupsyn"` + Dropped float64 `xml:"dropped"` + Completed float64 `xml:"completed"` + BucketOverflow float64 `xml:"bucket-overflow"` + CacheOverflow float64 `xml:"cache-overflow"` + Reset float64 `xml:"reset"` + Stale float64 `xml:"stale"` + Aborted float64 `xml:"aborted"` + Badack float64 `xml:"badack"` + Unreach float64 `xml:"unreach"` + ZoneFailures float64 `xml:"zone-failures"` + CookiesSent float64 `xml:"cookies-sent"` + CookiesReceived float64 `xml:"cookies-received"` + SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` + SegmentRetransmits float64 `xml:"segment-retransmits"` + ByteRetransmits float64 `xml:"byte-retransmits"` + SackOptionsReceived float64 `xml:"sack-options-received"` + SackOpitionsSent float64 `xml:"sack-opitions-sent"` + SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` + AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` + AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` + RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` + OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` + RstPackets float64 `xml:"rst-packets"` + IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` + SendPacketsDropped float64 `xml:"send-packets-dropped"` + RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` + OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` + ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` + ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` + ReceivedMacDropped float64 `xml:"received-mac-dropped"` + ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` + ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` + FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` + ReceivedDosAttack float64 `xml:"received-dos-attack"` + ReceivedBadSynack float64 `xml:"received-bad-synack"` + SyncacheZoneFull float64 `xml:"syncache-zone-full"` + ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` + ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` + ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` + ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` + ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` + ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` + ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` + ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` + ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` + ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` + ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` + OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` + OptionWindowLength float64 `xml:"option-window-length"` + OptionTimestampLength float64 `xml:"option-timestamp-length"` + OptionMd5Length float64 `xml:"option-md5-length"` + OptionAuthLength float64 `xml:"option-auth-length"` + OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` + OptionSackLength float64 `xml:"option-sack-length"` + OptionAuthoptionLength float64 `xml:"option-authoption-length"` } `xml:"tcp"` Udp struct { Text string `xml:",chardata"` - DatagramsReceived string `xml:"datagrams-received"` - DatagramsWithIncompleteHeader string `xml:"datagrams-with-incomplete-header"` - DatagramsWithBadDatalengthField string `xml:"datagrams-with-bad-datalength-field"` - DatagramsWithBadChecksum string `xml:"datagrams-with-bad-checksum"` - DatagramsDroppedDueToNoSocket string `xml:"datagrams-dropped-due-to-no-socket"` - BroadcastOrMulticastDatagramsDroppedDueToNoSocket string `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` - DatagramsDroppedDueToFullSocketBuffers string `xml:"datagrams-dropped-due-to-full-socket-buffers"` - DatagramsNotForHashedPcb string `xml:"datagrams-not-for-hashed-pcb"` - DatagramsDelivered string `xml:"datagrams-delivered"` - DatagramsOutput string `xml:"datagrams-output"` + DatagramsReceived float64 `xml:"datagrams-received"` + DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` + DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` + DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` + DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` + BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` + DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` + DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` + DatagramsDelivered float64 `xml:"datagrams-delivered"` + DatagramsOutput float64 `xml:"datagrams-output"` } `xml:"udp"` Ip struct { Text string `xml:",chardata"` diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go new file mode 100644 index 00000000..7c3d930d --- /dev/null +++ b/pkg/features/systemstatistics/rpc_test.go @@ -0,0 +1,1305 @@ +package systemstatistics + +import ( + "encoding/xml" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestStatisticsIPv4Unmarshaling(t *testing.T) { + tests := []struct { + name string + xmlInput string + expected SystemStatistics + }{ + { + name: "complete_ipv4_statistics", + xmlInput: ` + + + 1000 + 5 + 10 + 2 + 3 + 1 + 0 + 0 + 50 + 2 + 1 + 0 + 48 + 500 + 5 + 400 + 10 + 2 + 800 + 0 + 3 + 1 + 20 + 40 + 2 + 1 + 15 + 0 + 2 + 5 + 3 + 1 + 0 + 0 + 4 + 8 + 12 + 0 + 25 + 100 + 2 + 95 + 1 + 3 + 200 + + + + user@router> + + `, + expected: SystemStatistics{ + Statistics: struct { + Text string `xml:",chardata"` + Tcp struct { + Text string `xml:",chardata"` + PacketsSent float64 `xml:"packets-sent"` + SentDataPackets float64 `xml:"sent-data-packets"` + DataPacketsBytes float64 `xml:"data-packets-bytes"` + SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` + RetransmittedBytes float64 `xml:"retransmitted-bytes"` + SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` + SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` + SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` + SentPacketsDelayed float64 `xml:"sent-packets-delayed"` + SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` + SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` + SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` + SentControlPackets float64 `xml:"sent-control-packets"` + PacketsReceived float64 `xml:"packets-received"` + ReceivedAcks float64 `xml:"received-acks"` + AcksBytes float64 `xml:"acks-bytes"` + ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` + ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` + PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` + InSequenceBytes float64 `xml:"in-sequence-bytes"` + ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` + DuplicateInBytes float64 `xml:"duplicate-in-bytes"` + ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` + ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` + SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` + ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` + OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` + ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` + Bytes float64 `xml:"bytes"` + ReceivedWindowProbes float64 `xml:"received-window-probes"` + ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` + PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` + ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` + ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` + ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` + ConnectionRequests float64 `xml:"connection-requests"` + ConnectionAccepts float64 `xml:"connection-accepts"` + BadConnectionAttempts float64 `xml:"bad-connection-attempts"` + ListenQueueOverflows float64 `xml:"listen-queue-overflows"` + BadRstWindow float64 `xml:"bad-rst-window"` + ConnectionsEstablished float64 `xml:"connections-established"` + ConnectionsClosed float64 `xml:"connections-closed"` + Drops float64 `xml:"drops"` + ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` + ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` + ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` + EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` + SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` + Attempts float64 `xml:"attempts"` + RetransmitTimeouts float64 `xml:"retransmit-timeouts"` + ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` + PersistTimeouts float64 `xml:"persist-timeouts"` + ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` + KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` + KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` + KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` + AckHeaderPredictions float64 `xml:"ack-header-predictions"` + DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` + SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` + Retransmitted float64 `xml:"retransmitted"` + Dupsyn float64 `xml:"dupsyn"` + Dropped float64 `xml:"dropped"` + Completed float64 `xml:"completed"` + BucketOverflow float64 `xml:"bucket-overflow"` + CacheOverflow float64 `xml:"cache-overflow"` + Reset float64 `xml:"reset"` + Stale float64 `xml:"stale"` + Aborted float64 `xml:"aborted"` + Badack float64 `xml:"badack"` + Unreach float64 `xml:"unreach"` + ZoneFailures float64 `xml:"zone-failures"` + CookiesSent float64 `xml:"cookies-sent"` + CookiesReceived float64 `xml:"cookies-received"` + SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` + SegmentRetransmits float64 `xml:"segment-retransmits"` + ByteRetransmits float64 `xml:"byte-retransmits"` + SackOptionsReceived float64 `xml:"sack-options-received"` + SackOpitionsSent float64 `xml:"sack-opitions-sent"` + SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` + AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` + AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` + RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` + OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` + RstPackets float64 `xml:"rst-packets"` + IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` + SendPacketsDropped float64 `xml:"send-packets-dropped"` + RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` + OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` + ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` + ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` + ReceivedMacDropped float64 `xml:"received-mac-dropped"` + ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` + ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` + FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` + ReceivedDosAttack float64 `xml:"received-dos-attack"` + ReceivedBadSynack float64 `xml:"received-bad-synack"` + SyncacheZoneFull float64 `xml:"syncache-zone-full"` + ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` + ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` + ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` + ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` + ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` + ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` + ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` + ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` + ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` + ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` + ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` + OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` + OptionWindowLength float64 `xml:"option-window-length"` + OptionTimestampLength float64 `xml:"option-timestamp-length"` + OptionMd5Length float64 `xml:"option-md5-length"` + OptionAuthLength float64 `xml:"option-auth-length"` + OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` + OptionSackLength float64 `xml:"option-sack-length"` + OptionAuthoptionLength float64 `xml:"option-authoption-length"` + } `xml:"tcp"` + Udp struct { + Text string `xml:",chardata"` + DatagramsReceived float64 `xml:"datagrams-received"` + DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` + DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` + DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` + DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` + BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` + DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` + DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` + DatagramsDelivered float64 `xml:"datagrams-delivered"` + DatagramsOutput float64 `xml:"datagrams-output"` + } `xml:"udp"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + Icmp struct { + Text string `xml:",chardata"` + DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` + CallsToIcmpError string `xml:"calls-to-icmp-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` + Histogram []struct { + Text string `xml:",chardata"` + TypeOfHistogram string `xml:"type-of-histogram"` + IcmpEchoReply string `xml:"icmp-echo-reply"` + DestinationUnreachable string `xml:"destination-unreachable"` + IcmpEcho string `xml:"icmp-echo"` + TimeStampReply string `xml:"time-stamp-reply"` + TimeExceeded string `xml:"time-exceeded"` + TimeStamp string `xml:"time-stamp"` + AddressMaskRequest string `xml:"address-mask-request"` + AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` + } `xml:"histogram"` + MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` + MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` + MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` + MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` + MessagesWithBadLength string `xml:"messages-with-bad-length"` + EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` + TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` + MessageResponsesGenerated string `xml:"message-responses-generated"` + } `xml:"icmp"` + Arp struct { + Text string `xml:",chardata"` + DatagramsReceived string `xml:"datagrams-received"` + ArpRequestsReceived string `xml:"arp-requests-received"` + ArpRepliesReceived string `xml:"arp-replies-received"` + ResolutionRequestReceived string `xml:"resolution-request-received"` + ResolutionRequestDropped string `xml:"resolution-request-dropped"` + UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` + RestrictedProxyRequests string `xml:"restricted-proxy-requests"` + ReceivedProxyRequests string `xml:"received-proxy-requests"` + ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` + RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` + DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` + DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` + DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` + DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` + DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` + DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` + DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` + DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` + DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` + DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` + DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` + DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` + DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` + PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` + PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` + ArpRequestsSent string `xml:"arp-requests-sent"` + ArpRepliesSent string `xml:"arp-replies-sent"` + RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` + RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` + RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` + RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` + RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` + NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` + RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` + RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` + RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` + ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` + ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` + ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` + ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` + ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` + SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` + ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` + ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` + ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` + ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` + GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` + ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` + ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` + ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` + ArpSystemMax string `xml:"arp-system-max"` + ArpPublicMax string `xml:"arp-public-max"` + ArpIriMax string `xml:"arp-iri-max"` + ArpMgtMax string `xml:"arp-mgt-max"` + ArpPublicCnt string `xml:"arp-public-cnt"` + ArpIriCnt string `xml:"arp-iri-cnt"` + ArpMgtCnt string `xml:"arp-mgt-cnt"` + ArpSystemDrop string `xml:"arp-system-drop"` + ArpPublicDrop string `xml:"arp-public-drop"` + ArpIriDrop string `xml:"arp-iri-drop"` + ArpMgtDrop string `xml:"arp-mgt-drop"` + } `xml:"arp"` + Ip6 struct { + Text string `xml:",chardata"` + TotalPacketsReceived float64 `xml:"total-packets-received"` + Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` + PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` + Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` + Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` + Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` + DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` + Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` + FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` + Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` + Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` + Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` + Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` + Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` + Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` + Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` + Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` + Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` + Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` + Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` + Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` + PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` + MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` + Histogram float64 `xml:"histogram"` + Ip6nhTcp float64 `xml:"ip6nh-tcp"` + Ip6nhUdp float64 `xml:"ip6nh-udp"` + Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` + PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` + TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` + PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` + FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` + HeaderType []struct { + Text string `xml:",chardata"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + LinkLocals float64 `xml:"link-locals"` + Globals float64 `xml:"globals"` + AddressScope float64 `xml:"address-scope"` + HexValue float64 `xml:"hex-value"` + } `xml:"header-type"` + ForwardCacheHit float64 `xml:"forward-cache-hit"` + ForwardCacheMiss float64 `xml:"forward-cache-miss"` + Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` + Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` + Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` + PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` + TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` + PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` + } `xml:"ip6"` + Icmp6 struct { + Text string `xml:",chardata"` + ProtocolName string `xml:"protocol-name"` + CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` + ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` + OutputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"output-histogram"` + Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` + MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` + BadChecksums string `xml:"bad-checksums"` + Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` + InputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"input-histogram"` + HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` + NoRoute string `xml:"no-route"` + AdministrativelyProhibited string `xml:"administratively-prohibited"` + BeyondScope string `xml:"beyond-scope"` + AddressUnreachable string `xml:"address-unreachable"` + PortUnreachable string `xml:"port-unreachable"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceedTransit string `xml:"time-exceed-transit"` + TimeExceedReassembly string `xml:"time-exceed-reassembly"` + ErroneousHeaderField string `xml:"erroneous-header-field"` + UnrecognizedNextHeader string `xml:"unrecognized-next-header"` + UnrecognizedOption string `xml:"unrecognized-option"` + Redirect string `xml:"redirect"` + Unknown string `xml:"unknown"` + Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` + MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` + NdSystemMax string `xml:"nd-system-max"` + NdPublicMax string `xml:"nd-public-max"` + NdIriMax string `xml:"nd-iri-max"` + NdMgtMax string `xml:"nd-mgt-max"` + NdPublicCnt string `xml:"nd-public-cnt"` + NdIriCnt string `xml:"nd-iri-cnt"` + NdMgtCnt string `xml:"nd-mgt-cnt"` + NdSystemDrop string `xml:"nd-system-drop"` + NdPublicDrop string `xml:"nd-public-drop"` + NdIriDrop string `xml:"nd-iri-drop"` + NdMgtDrop string `xml:"nd-mgt-drop"` + Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` + Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` + Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` + Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` + Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` + Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` + Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` + Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` + Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` + Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` + Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` + Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` + Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` + Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` + Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` + Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` + Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` + Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` + } `xml:"icmp6"` + Mpls struct { + Text string `xml:",chardata"` + TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` + PacketsForwarded string `xml:"packets-forwarded"` + PacketsDropped string `xml:"packets-dropped"` + PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` + AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` + PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` + PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` + PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` + LspPingPackets string `xml:"lsp-ping-packets"` + PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` + PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` + PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` + PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` + PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` + PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` + PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` + } `xml:"mpls"` + }{ + Ip: struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + }{ + PacketsReceived: 1000, + BadHeaderChecksums: 5, + PacketsWithSizeSmallerThanMinimum: 10, + PacketsWithDataSizeLessThanDatalength: 2, + PacketsWithHeaderLengthLessThanDataSize: 3, + PacketsWithDataLengthLessThanHeaderlength: 1, + PacketsWithIncorrectVersionNumber: 0, + PacketsDestinedToDeadNextHop: 0, + FragmentsReceived: 50, + FragmentsDroppedDueToOutofspaceOrDup: 2, + FragmentsDroppedDueToQueueoverflow: 1, + FragmentsDroppedAfterTimeout: 0, + PacketsReassembledOk: 48, + PacketsForThisHost: 500, + PacketsForUnknownOrUnsupportedProtocol: 5, + PacketsForwarded: 400, + PacketsNotForwardable: 10, + RedirectsSent: 2, + PacketsSentFromThisHost: 800, + PacketsSentWithFabricatedIpHeader: 0, + OutputPacketsDroppedDueToNoBufs: 3, + OutputPacketsDiscardedDueToNoRoute: 1, + OutputDatagramsFragmented: 20, + FragmentsCreated: 40, + DatagramsThatCanNotBeFragmented: 2, + PacketsWithBadOptions: 1, + PacketsWithOptionsHandledWithoutError: 15, + StrictSourceAndRecordRouteOptions: 0, + LooseSourceAndRecordRouteOptions: 2, + RecordRouteOptions: 5, + TimestampOptions: 3, + TimestampAndAddressOptions: 1, + TimestampAndPrespecifiedAddressOptions: 0, + OptionPacketsDroppedDueToRateLimit: 0, + RouterAlertOptions: 4, + MulticastPacketsDropped: 8, + PacketsDropped: 12, + TransitRePacketsDroppedOnMgmtInterface: 0, + PacketsUsedFirstNexthopInEcmpUnilist: 25, + IncomingTtpoipPacketsReceived: 100, + IncomingTtpoipPacketsDropped: 2, + OutgoingTtpoipPacketsSent: 95, + OutgoingTtpoipPacketsDropped: 1, + IncomingRawipPacketsDroppedNoSocketBuffer: 3, + IncomingVirtualNodePacketsDelivered: 200, + }, + }, + Cli: struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + }{ + Banner: "user@router>", + }, + }, + }, + { + name: "empty_ipv4_statistics", + xmlInput: ` + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + user@router> + + `, + expected: SystemStatistics{ + Cli: struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + }{ + Banner: "user@router>", + }, + }, + }, + { + name: "high_values_ipv4_statistics", + xmlInput: ` + + + 999999999 + 12345 + 54321 + 1111 + 2222 + 3333 + 4444 + 5555 + 888888 + 6666 + 7777 + 8888 + 777777 + 555555 + 9999 + 444444 + 11111 + 12121 + 666666 + 13131 + 14141 + 15151 + 16161 + 17171 + 18181 + 19191 + 20202 + 21212 + 22222 + 23232 + 24242 + 25252 + 26262 + 27272 + 28282 + 29292 + 30303 + 31313 + 32323 + 33333 + 34343 + 35353 + 36363 + 37373 + 38383 + + + + admin@high-traffic-router> + + `, + expected: SystemStatistics{ + Statistics: struct { + Text string `xml:",chardata"` + Tcp struct { + Text string `xml:",chardata"` + PacketsSent float64 `xml:"packets-sent"` + SentDataPackets float64 `xml:"sent-data-packets"` + DataPacketsBytes float64 `xml:"data-packets-bytes"` + SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` + RetransmittedBytes float64 `xml:"retransmitted-bytes"` + SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` + SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` + SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` + SentPacketsDelayed float64 `xml:"sent-packets-delayed"` + SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` + SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` + SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` + SentControlPackets float64 `xml:"sent-control-packets"` + PacketsReceived float64 `xml:"packets-received"` + ReceivedAcks float64 `xml:"received-acks"` + AcksBytes float64 `xml:"acks-bytes"` + ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` + ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` + PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` + InSequenceBytes float64 `xml:"in-sequence-bytes"` + ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` + DuplicateInBytes float64 `xml:"duplicate-in-bytes"` + ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` + ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` + SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` + ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` + OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` + ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` + Bytes float64 `xml:"bytes"` + ReceivedWindowProbes float64 `xml:"received-window-probes"` + ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` + PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` + ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` + ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` + ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` + ConnectionRequests float64 `xml:"connection-requests"` + ConnectionAccepts float64 `xml:"connection-accepts"` + BadConnectionAttempts float64 `xml:"bad-connection-attempts"` + ListenQueueOverflows float64 `xml:"listen-queue-overflows"` + BadRstWindow float64 `xml:"bad-rst-window"` + ConnectionsEstablished float64 `xml:"connections-established"` + ConnectionsClosed float64 `xml:"connections-closed"` + Drops float64 `xml:"drops"` + ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` + ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` + ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` + EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` + SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` + Attempts float64 `xml:"attempts"` + RetransmitTimeouts float64 `xml:"retransmit-timeouts"` + ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` + PersistTimeouts float64 `xml:"persist-timeouts"` + ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` + KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` + KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` + KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` + AckHeaderPredictions float64 `xml:"ack-header-predictions"` + DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` + SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` + Retransmitted float64 `xml:"retransmitted"` + Dupsyn float64 `xml:"dupsyn"` + Dropped float64 `xml:"dropped"` + Completed float64 `xml:"completed"` + BucketOverflow float64 `xml:"bucket-overflow"` + CacheOverflow float64 `xml:"cache-overflow"` + Reset float64 `xml:"reset"` + Stale float64 `xml:"stale"` + Aborted float64 `xml:"aborted"` + Badack float64 `xml:"badack"` + Unreach float64 `xml:"unreach"` + ZoneFailures float64 `xml:"zone-failures"` + CookiesSent float64 `xml:"cookies-sent"` + CookiesReceived float64 `xml:"cookies-received"` + SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` + SegmentRetransmits float64 `xml:"segment-retransmits"` + ByteRetransmits float64 `xml:"byte-retransmits"` + SackOptionsReceived float64 `xml:"sack-options-received"` + SackOpitionsSent float64 `xml:"sack-opitions-sent"` + SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` + AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` + AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` + RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` + OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` + RstPackets float64 `xml:"rst-packets"` + IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` + SendPacketsDropped float64 `xml:"send-packets-dropped"` + RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` + OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` + ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` + ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` + ReceivedMacDropped float64 `xml:"received-mac-dropped"` + ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` + ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` + FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` + ReceivedDosAttack float64 `xml:"received-dos-attack"` + ReceivedBadSynack float64 `xml:"received-bad-synack"` + SyncacheZoneFull float64 `xml:"syncache-zone-full"` + ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` + ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` + ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` + ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` + ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` + ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` + ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` + ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` + ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` + ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` + ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` + OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` + OptionWindowLength float64 `xml:"option-window-length"` + OptionTimestampLength float64 `xml:"option-timestamp-length"` + OptionMd5Length float64 `xml:"option-md5-length"` + OptionAuthLength float64 `xml:"option-auth-length"` + OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` + OptionSackLength float64 `xml:"option-sack-length"` + OptionAuthoptionLength float64 `xml:"option-authoption-length"` + } `xml:"tcp"` + Udp struct { + Text string `xml:",chardata"` + DatagramsReceived float64 `xml:"datagrams-received"` + DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` + DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` + DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` + DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` + BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` + DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` + DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` + DatagramsDelivered float64 `xml:"datagrams-delivered"` + DatagramsOutput float64 `xml:"datagrams-output"` + } `xml:"udp"` + Ip struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + } `xml:"ip"` + Icmp struct { + Text string `xml:",chardata"` + DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` + CallsToIcmpError string `xml:"calls-to-icmp-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` + Histogram []struct { + Text string `xml:",chardata"` + TypeOfHistogram string `xml:"type-of-histogram"` + IcmpEchoReply string `xml:"icmp-echo-reply"` + DestinationUnreachable string `xml:"destination-unreachable"` + IcmpEcho string `xml:"icmp-echo"` + TimeStampReply string `xml:"time-stamp-reply"` + TimeExceeded string `xml:"time-exceeded"` + TimeStamp string `xml:"time-stamp"` + AddressMaskRequest string `xml:"address-mask-request"` + AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` + } `xml:"histogram"` + MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` + MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` + MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` + MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` + MessagesWithBadLength string `xml:"messages-with-bad-length"` + EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` + TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` + MessageResponsesGenerated string `xml:"message-responses-generated"` + } `xml:"icmp"` + Arp struct { + Text string `xml:",chardata"` + DatagramsReceived string `xml:"datagrams-received"` + ArpRequestsReceived string `xml:"arp-requests-received"` + ArpRepliesReceived string `xml:"arp-replies-received"` + ResolutionRequestReceived string `xml:"resolution-request-received"` + ResolutionRequestDropped string `xml:"resolution-request-dropped"` + UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` + RestrictedProxyRequests string `xml:"restricted-proxy-requests"` + ReceivedProxyRequests string `xml:"received-proxy-requests"` + ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` + RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` + DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` + DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` + DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` + DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` + DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` + DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` + DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` + DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` + DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` + DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` + DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` + DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` + DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` + PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` + PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` + ArpRequestsSent string `xml:"arp-requests-sent"` + ArpRepliesSent string `xml:"arp-replies-sent"` + RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` + RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` + RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` + RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` + RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` + NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` + RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` + RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` + RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` + ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` + ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` + ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` + ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` + ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` + SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` + ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` + ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` + ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` + ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` + GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` + ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` + ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` + ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` + ArpSystemMax string `xml:"arp-system-max"` + ArpPublicMax string `xml:"arp-public-max"` + ArpIriMax string `xml:"arp-iri-max"` + ArpMgtMax string `xml:"arp-mgt-max"` + ArpPublicCnt string `xml:"arp-public-cnt"` + ArpIriCnt string `xml:"arp-iri-cnt"` + ArpMgtCnt string `xml:"arp-mgt-cnt"` + ArpSystemDrop string `xml:"arp-system-drop"` + ArpPublicDrop string `xml:"arp-public-drop"` + ArpIriDrop string `xml:"arp-iri-drop"` + ArpMgtDrop string `xml:"arp-mgt-drop"` + } `xml:"arp"` + Ip6 struct { + Text string `xml:",chardata"` + TotalPacketsReceived float64 `xml:"total-packets-received"` + Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` + PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` + Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` + Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` + Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` + DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` + Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` + FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` + Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` + Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` + Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` + Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` + Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` + Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` + Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` + Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` + Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` + Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` + Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` + Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` + PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` + MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` + Histogram float64 `xml:"histogram"` + Ip6nhTcp float64 `xml:"ip6nh-tcp"` + Ip6nhUdp float64 `xml:"ip6nh-udp"` + Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` + PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` + TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` + PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` + FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` + HeaderType []struct { + Text string `xml:",chardata"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + LinkLocals float64 `xml:"link-locals"` + Globals float64 `xml:"globals"` + AddressScope float64 `xml:"address-scope"` + HexValue float64 `xml:"hex-value"` + } `xml:"header-type"` + ForwardCacheHit float64 `xml:"forward-cache-hit"` + ForwardCacheMiss float64 `xml:"forward-cache-miss"` + Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` + Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` + Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` + PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` + TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` + PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` + } `xml:"ip6"` + Icmp6 struct { + Text string `xml:",chardata"` + ProtocolName string `xml:"protocol-name"` + CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` + ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` + OutputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"output-histogram"` + Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` + MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` + BadChecksums string `xml:"bad-checksums"` + Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` + InputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"input-histogram"` + HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` + NoRoute string `xml:"no-route"` + AdministrativelyProhibited string `xml:"administratively-prohibited"` + BeyondScope string `xml:"beyond-scope"` + AddressUnreachable string `xml:"address-unreachable"` + PortUnreachable string `xml:"port-unreachable"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceedTransit string `xml:"time-exceed-transit"` + TimeExceedReassembly string `xml:"time-exceed-reassembly"` + ErroneousHeaderField string `xml:"erroneous-header-field"` + UnrecognizedNextHeader string `xml:"unrecognized-next-header"` + UnrecognizedOption string `xml:"unrecognized-option"` + Redirect string `xml:"redirect"` + Unknown string `xml:"unknown"` + Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` + MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` + NdSystemMax string `xml:"nd-system-max"` + NdPublicMax string `xml:"nd-public-max"` + NdIriMax string `xml:"nd-iri-max"` + NdMgtMax string `xml:"nd-mgt-max"` + NdPublicCnt string `xml:"nd-public-cnt"` + NdIriCnt string `xml:"nd-iri-cnt"` + NdMgtCnt string `xml:"nd-mgt-cnt"` + NdSystemDrop string `xml:"nd-system-drop"` + NdPublicDrop string `xml:"nd-public-drop"` + NdIriDrop string `xml:"nd-iri-drop"` + NdMgtDrop string `xml:"nd-mgt-drop"` + Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` + Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` + Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` + Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` + Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` + Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` + Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` + Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` + Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` + Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` + Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` + Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` + Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` + Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` + Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` + Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` + Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` + Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` + } `xml:"icmp6"` + Mpls struct { + Text string `xml:",chardata"` + TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` + PacketsForwarded string `xml:"packets-forwarded"` + PacketsDropped string `xml:"packets-dropped"` + PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` + AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` + PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` + PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` + PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` + LspPingPackets string `xml:"lsp-ping-packets"` + PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` + PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` + PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` + PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` + PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` + PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` + PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` + } `xml:"mpls"` + }{ + Ip: struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` + }{ + PacketsReceived: 999999999, + BadHeaderChecksums: 12345, + PacketsWithSizeSmallerThanMinimum: 54321, + PacketsWithDataSizeLessThanDatalength: 1111, + PacketsWithHeaderLengthLessThanDataSize: 2222, + PacketsWithDataLengthLessThanHeaderlength: 3333, + PacketsWithIncorrectVersionNumber: 4444, + PacketsDestinedToDeadNextHop: 5555, + FragmentsReceived: 888888, + FragmentsDroppedDueToOutofspaceOrDup: 6666, + FragmentsDroppedDueToQueueoverflow: 7777, + FragmentsDroppedAfterTimeout: 8888, + PacketsReassembledOk: 777777, + PacketsForThisHost: 555555, + PacketsForUnknownOrUnsupportedProtocol: 9999, + PacketsForwarded: 444444, + PacketsNotForwardable: 11111, + RedirectsSent: 12121, + PacketsSentFromThisHost: 666666, + PacketsSentWithFabricatedIpHeader: 13131, + OutputPacketsDroppedDueToNoBufs: 14141, + OutputPacketsDiscardedDueToNoRoute: 15151, + OutputDatagramsFragmented: 16161, + FragmentsCreated: 17171, + DatagramsThatCanNotBeFragmented: 18181, + PacketsWithBadOptions: 19191, + PacketsWithOptionsHandledWithoutError: 20202, + StrictSourceAndRecordRouteOptions: 21212, + LooseSourceAndRecordRouteOptions: 22222, + RecordRouteOptions: 23232, + TimestampOptions: 24242, + TimestampAndAddressOptions: 25252, + TimestampAndPrespecifiedAddressOptions: 26262, + OptionPacketsDroppedDueToRateLimit: 27272, + RouterAlertOptions: 28282, + MulticastPacketsDropped: 29292, + PacketsDropped: 30303, + TransitRePacketsDroppedOnMgmtInterface: 31313, + PacketsUsedFirstNexthopInEcmpUnilist: 32323, + IncomingTtpoipPacketsReceived: 33333, + IncomingTtpoipPacketsDropped: 34343, + OutgoingTtpoipPacketsSent: 35353, + OutgoingTtpoipPacketsDropped: 36363, + IncomingRawipPacketsDroppedNoSocketBuffer: 37373, + IncomingVirtualNodePacketsDelivered: 38383, + }, + }, + Cli: struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + }{ + Banner: "admin@high-traffic-router>", + }, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var result SystemStatistics + err := xml.Unmarshal([]byte(tt.xmlInput), &result) + assert.NoError(t, err, "unmarshal should not return error") + + // Test all IP struct fields + assert.Equal(t, tt.expected.Statistics.Ip.PacketsReceived, result.Statistics.Ip.PacketsReceived, "PacketsReceived should match") + assert.Equal(t, tt.expected.Statistics.Ip.BadHeaderChecksums, result.Statistics.Ip.BadHeaderChecksums, "BadHeaderChecksums should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, "PacketsWithSizeSmallerThanMinimum should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, result.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, "PacketsWithDataSizeLessThanDatalength should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, result.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, "PacketsWithHeaderLengthLessThanDataSize should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, result.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, "PacketsWithDataLengthLessThanHeaderlength should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithIncorrectVersionNumber, result.Statistics.Ip.PacketsWithIncorrectVersionNumber, "PacketsWithIncorrectVersionNumber should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsDestinedToDeadNextHop, result.Statistics.Ip.PacketsDestinedToDeadNextHop, "PacketsDestinedToDeadNextHop should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsReceived, result.Statistics.Ip.FragmentsReceived, "FragmentsReceived should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, result.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, "FragmentsDroppedDueToOutofspaceOrDup should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, result.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, "FragmentsDroppedDueToQueueoverflow should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedAfterTimeout, result.Statistics.Ip.FragmentsDroppedAfterTimeout, "FragmentsDroppedAfterTimeout should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsReassembledOk, result.Statistics.Ip.PacketsReassembledOk, "PacketsReassembledOk should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsForThisHost, result.Statistics.Ip.PacketsForThisHost, "PacketsForThisHost should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, result.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, "PacketsForUnknownOrUnsupportedProtocol should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsForwarded, result.Statistics.Ip.PacketsForwarded, "PacketsForwarded should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsNotForwardable, result.Statistics.Ip.PacketsNotForwardable, "PacketsNotForwardable should match") + assert.Equal(t, tt.expected.Statistics.Ip.RedirectsSent, result.Statistics.Ip.RedirectsSent, "RedirectsSent should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentFromThisHost, result.Statistics.Ip.PacketsSentFromThisHost, "PacketsSentFromThisHost should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentWithFabricatedIpHeader, result.Statistics.Ip.PacketsSentWithFabricatedIpHeader, "PacketsSentWithFabricatedIpHeader should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, result.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, "OutputPacketsDroppedDueToNoBufs should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, result.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, "OutputPacketsDiscardedDueToNoRoute should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutputDatagramsFragmented, result.Statistics.Ip.OutputDatagramsFragmented, "OutputDatagramsFragmented should match") + assert.Equal(t, tt.expected.Statistics.Ip.FragmentsCreated, result.Statistics.Ip.FragmentsCreated, "FragmentsCreated should match") + assert.Equal(t, tt.expected.Statistics.Ip.DatagramsThatCanNotBeFragmented, result.Statistics.Ip.DatagramsThatCanNotBeFragmented, "DatagramsThatCanNotBeFragmented should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithBadOptions, result.Statistics.Ip.PacketsWithBadOptions, "PacketsWithBadOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithOptionsHandledWithoutError, result.Statistics.Ip.PacketsWithOptionsHandledWithoutError, "PacketsWithOptionsHandledWithoutError should match") + assert.Equal(t, tt.expected.Statistics.Ip.StrictSourceAndRecordRouteOptions, result.Statistics.Ip.StrictSourceAndRecordRouteOptions, "StrictSourceAndRecordRouteOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.LooseSourceAndRecordRouteOptions, result.Statistics.Ip.LooseSourceAndRecordRouteOptions, "LooseSourceAndRecordRouteOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.RecordRouteOptions, result.Statistics.Ip.RecordRouteOptions, "RecordRouteOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.TimestampOptions, result.Statistics.Ip.TimestampOptions, "TimestampOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndAddressOptions, result.Statistics.Ip.TimestampAndAddressOptions, "TimestampAndAddressOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, result.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, "TimestampAndPrespecifiedAddressOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, result.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, "OptionPacketsDroppedDueToRateLimit should match") + assert.Equal(t, tt.expected.Statistics.Ip.RouterAlertOptions, result.Statistics.Ip.RouterAlertOptions, "RouterAlertOptions should match") + assert.Equal(t, tt.expected.Statistics.Ip.MulticastPacketsDropped, result.Statistics.Ip.MulticastPacketsDropped, "MulticastPacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsDropped, result.Statistics.Ip.PacketsDropped, "PacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, result.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, "TransitRePacketsDroppedOnMgmtInterface should match") + assert.Equal(t, tt.expected.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, result.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, "PacketsUsedFirstNexthopInEcmpUnilist should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived, result.Statistics.Ip.IncomingTtpoipPacketsReceived, "IncomingTtpoipPacketsReceived should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsDropped, result.Statistics.Ip.IncomingTtpoipPacketsDropped, "IncomingTtpoipPacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsSent, result.Statistics.Ip.OutgoingTtpoipPacketsSent, "OutgoingTtpoipPacketsSent should match") + assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsDropped, result.Statistics.Ip.OutgoingTtpoipPacketsDropped, "OutgoingTtpoipPacketsDropped should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, result.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, "IncomingRawipPacketsDroppedNoSocketBuffer should match") + assert.Equal(t, tt.expected.Statistics.Ip.IncomingVirtualNodePacketsDelivered, result.Statistics.Ip.IncomingVirtualNodePacketsDelivered, "IncomingVirtualNodePacketsDelivered should match") + }) + } +} \ No newline at end of file From 46d82910feada51655665fb4028b9d717535200b Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 28 Aug 2025 15:54:34 +0200 Subject: [PATCH 10/27] added tcp --- pkg/features/systemstatistics/collector.go | 475 ++++++++++++++++++++- 1 file changed, 474 insertions(+), 1 deletion(-) diff --git a/pkg/features/systemstatistics/collector.go b/pkg/features/systemstatistics/collector.go index e959b449..393b58f4 100644 --- a/pkg/features/systemstatistics/collector.go +++ b/pkg/features/systemstatistics/collector.go @@ -105,6 +105,123 @@ var ( udpDatagramsNotForHashedPcbDesc *prometheus.Desc udpDatagramsDeliveredDesc *prometheus.Desc udpDatagramsOutputDesc *prometheus.Desc + + tcpPacketsSent *prometheus.Desc + tcpSentDataPackets *prometheus.Desc + tcpDataPacketsBytes *prometheus.Desc + tcpSentDataPacketsRetransmitted *prometheus.Desc + tcpRetransmittedBytes *prometheus.Desc + tcpSentDataUnnecessaryRetransmitted *prometheus.Desc + tcpSentResendsByMtuDiscovery *prometheus.Desc + tcpSentAckOnlyPackets *prometheus.Desc + tcpSentPacketsDelayed *prometheus.Desc + tcpSentUrgOnlyPackets *prometheus.Desc + tcpSentWindowProbePackets *prometheus.Desc + tcpSentWindowUpdatePackets *prometheus.Desc + tcpSentControlPackets *prometheus.Desc + tcpPacketsReceived *prometheus.Desc + tcpReceivedAcks *prometheus.Desc + tcpAcksBytes *prometheus.Desc + tcpReceivedDuplicateAcks *prometheus.Desc + tcpReceivedAcksForUnsentData *prometheus.Desc + tcpPacketsReceivedInSequence *prometheus.Desc + tcpInSequenceBytes *prometheus.Desc + tcpReceivedCompletelyDuplicatePacket *prometheus.Desc + tcpDuplicateInBytes *prometheus.Desc + tcpReceivedOldDuplicatePackets *prometheus.Desc + tcpReceivedPacketsWithSomeDupliacteData *prometheus.Desc + tcpSomeDuplicateInBytes *prometheus.Desc + tcpReceivedOutOfOrderPackets *prometheus.Desc + tcpOutOfOrderInBytes *prometheus.Desc + tcpReceivedPacketsOfDataAfterWindow *prometheus.Desc + tcpBytes *prometheus.Desc + tcpReceivedWindowProbes *prometheus.Desc + tcpReceivedWindowUpdatePackets *prometheus.Desc + tcpPacketsReceivedAfterClose *prometheus.Desc + tcpReceivedDiscardedForBadChecksum *prometheus.Desc + tcpReceivedDiscardedForBadHeaderOffset *prometheus.Desc + tcpReceivedDiscardedBecausePacketTooShort *prometheus.Desc + tcpConnectionRequests *prometheus.Desc + tcpConnectionAccepts *prometheus.Desc + tcpBadConnectionAttempts *prometheus.Desc + tcpListenQueueOverflows *prometheus.Desc + tcpBadRstWindow *prometheus.Desc + tcpConnectionsEstablished *prometheus.Desc + tcpConnectionsClosed *prometheus.Desc + tcpDrops *prometheus.Desc + tcpConnectionsUpdatedRttOnClose *prometheus.Desc + tcpConnectionsUpdatedVarianceOnClose *prometheus.Desc + tcpConnectionsUpdatedSsthreshOnClose *prometheus.Desc + tcpEmbryonicConnectionsDropped *prometheus.Desc + tcpSegmentsUpdatedRtt *prometheus.Desc + tcpAttempts *prometheus.Desc + tcpRetransmitTimeouts *prometheus.Desc + tcpConnectionsDroppedByRetransmitTimeout *prometheus.Desc + tcpPersistTimeouts *prometheus.Desc + tcpConnectionsDroppedByPersistTimeout *prometheus.Desc + tcpKeepaliveTimeouts *prometheus.Desc + tcpKeepaliveProbesSent *prometheus.Desc + tcpKeepaliveConnectionsDropped *prometheus.Desc + tcpAckHeaderPredictions *prometheus.Desc + tcpDataPacketHeaderPredictions *prometheus.Desc + tcpSyncacheEntriesAdded *prometheus.Desc + tcpRetransmitted *prometheus.Desc + tcpDupsyn *prometheus.Desc + tcpDropped *prometheus.Desc + tcpCompleted *prometheus.Desc + tcpBucketOverflow *prometheus.Desc + tcpCacheOverflow *prometheus.Desc + tcpReset *prometheus.Desc + tcpStale *prometheus.Desc + tcpAborted *prometheus.Desc + tcpBadack *prometheus.Desc + tcpUnreach *prometheus.Desc + tcpZoneFailures *prometheus.Desc + tcpCookiesSent *prometheus.Desc + tcpCookiesReceived *prometheus.Desc + tcpSackRecoveryEpisodes *prometheus.Desc + tcpSegmentRetransmits *prometheus.Desc + tcpByteRetransmits *prometheus.Desc + tcpSackOptionsReceived *prometheus.Desc + tcpSackOptionsSent *prometheus.Desc + tcpSackScoreboardOverflow *prometheus.Desc + tcpAcksSentInResponseButNotExactRsts *prometheus.Desc + tcpAcksSentInResponseToSynsOnEstablishedConnections *prometheus.Desc + tcpRcvPacketsDroppedDueToBadAddress *prometheus.Desc + tcpOutOfSequenceSegmentDrops *prometheus.Desc + tcpRstPackets *prometheus.Desc + tcpIcmpPacketsIgnored *prometheus.Desc + tcpSendPacketsDropped *prometheus.Desc + tcpRcvPacketsDropped *prometheus.Desc + tcpOutgoingSegmentsDropped *prometheus.Desc + tcpReceivedSynfinDropped *prometheus.Desc + tcpReceivedIpsecDropped *prometheus.Desc + tcpReceivedMacDropped *prometheus.Desc + tcpReceivedMinttlExceeded *prometheus.Desc + tcpListenstateBadflagsDropped *prometheus.Desc + tcpFinwaitstateBadflagsDropped *prometheus.Desc + tcpReceivedDosAttack *prometheus.Desc + tcpReceivedBadSynack *prometheus.Desc + tcpSyncacheZoneFull *prometheus.Desc + tcpReceivedRstFirewallfilter *prometheus.Desc + tcpReceivedNoackTimewait *prometheus.Desc + tcpReceivedNoTimewaitState *prometheus.Desc + tcpReceivedRstTimewaitState *prometheus.Desc + tcpReceivedTimewaitDrops *prometheus.Desc + tcpReceivedBadaddrTimewaitState *prometheus.Desc + tcpReceivedAckoffInSynSentrcvd *prometheus.Desc + tcpReceivedBadaddrFirewall *prometheus.Desc + tcpReceivedNosynSynSent *prometheus.Desc + tcpReceivedBadrstSynSent *prometheus.Desc + tcpReceivedBadrstListenState *prometheus.Desc + tcpOptionMaxsegmentLength *prometheus.Desc + tcpOptionWindowLength *prometheus.Desc + tcpOptionTimestampLength *prometheus.Desc + tcpOptionMd5Length *prometheus.Desc + tcpOptionAuthLength *prometheus.Desc + tcpOptionSackpermittedLength *prometheus.Desc + tcpOptionSackLength *prometheus.Desc + tcpOptionAuthoptionLength *prometheus.Desc ) func init() { @@ -208,6 +325,125 @@ func init() { udpDatagramsNotForHashedPcbDesc = prometheus.NewDesc(prefix+"udp_datagrams_not_for_hashed_pcb", "Number of UDP datagrams not for hashed pcb", labelsUDP, nil) udpDatagramsDeliveredDesc = prometheus.NewDesc(prefix+"udp_datagrams_delivered", "Number of UDP datagrams delivered", labelsUDP, nil) udpDatagramsOutputDesc = prometheus.NewDesc(prefix+"udp_datagrams_output", "Number of UDP datagrams output", labelsUDP, nil) + + labelsTCP := []string{"target", "protocol"} + tcpPacketsSent = prometheus.NewDesc(prefix+"tcp_packets_sent", "Number of TCP packets sent", labelsTCP, nil) + tcpSentDataPackets = prometheus.NewDesc(prefix+"tcp_sent_data_packets", "Number of TCP sent data packets", labelsTCP, nil) + tcpDataPacketsBytes = prometheus.NewDesc(prefix+"tcp_data_packets_bytes", "Number of TCP data packets bytes", labelsTCP, nil) + tcpSentDataPacketsRetransmitted = prometheus.NewDesc(prefix+"tcp_sent_data_packets_retransmitted", "Number of TCP sent data packets retransmitted", labelsTCP, nil) + tcpRetransmittedBytes = prometheus.NewDesc(prefix+"tcp_retransmitted_bytes", "Number of TCP retransmitted bytes", labelsTCP, nil) + tcpSentDataUnnecessaryRetransmitted = prometheus.NewDesc(prefix+"tcp_sent_data_unnecessary_retransmitted", "Number of tcp data unnecessary retransmitted packets", labelsTCP, nil) + tcpSentResendsByMtuDiscovery = prometheus.NewDesc(prefix+"tcp_sent_resends_by_mtu_discovery", "Number of tcp sent resends by mtu discovery", labelsTCP, nil) + tcpSentAckOnlyPackets = prometheus.NewDesc(prefix+"tcp_sent_ack_only_packets", "Number of tcp sent ack only packets", labelsTCP, nil) + tcpSentPacketsDelayed = prometheus.NewDesc(prefix+"tcp_sent_packets_delayed", "Number of tcp sent packets delayed", labelsTCP, nil) + tcpSentUrgOnlyPackets = prometheus.NewDesc(prefix+"tcp_sent_urg_only_packets", "Number of tcp sent urg only packets", labelsTCP, nil) + tcpSentWindowProbePackets = prometheus.NewDesc(prefix+"tcp_sent_window_probe_packets", "Number of tcp sent window probe packets", labelsTCP, nil) + tcpSentWindowUpdatePackets = prometheus.NewDesc(prefix+"tcp_sent_window_update_packets", "Number of tcp sent window update packets", labelsTCP, nil) + tcpSentControlPackets = prometheus.NewDesc(prefix+"tcp_sent_control_packets", "Number of tcp sent control packets", labelsTCP, nil) + tcpPacketsReceived = prometheus.NewDesc(prefix+"tcp_packets_received", "Number of TCP packets received", labelsTCP, nil) + tcpReceivedAcks = prometheus.NewDesc(prefix+"tcp_received_acks", "Number of TCP received acks", labelsTCP, nil) + tcpAcksBytes = prometheus.NewDesc(prefix+"tcp_acks_bytes", "Number of TCP acks bytes", labelsTCP, nil) + tcpReceivedDuplicateAcks = prometheus.NewDesc(prefix+"tcp_received_duplicate_acks", "Number of TCP received duplicate acks", labelsTCP, nil) + tcpReceivedAcksForUnsentData = prometheus.NewDesc(prefix+"tcp_received_acks_for_unsent_data", "Number of TCP received acks for unsent data", labelsTCP, nil) + tcpPacketsReceivedInSequence = prometheus.NewDesc(prefix+"tcp_packets_received_in_sequence", "Number of TCP packets received in sequence", labelsTCP, nil) + tcpInSequenceBytes = prometheus.NewDesc(prefix+"tcp_in_sequence_bytes", "Number of TCP in sequence bytes", labelsTCP, nil) + tcpReceivedCompletelyDuplicatePacket = prometheus.NewDesc(prefix+"tcp_received_completely_duplicate_packet", "Number of TCP received completely duplicate packet", labelsTCP, nil) + tcpDuplicateInBytes = prometheus.NewDesc(prefix+"tcp_duplicate_in_bytes", "Number of TCP duplicate in bytes", labelsTCP, nil) + tcpReceivedOldDuplicatePackets = prometheus.NewDesc(prefix+"tcp_received_old_duplicate_packets", "Number of TCP received old duplicate packets", labelsTCP, nil) + tcpReceivedPacketsWithSomeDupliacteData = prometheus.NewDesc(prefix+"tcp_received_packet_with_some_duplicate_data", "Number of TCP received packet with some duplicate data", labelsTCP, nil) + tcpSomeDuplicateInBytes = prometheus.NewDesc(prefix+"tcp_some_duplicate_in_bytes", "Number of TCP some duplicate in bytes", labelsTCP, nil) + tcpReceivedOutOfOrderPackets = prometheus.NewDesc(prefix+"tcp_received_out_of_order_packets", "Number of TCP received out of order packets", labelsTCP, nil) + tcpOutOfOrderInBytes = prometheus.NewDesc(prefix+"tcp_out_of_order_in_bytes", "Number of TCP out of order in bytes", labelsTCP, nil) + tcpReceivedPacketsOfDataAfterWindow = prometheus.NewDesc(prefix+"tcp_received_packets_of_data_after_window", "Number of TCP received packets of data after window", labelsTCP, nil) + tcpBytes = prometheus.NewDesc(prefix+"tcp_bytes", "Number of TCP bytes", labelsTCP, nil) + tcpReceivedWindowProbes = prometheus.NewDesc(prefix+"tcp_received_window_probes", "Number of TCP received window probes", labelsTCP, nil) + tcpReceivedWindowUpdatePackets = prometheus.NewDesc(prefix+"tcp_received_window_update_packets", "Number of TCP received window update packets", labelsTCP, nil) + tcpPacketsReceivedAfterClose = prometheus.NewDesc(prefix+"tcp_packets_received_after_close", "Number of TCP packets received after close", labelsTCP, nil) + tcpReceivedDiscardedForBadChecksum = prometheus.NewDesc(prefix+"tcp_received_discarded_for_bad_checksum", "Number of TCP received discarded for bad checksum", labelsTCP, nil) + tcpReceivedDiscardedForBadHeaderOffset = prometheus.NewDesc(prefix+"tcp_received_discarded_for_bad_header_offset", "Number of TCP received discarded for bad header offset", labelsTCP, nil) + tcpReceivedDiscardedBecausePacketTooShort = prometheus.NewDesc(prefix+"tcp_received_discarded_because_packet_too_short", "Number of TCP received discarded because packet too short", labelsTCP, nil) + tcpConnectionRequests = prometheus.NewDesc(prefix+"tcp_connection_requests", "Number of TCP connection requests", labelsTCP, nil) + tcpConnectionAccepts = prometheus.NewDesc(prefix+"tcp_connection_accepts", "Number of TCP connection accepts", labelsTCP, nil) + tcpBadConnectionAttempts = prometheus.NewDesc(prefix+"tcp_bad_connection_attempts", "Number of TCP bad connection attempts", labelsTCP, nil) + tcpListenQueueOverflows = prometheus.NewDesc(prefix+"tcp_listen_queue_overflows", "Number of TCP listen queue overflows", labelsTCP, nil) + tcpBadRstWindow = prometheus.NewDesc(prefix+"tcp_bad_rst_window", "Number of TCP bad rst window", labelsTCP, nil) + tcpConnectionsEstablished = prometheus.NewDesc(prefix+"tcp_connections_established", "Number of TCP connections established", labelsTCP, nil) + tcpConnectionsClosed = prometheus.NewDesc(prefix+"tcp_connections_closed", "Number of TCP connections closed", labelsTCP, nil) + tcpDrops = prometheus.NewDesc(prefix+"tcp_drops", "Number of TCP drops", labelsTCP, nil) + tcpConnectionsUpdatedRttOnClose = prometheus.NewDesc(prefix+"tcp_connections_updated_rtt_on_close", "Number of TCP connections updated rtt on close", labelsTCP, nil) + tcpConnectionsUpdatedVarianceOnClose = prometheus.NewDesc(prefix+"tcp_connections_updated_variance_on_close", "Number of TCP connections updated variance on close", labelsTCP, nil) + tcpConnectionsUpdatedSsthreshOnClose = prometheus.NewDesc(prefix+"tcp_connections_updated_ssthresh_on_close", "Number of TCP connections updated ssthresh on close", labelsTCP, nil) + tcpEmbryonicConnectionsDropped = prometheus.NewDesc(prefix+"tcp_embryonic_connections_dropped", "Number of TCP embryonic connections dropped", labelsTCP, nil) + tcpSegmentsUpdatedRtt = prometheus.NewDesc(prefix+"tcp_segments_updated_rtt", "Number of TCP segments updated rtt", labelsTCP, nil) + tcpAttempts = prometheus.NewDesc(prefix+"tcp_attempts", "Number of TCP attempts", labelsTCP, nil) + tcpRetransmitTimeouts = prometheus.NewDesc(prefix+"tcp_retransmit_timeouts", "Number of TCP retransmit timeouts", labelsTCP, nil) + tcpConnectionsDroppedByRetransmitTimeout = prometheus.NewDesc(prefix+"tcp_connections_dropped_by_retransmit_timeout", "Number of TCP connections dropped by retransmit timeout", labelsTCP, nil) + tcpPersistTimeouts = prometheus.NewDesc(prefix+"tcp_persist_timeouts", "Number of TCP persist timeouts", labelsTCP, nil) + tcpConnectionsDroppedByPersistTimeout = prometheus.NewDesc(prefix+"tcp_connections_dropped_by_persist_timeout", "Number of TCP connections dropped by persist timeout", labelsTCP, nil) + tcpKeepaliveTimeouts = prometheus.NewDesc(prefix+"tcp_keepalive_timeouts", "Number of TCP keepalive timeouts", labelsTCP, nil) + tcpKeepaliveProbesSent = prometheus.NewDesc(prefix+"tcp_keepalive_probes_sent", "Number of TCP keepalive probes sent", labelsTCP, nil) + tcpKeepaliveConnectionsDropped = prometheus.NewDesc(prefix+"tcp_keepalive_connections_dropped", "Number of TCP keepalive connections dropped", labelsTCP, nil) + tcpAckHeaderPredictions = prometheus.NewDesc(prefix+"tcp_ack_header_predictions", "Number of TCP ack header predictions", labelsTCP, nil) + tcpDataPacketHeaderPredictions = prometheus.NewDesc(prefix+"tcp_data_packet_header_predictions", "Number of TCP data packet header predictions", labelsTCP, nil) + tcpSyncacheEntriesAdded = prometheus.NewDesc(prefix+"tcp_syncache_entries_added", "Number of TCP syncache entries added", labelsTCP, nil) + tcpRetransmitted = prometheus.NewDesc(prefix+"tcp_retransmitted", "Number of TCP retransmitted", labelsTCP, nil) + tcpDupsyn = prometheus.NewDesc(prefix+"tcp_dupsyn", "Number of TCP dupsyn", labelsTCP, nil) + tcpDropped = prometheus.NewDesc(prefix+"tcp_dropped", "Number of TCP dropped", labelsTCP, nil) + tcpCompleted = prometheus.NewDesc(prefix+"tcp_completed", "Number of TCP completed", labelsTCP, nil) + tcpBucketOverflow = prometheus.NewDesc(prefix+"tcp_bucket_overflow", "Number of TCP bucket overflow", labelsTCP, nil) + tcpCacheOverflow = prometheus.NewDesc(prefix+"tcp_cache_overflow", "Number of TCP cache overflow", labelsTCP, nil) + tcpReset = prometheus.NewDesc(prefix+"tcp_reset", "Number of TCP reset", labelsTCP, nil) + tcpStale = prometheus.NewDesc(prefix+"tcp_stale", "Number of TCP stale", labelsTCP, nil) + tcpAborted = prometheus.NewDesc(prefix+"tcp_aborted", "Number of TCP aborted", labelsTCP, nil) + tcpBadack = prometheus.NewDesc(prefix+"tcp_badack", "Number of TCP badack", labelsTCP, nil) + tcpUnreach = prometheus.NewDesc(prefix+"tcp_unreach", "Number of TCP unreach", labelsTCP, nil) + tcpZoneFailures = prometheus.NewDesc(prefix+"tcp_zone_failures", "Number of TCP zone failures", labelsTCP, nil) + tcpCookiesSent = prometheus.NewDesc(prefix+"tcp_cookies_sent", "Number of TCP cookies sent", labelsTCP, nil) + tcpCookiesReceived = prometheus.NewDesc(prefix+"tcp_cookies_received", "Number of TCP cookies received", labelsTCP, nil) + tcpSackRecoveryEpisodes = prometheus.NewDesc(prefix+"tcp_sack_recovery_episodes", "Number of TCP sack recovery episodes", labelsTCP, nil) + tcpSegmentRetransmits = prometheus.NewDesc(prefix+"tcp_segment_retransmits", "Number of TCP segment retransmits", labelsTCP, nil) + tcpByteRetransmits = prometheus.NewDesc(prefix+"tcp_byte_retransmits", "Number of TCP byte retransmits", labelsTCP, nil) + tcpSackOptionsReceived = prometheus.NewDesc(prefix+"tcp_sack_options_received", "Number of TCP sack options received", labelsTCP, nil) + tcpSackOptionsSent = prometheus.NewDesc(prefix+"tcp_sack_options_sent", "Number of TCP sack options sent", labelsTCP, nil) + tcpSackScoreboardOverflow = prometheus.NewDesc(prefix+"tcp_sack_scoreboard_overflow", "Number of TCP sack scoreboard overflow", labelsTCP, nil) + tcpAcksSentInResponseButNotExactRsts = prometheus.NewDesc(prefix+"tcp_acks_sent_in_response_but_not_exact_rsts", "Number of TCP acks sent in response but not exact rsts", labelsTCP, nil) + tcpAcksSentInResponseToSynsOnEstablishedConnections = prometheus.NewDesc(prefix+"tcp_ack_sent_in_response_to_syns_on_established_connections", "Number of TCP acks sent in response to syns on established connections", labelsTCP, nil) + tcpRcvPacketsDroppedDueToBadAddress = prometheus.NewDesc(prefix+"tcp_rcv_packets_dropped_due_to_bad_address", "Number of TCP rcv packets dropped due to bad address", labelsTCP, nil) + tcpOutOfSequenceSegmentDrops = prometheus.NewDesc(prefix+"tcp_out_of_sequence_segment_drops", "Number of TCP out of sequence segment drops", labelsTCP, nil) + tcpRstPackets = prometheus.NewDesc(prefix+"tcp_rst_packets", "Number of TCP rst packets", labelsTCP, nil) + tcpIcmpPacketsIgnored = prometheus.NewDesc(prefix+"tcp_icmp_packets_ignored", "Number of TCP icmp packets ignored", labelsTCP, nil) + tcpSendPacketsDropped = prometheus.NewDesc(prefix+"tcp_send_packets_dropped", "Number of TCP send packets dropped", labelsTCP, nil) + tcpRcvPacketsDropped = prometheus.NewDesc(prefix+"tcp_rcv_packets_dropped", "Number of TCP rcv packets dropped", labelsTCP, nil) + tcpOutgoingSegmentsDropped = prometheus.NewDesc(prefix+"tcp_outgoing_segments_dropped", "Number of TCP outgoing segments dropped", labelsTCP, nil) + tcpReceivedSynfinDropped = prometheus.NewDesc(prefix+"tcp_received_synfin_dropped", "Number of TCP received synfin dropped", labelsTCP, nil) + tcpReceivedIpsecDropped = prometheus.NewDesc(prefix+"tcp_received_ipsec_dropped", "Number of TCP received ipsec dropped", labelsTCP, nil) + tcpReceivedMacDropped = prometheus.NewDesc(prefix+"tcp_received_mac_dropped", "Number of TCP received mac dropped", labelsTCP, nil) + tcpReceivedMinttlExceeded = prometheus.NewDesc(prefix+"tcp_received_minttl_exceeded", "Number of TCP received minttl exceeded", labelsTCP, nil) + tcpListenstateBadflagsDropped = prometheus.NewDesc(prefix+"tcp_listenstate_badflags_dropped", "Number of TCP listenstate badflags dropped", labelsTCP, nil) + tcpFinwaitstateBadflagsDropped = prometheus.NewDesc(prefix+"tcp_finwaitstate_badflags_dropped", "Number of TCP finwaitstate badflags dropped", labelsTCP, nil) + tcpReceivedDosAttack = prometheus.NewDesc(prefix+"tcp_received_dos_attack", "Number of tcp received dos attack", labelsTCP, nil) + tcpReceivedBadSynack = prometheus.NewDesc(prefix+"tcp_received_bad_synack", "Number of tcp received bad synack", labelsTCP, nil) + tcpSyncacheZoneFull = prometheus.NewDesc(prefix+"tcp_syncache_zone_full", "Number of TCP syncache zone full", labelsTCP, nil) + tcpReceivedRstFirewallfilter = prometheus.NewDesc(prefix+"tcp_received_rst_firewallfilter", "Number of TCP received rst firewallfilter", labelsTCP, nil) + tcpReceivedNoackTimewait = prometheus.NewDesc(prefix+"tcp_received_noack_timewait", "Number of TCP received noack timewait", labelsTCP, nil) + tcpReceivedNoTimewaitState = prometheus.NewDesc(prefix+"tcp_received_no_timewait_state", "Number of TCP received no timewait state", labelsTCP, nil) + tcpReceivedRstTimewaitState = prometheus.NewDesc(prefix+"tcp_received_rst_timewait_state", "Number of TCP received rst timewait state", labelsTCP, nil) + tcpReceivedTimewaitDrops = prometheus.NewDesc(prefix+"tcp_received_timewait_drops", "Number of TCP received timewait drops", labelsTCP, nil) + tcpReceivedBadaddrTimewaitState = prometheus.NewDesc(prefix+"tcp_received_badaddr_timewait_state", "Number of TCP received badaddr timewait state", labelsTCP, nil) + tcpReceivedAckoffInSynSentrcvd = prometheus.NewDesc(prefix+"tcp_received_ackoff_insyn_sentrcvd", "Number of TCP received ackoff in syn sentrcvd", labelsTCP, nil) + tcpReceivedBadaddrFirewall = prometheus.NewDesc(prefix+"tcp_received_badaddr_firewall", "Number of TCP received badaddr firewall", labelsTCP, nil) + tcpReceivedNosynSynSent = prometheus.NewDesc(prefix+"tcp_received_nosyn_synsent", "Number of TCP received nosyn synsent", labelsTCP, nil) + tcpReceivedBadrstSynSent = prometheus.NewDesc(prefix+"tcp_received_badrst_synsent", "Number of TCP received badrst synsent", labelsTCP, nil) + tcpReceivedBadrstListenState = prometheus.NewDesc(prefix+"tcp_received_badrst_listenstate", "Number of TCP received badrst listenstate", labelsTCP, nil) + tcpOptionMaxsegmentLength = prometheus.NewDesc(prefix+"tcp_option_maxsegment_length", "Number of TCP option maxsegment length", labelsTCP, nil) + tcpOptionWindowLength = prometheus.NewDesc(prefix+"tcp_option_window_length", "Number of TCP option window length", labelsTCP, nil) + tcpOptionTimestampLength = prometheus.NewDesc(prefix+"tcp_option_timestamp_length", "Number of TCP option timestamp length", labelsTCP, nil) + tcpOptionMd5Length = prometheus.NewDesc(prefix+"tcp_option_md5_length", "Number of TCP option md5 length", labelsTCP, nil) + tcpOptionAuthLength = prometheus.NewDesc(prefix+"tcp_option_auth_length", "Number of TCP option auth length", labelsTCP, nil) + tcpOptionSackpermittedLength = prometheus.NewDesc(prefix+"tcp_option_sackpermitted_length", "Number of TCP option sackpermitted length", labelsTCP, nil) + tcpOptionSackLength = prometheus.NewDesc(prefix+"tcp_option_sack_length", "Number of TCP option sack length", labelsTCP, nil) + tcpOptionAuthoptionLength = prometheus.NewDesc(prefix+"tcp_option_authoption_length", "Number of TCP option authoption length", labelsTCP, nil) + } type systemstatisticsCollector struct{} @@ -317,6 +553,124 @@ func (c *systemstatisticsCollector) Describe(ch chan<- *prometheus.Desc) { ch <- udpDatagramsNotForHashedPcbDesc ch <- udpDatagramsDeliveredDesc ch <- udpDatagramsOutputDesc + + ch <- tcpPacketsSent + ch <- tcpSentDataPackets + ch <- tcpDataPacketsBytes + ch <- tcpSentDataPacketsRetransmitted + ch <- tcpRetransmittedBytes + ch <- tcpSentDataUnnecessaryRetransmitted + ch <- tcpSentResendsByMtuDiscovery + ch <- tcpSentAckOnlyPackets + ch <- tcpSentPacketsDelayed + ch <- tcpSentUrgOnlyPackets + ch <- tcpSentWindowProbePackets + ch <- tcpSentWindowUpdatePackets + ch <- tcpSentControlPackets + ch <- tcpPacketsReceived + ch <- tcpReceivedAcks + ch <- tcpAcksBytes + ch <- tcpReceivedDuplicateAcks + ch <- tcpReceivedAcksForUnsentData + ch <- tcpPacketsReceivedInSequence + ch <- tcpInSequenceBytes + ch <- tcpReceivedCompletelyDuplicatePacket + ch <- tcpDuplicateInBytes + ch <- tcpReceivedOldDuplicatePackets + ch <- tcpReceivedPacketsWithSomeDupliacteData + ch <- tcpSomeDuplicateInBytes + ch <- tcpReceivedOutOfOrderPackets + ch <- tcpOutOfOrderInBytes + ch <- tcpReceivedPacketsOfDataAfterWindow + ch <- tcpBytes + ch <- tcpReceivedWindowProbes + ch <- tcpReceivedWindowUpdatePackets + ch <- tcpPacketsReceivedAfterClose + ch <- tcpReceivedDiscardedForBadChecksum + ch <- tcpReceivedDiscardedForBadHeaderOffset + ch <- tcpReceivedDiscardedBecausePacketTooShort + ch <- tcpConnectionRequests + ch <- tcpConnectionAccepts + ch <- tcpBadConnectionAttempts + ch <- tcpListenQueueOverflows + ch <- tcpBadRstWindow + ch <- tcpConnectionsEstablished + ch <- tcpConnectionsClosed + ch <- tcpDrops + ch <- tcpConnectionsUpdatedRttOnClose + ch <- tcpConnectionsUpdatedVarianceOnClose + ch <- tcpConnectionsUpdatedSsthreshOnClose + ch <- tcpEmbryonicConnectionsDropped + ch <- tcpSegmentsUpdatedRtt + ch <- tcpAttempts + ch <- tcpRetransmitTimeouts + ch <- tcpConnectionsDroppedByRetransmitTimeout + ch <- tcpPersistTimeouts + ch <- tcpConnectionsDroppedByPersistTimeout + ch <- tcpKeepaliveTimeouts + ch <- tcpKeepaliveProbesSent + ch <- tcpKeepaliveConnectionsDropped + ch <- tcpAckHeaderPredictions + ch <- tcpDataPacketHeaderPredictions + ch <- tcpSyncacheEntriesAdded + ch <- tcpRetransmitted + ch <- tcpDupsyn + ch <- tcpDropped + ch <- tcpCompleted + ch <- tcpBucketOverflow + ch <- tcpCacheOverflow + ch <- tcpReset + ch <- tcpStale + ch <- tcpAborted + ch <- tcpBadack + ch <- tcpUnreach + ch <- tcpZoneFailures + ch <- tcpCookiesSent + ch <- tcpCookiesReceived + ch <- tcpSackRecoveryEpisodes + ch <- tcpSegmentRetransmits + ch <- tcpByteRetransmits + ch <- tcpSackOptionsReceived + ch <- tcpSackOptionsSent + ch <- tcpSackScoreboardOverflow + ch <- tcpAcksSentInResponseButNotExactRsts + ch <- tcpAcksSentInResponseToSynsOnEstablishedConnections + ch <- tcpRcvPacketsDroppedDueToBadAddress + ch <- tcpOutOfSequenceSegmentDrops + ch <- tcpRstPackets + ch <- tcpIcmpPacketsIgnored + ch <- tcpSendPacketsDropped + ch <- tcpRcvPacketsDropped + ch <- tcpOutgoingSegmentsDropped + ch <- tcpReceivedSynfinDropped + ch <- tcpReceivedIpsecDropped + ch <- tcpReceivedMacDropped + ch <- tcpReceivedMinttlExceeded + ch <- tcpListenstateBadflagsDropped + ch <- tcpFinwaitstateBadflagsDropped + ch <- tcpReceivedDosAttack + ch <- tcpReceivedBadSynack + ch <- tcpSyncacheZoneFull + ch <- tcpReceivedRstFirewallfilter + ch <- tcpReceivedNoackTimewait + ch <- tcpReceivedNoTimewaitState + ch <- tcpReceivedRstTimewaitState + ch <- tcpReceivedTimewaitDrops + ch <- tcpReceivedBadaddrTimewaitState + ch <- tcpReceivedAckoffInSynSentrcvd + ch <- tcpReceivedBadaddrFirewall + ch <- tcpReceivedNosynSynSent + ch <- tcpReceivedBadrstSynSent + ch <- tcpReceivedBadrstListenState + ch <- tcpOptionMaxsegmentLength + ch <- tcpOptionWindowLength + ch <- tcpOptionTimestampLength + ch <- tcpOptionMd5Length + ch <- tcpOptionAuthLength + ch <- tcpOptionSackpermittedLength + ch <- tcpOptionSackLength + ch <- tcpOptionAuthoptionLength + } func (c *systemstatisticsCollector) Collect(client collector.Client, ch chan<- prometheus.Metric, labelValues []string) error { @@ -328,6 +682,7 @@ func (c *systemstatisticsCollector) Collect(client collector.Client, ch chan<- p c.collectSystemStatisticsIPV4(ch, labelValues, s) c.collectSystemStatisticsIPV6(ch, labelValues, s) c.collectSystemStatisticsUDP(ch, labelValues, s) + c.collectSystemStatisticsTCP(ch, labelValues, s) return nil } @@ -439,4 +794,122 @@ func (c *systemstatisticsCollector) collectSystemStatisticsUDP(ch chan<- prometh ch <- prometheus.MustNewConstMetric(udpDatagramsNotForHashedPcbDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsNotForHashedPcb, l...) ch <- prometheus.MustNewConstMetric(udpDatagramsDeliveredDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsDelivered, l...) ch <- prometheus.MustNewConstMetric(udpDatagramsOutputDesc, prometheus.CounterValue, s.Statistics.Udp.DatagramsOutput, l...) -} \ No newline at end of file +} + +func (c *systemstatisticsCollector) collectSystemStatisticsTCP(ch chan<- prometheus.Metric, labelValues []string, s SystemStatistics) { + l := append(labelValues, "tcp") + ch <- prometheus.MustNewConstMetric(tcpPacketsSent, prometheus.CounterValue, s.Statistics.Tcp.PacketsSent, l...) + ch <- prometheus.MustNewConstMetric(tcpSentDataPackets, prometheus.CounterValue, s.Statistics.Tcp.SentDataPackets, l...) + ch <- prometheus.MustNewConstMetric(tcpDataPacketsBytes, prometheus.CounterValue, s.Statistics.Tcp.DataPacketsBytes, l...) + ch <- prometheus.MustNewConstMetric(tcpSentDataPacketsRetransmitted, prometheus.CounterValue, s.Statistics.Tcp.SentDataPacketsRetransmitted, l...) + ch <- prometheus.MustNewConstMetric(tcpRetransmittedBytes, prometheus.CounterValue, s.Statistics.Tcp.RetransmittedBytes, l...) + ch <- prometheus.MustNewConstMetric(tcpSentDataUnnecessaryRetransmitted, prometheus.CounterValue, s.Statistics.Tcp.SentDataUnnecessaryRetransmitted, l...) + ch <- prometheus.MustNewConstMetric(tcpSentResendsByMtuDiscovery, prometheus.CounterValue, s.Statistics.Tcp.SentResendsByMtuDiscovery, l...) + ch <- prometheus.MustNewConstMetric(tcpSentAckOnlyPackets, prometheus.CounterValue, s.Statistics.Tcp.SentAckOnlyPackets, l...) + ch <- prometheus.MustNewConstMetric(tcpSentPacketsDelayed, prometheus.CounterValue, s.Statistics.Tcp.SentPacketsDelayed, l...) + ch <- prometheus.MustNewConstMetric(tcpSentUrgOnlyPackets, prometheus.CounterValue, s.Statistics.Tcp.SentUrgOnlyPackets, l...) + ch <- prometheus.MustNewConstMetric(tcpSentWindowProbePackets, prometheus.CounterValue, s.Statistics.Tcp.SentWindowProbePackets, l...) + ch <- prometheus.MustNewConstMetric(tcpSentWindowUpdatePackets, prometheus.CounterValue, s.Statistics.Tcp.SentWindowUpdatePackets, l...) + ch <- prometheus.MustNewConstMetric(tcpSentControlPackets, prometheus.CounterValue, s.Statistics.Tcp.SentControlPackets, l...) + ch <- prometheus.MustNewConstMetric(tcpPacketsReceived, prometheus.CounterValue, s.Statistics.Tcp.PacketsReceived, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedAcks, prometheus.CounterValue, s.Statistics.Tcp.ReceivedAcks, l...) + ch <- prometheus.MustNewConstMetric(tcpAcksBytes, prometheus.CounterValue, s.Statistics.Tcp.AcksBytes, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedDuplicateAcks, prometheus.CounterValue, s.Statistics.Tcp.ReceivedDuplicateAcks, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedAcksForUnsentData, prometheus.CounterValue, s.Statistics.Tcp.ReceivedAcksForUnsentData, l...) + ch <- prometheus.MustNewConstMetric(tcpPacketsReceivedInSequence, prometheus.CounterValue, s.Statistics.Tcp.PacketsReceivedInSequence, l...) + ch <- prometheus.MustNewConstMetric(tcpInSequenceBytes, prometheus.CounterValue, s.Statistics.Tcp.InSequenceBytes, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedCompletelyDuplicatePacket, prometheus.CounterValue, s.Statistics.Tcp.ReceivedCompletelyDuplicatePacket, l...) + ch <- prometheus.MustNewConstMetric(tcpDuplicateInBytes, prometheus.CounterValue, s.Statistics.Tcp.DuplicateInBytes, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedOldDuplicatePackets, prometheus.CounterValue, s.Statistics.Tcp.ReceivedOldDuplicatePackets, l...) + ch <- prometheus.MustNewConstMetric(tcpSomeDuplicateInBytes, prometheus.CounterValue, s.Statistics.Tcp.SomeDuplicateInBytes, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedOutOfOrderPackets, prometheus.CounterValue, s.Statistics.Tcp.ReceivedOutOfOrderPackets, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedPacketsOfDataAfterWindow, prometheus.CounterValue, s.Statistics.Tcp.ReceivedPacketsOfDataAfterWindow, l...) + ch <- prometheus.MustNewConstMetric(tcpBytes, prometheus.CounterValue, s.Statistics.Tcp.Bytes, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedWindowProbes, prometheus.CounterValue, s.Statistics.Tcp.ReceivedWindowProbes, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedWindowUpdatePackets, prometheus.CounterValue, s.Statistics.Tcp.ReceivedWindowUpdatePackets, l...) + ch <- prometheus.MustNewConstMetric(tcpPacketsReceivedAfterClose, prometheus.CounterValue, s.Statistics.Tcp.PacketsReceivedAfterClose, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedDiscardedForBadChecksum, prometheus.CounterValue, s.Statistics.Tcp.ReceivedDiscardedForBadChecksum, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedDiscardedForBadHeaderOffset, prometheus.CounterValue, s.Statistics.Tcp.ReceivedDiscardedForBadHeaderOffset, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedDiscardedBecausePacketTooShort, prometheus.CounterValue, s.Statistics.Tcp.ReceivedDiscardedBecausePacketTooShort, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionRequests, prometheus.CounterValue, s.Statistics.Tcp.ConnectionRequests, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionAccepts, prometheus.CounterValue, s.Statistics.Tcp.ConnectionAccepts, l...) + ch <- prometheus.MustNewConstMetric(tcpBadConnectionAttempts, prometheus.CounterValue, s.Statistics.Tcp.BadConnectionAttempts, l...) + ch <- prometheus.MustNewConstMetric(tcpListenQueueOverflows, prometheus.CounterValue, s.Statistics.Tcp.ListenQueueOverflows, l...) + ch <- prometheus.MustNewConstMetric(tcpBadRstWindow, prometheus.CounterValue, s.Statistics.Tcp.BadRstWindow, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsEstablished, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsEstablished, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsClosed, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsClosed, l...) + ch <- prometheus.MustNewConstMetric(tcpDrops, prometheus.CounterValue, s.Statistics.Tcp.Drops, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsUpdatedRttOnClose, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsUpdatedRttOnClose, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsUpdatedVarianceOnClose, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsUpdatedVarianceOnClose, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsUpdatedSsthreshOnClose, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsUpdatedSsthreshOnClose, l...) + ch <- prometheus.MustNewConstMetric(tcpEmbryonicConnectionsDropped, prometheus.CounterValue, s.Statistics.Tcp.EmbryonicConnectionsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpSegmentsUpdatedRtt, prometheus.CounterValue, s.Statistics.Tcp.SegmentsUpdatedRtt, l...) + ch <- prometheus.MustNewConstMetric(tcpAttempts, prometheus.CounterValue, s.Statistics.Tcp.Attempts, l...) + ch <- prometheus.MustNewConstMetric(tcpRetransmitTimeouts, prometheus.CounterValue, s.Statistics.Tcp.RetransmitTimeouts, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsDroppedByRetransmitTimeout, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsDroppedByRetransmitTimeout, l...) + ch <- prometheus.MustNewConstMetric(tcpPersistTimeouts, prometheus.CounterValue, s.Statistics.Tcp.PersistTimeouts, l...) + ch <- prometheus.MustNewConstMetric(tcpConnectionsDroppedByPersistTimeout, prometheus.CounterValue, s.Statistics.Tcp.ConnectionsDroppedByPersistTimeout, l...) + ch <- prometheus.MustNewConstMetric(tcpKeepaliveTimeouts, prometheus.CounterValue, s.Statistics.Tcp.KeepaliveTimeouts, l...) + ch <- prometheus.MustNewConstMetric(tcpKeepaliveProbesSent, prometheus.CounterValue, s.Statistics.Tcp.KeepaliveProbesSent, l...) + ch <- prometheus.MustNewConstMetric(tcpKeepaliveConnectionsDropped, prometheus.CounterValue, s.Statistics.Tcp.KeepaliveConnectionsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpAckHeaderPredictions, prometheus.CounterValue, s.Statistics.Tcp.AckHeaderPredictions, l...) + ch <- prometheus.MustNewConstMetric(tcpDataPacketHeaderPredictions, prometheus.CounterValue, s.Statistics.Tcp.DataPacketHeaderPredictions, l...) + ch <- prometheus.MustNewConstMetric(tcpSyncacheEntriesAdded, prometheus.CounterValue, s.Statistics.Tcp.SyncacheEntriesAdded, l...) + ch <- prometheus.MustNewConstMetric(tcpRetransmitted, prometheus.CounterValue, s.Statistics.Tcp.Retransmitted, l...) + ch <- prometheus.MustNewConstMetric(tcpDupsyn, prometheus.CounterValue, s.Statistics.Tcp.Dupsyn, l...) + ch <- prometheus.MustNewConstMetric(tcpDropped, prometheus.CounterValue, s.Statistics.Tcp.Dropped, l...) + ch <- prometheus.MustNewConstMetric(tcpCompleted, prometheus.CounterValue, s.Statistics.Tcp.Completed, l...) + ch <- prometheus.MustNewConstMetric(tcpBucketOverflow, prometheus.CounterValue, s.Statistics.Tcp.BucketOverflow, l...) + ch <- prometheus.MustNewConstMetric(tcpCacheOverflow, prometheus.CounterValue, s.Statistics.Tcp.CacheOverflow, l...) + ch <- prometheus.MustNewConstMetric(tcpReset, prometheus.CounterValue, s.Statistics.Tcp.Reset, l...) + ch <- prometheus.MustNewConstMetric(tcpStale, prometheus.CounterValue, s.Statistics.Tcp.Stale, l...) + ch <- prometheus.MustNewConstMetric(tcpAborted, prometheus.CounterValue, s.Statistics.Tcp.Aborted, l...) + ch <- prometheus.MustNewConstMetric(tcpBadack, prometheus.CounterValue, s.Statistics.Tcp.Badack, l...) + ch <- prometheus.MustNewConstMetric(tcpUnreach, prometheus.CounterValue, s.Statistics.Tcp.Unreach, l...) + ch <- prometheus.MustNewConstMetric(tcpZoneFailures, prometheus.CounterValue, s.Statistics.Tcp.ZoneFailures, l...) + ch <- prometheus.MustNewConstMetric(tcpCookiesSent, prometheus.CounterValue, s.Statistics.Tcp.CookiesSent, l...) + ch <- prometheus.MustNewConstMetric(tcpCookiesReceived, prometheus.CounterValue, s.Statistics.Tcp.CookiesReceived, l...) + ch <- prometheus.MustNewConstMetric(tcpSackRecoveryEpisodes, prometheus.CounterValue, s.Statistics.Tcp.SackRecoveryEpisodes, l...) + ch <- prometheus.MustNewConstMetric(tcpSegmentRetransmits, prometheus.CounterValue, s.Statistics.Tcp.SegmentRetransmits, l...) + ch <- prometheus.MustNewConstMetric(tcpByteRetransmits, prometheus.CounterValue, s.Statistics.Tcp.ByteRetransmits, l...) + ch <- prometheus.MustNewConstMetric(tcpSackOptionsReceived, prometheus.CounterValue, s.Statistics.Tcp.SackOptionsReceived, l...) + ch <- prometheus.MustNewConstMetric(tcpSackOptionsSent, prometheus.CounterValue, s.Statistics.Tcp.SackOptionsReceived, l...) + ch <- prometheus.MustNewConstMetric(tcpSackScoreboardOverflow, prometheus.CounterValue, s.Statistics.Tcp.SackScoreboardOverflow, l...) + ch <- prometheus.MustNewConstMetric(tcpAcksSentInResponseButNotExactRsts, prometheus.CounterValue, s.Statistics.Tcp.AcksSentInResponseButNotExactRsts, l...) + ch <- prometheus.MustNewConstMetric(tcpAcksSentInResponseToSynsOnEstablishedConnections, prometheus.CounterValue, s.Statistics.Tcp.AcksSentInResponseToSynsOnEstablishedConnections, l...) + ch <- prometheus.MustNewConstMetric(tcpRcvPacketsDroppedDueToBadAddress, prometheus.CounterValue, s.Statistics.Tcp.RcvPacketsDroppedDueToBadAddress, l...) + ch <- prometheus.MustNewConstMetric(tcpOutOfSequenceSegmentDrops, prometheus.CounterValue, s.Statistics.Tcp.OutOfSequenceSegmentDrops, l...) + ch <- prometheus.MustNewConstMetric(tcpRstPackets, prometheus.CounterValue, s.Statistics.Tcp.RstPackets, l...) + ch <- prometheus.MustNewConstMetric(tcpIcmpPacketsIgnored, prometheus.CounterValue, s.Statistics.Tcp.IcmpPacketsIgnored, l...) + ch <- prometheus.MustNewConstMetric(tcpSendPacketsDropped, prometheus.CounterValue, s.Statistics.Tcp.SendPacketsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpRcvPacketsDropped, prometheus.CounterValue, s.Statistics.Tcp.RcvPacketsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpOutgoingSegmentsDropped, prometheus.CounterValue, s.Statistics.Tcp.OutgoingSegmentsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedSynfinDropped, prometheus.CounterValue, s.Statistics.Tcp.ReceivedSynfinDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedIpsecDropped, prometheus.CounterValue, s.Statistics.Tcp.ReceivedIpsecDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedMacDropped, prometheus.CounterValue, s.Statistics.Tcp.ReceivedMacDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedMinttlExceeded, prometheus.CounterValue, s.Statistics.Tcp.ReceivedMinttlExceeded, l...) + ch <- prometheus.MustNewConstMetric(tcpListenstateBadflagsDropped, prometheus.CounterValue, s.Statistics.Tcp.ListenstateBadflagsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpFinwaitstateBadflagsDropped, prometheus.CounterValue, s.Statistics.Tcp.FinwaitstateBadflagsDropped, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedDosAttack, prometheus.CounterValue, s.Statistics.Tcp.ReceivedDosAttack, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedBadSynack, prometheus.CounterValue, s.Statistics.Tcp.ReceivedBadSynack, l...) + ch <- prometheus.MustNewConstMetric(tcpSyncacheZoneFull, prometheus.CounterValue, s.Statistics.Tcp.SyncacheZoneFull, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedRstFirewallfilter, prometheus.CounterValue, s.Statistics.Tcp.ReceivedRstFirewallfilter, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedNoackTimewait, prometheus.CounterValue, s.Statistics.Tcp.ReceivedNoackTimewait, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedNoTimewaitState, prometheus.CounterValue, s.Statistics.Tcp.ReceivedNoTimewaitState, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedRstTimewaitState, prometheus.CounterValue, s.Statistics.Tcp.ReceivedRstTimewaitState, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedTimewaitDrops, prometheus.CounterValue, s.Statistics.Tcp.ReceivedTimewaitDrops, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedBadaddrTimewaitState, prometheus.CounterValue, s.Statistics.Tcp.ReceivedBadaddrTimewaitState, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedAckoffInSynSentrcvd, prometheus.CounterValue, s.Statistics.Tcp.ReceivedAckoffInSynSentrcvd, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedBadaddrFirewall, prometheus.CounterValue, s.Statistics.Tcp.ReceivedBadaddrFirewall, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedNosynSynSent, prometheus.CounterValue, s.Statistics.Tcp.ReceivedNosynSynSent, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedBadrstSynSent, prometheus.CounterValue, s.Statistics.Tcp.ReceivedBadrstSynSent, l...) + ch <- prometheus.MustNewConstMetric(tcpReceivedBadrstListenState, prometheus.CounterValue, s.Statistics.Tcp.ReceivedBadrstListenState, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionMaxsegmentLength, prometheus.CounterValue, s.Statistics.Tcp.OptionMaxsegmentLength, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionWindowLength, prometheus.CounterValue, s.Statistics.Tcp.OptionWindowLength, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionTimestampLength, prometheus.CounterValue, s.Statistics.Tcp.OptionTimestampLength, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionMd5Length, prometheus.CounterValue, s.Statistics.Tcp.OptionMd5Length, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionAuthLength, prometheus.CounterValue, s.Statistics.Tcp.OptionAuthLength, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionSackpermittedLength, prometheus.CounterValue, s.Statistics.Tcp.OptionSackpermittedLength, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionSackLength, prometheus.CounterValue, s.Statistics.Tcp.OptionSackLength, l...) + ch <- prometheus.MustNewConstMetric(tcpOptionAuthoptionLength, prometheus.CounterValue, s.Statistics.Tcp.OptionAuthoptionLength, l...) +} From b2b8ce3597021e6dd37d246df5529f1c285aae77 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Fri, 29 Aug 2025 08:59:12 +0200 Subject: [PATCH 11/27] refactored tests for ipv4 --- pkg/features/systemstatistics/rpc_test.go | 190 ++---------------- .../testsFiles/IPV4/ipv4TestDataCase1.xml | 54 +++++ .../testsFiles/IPV4/ipv4TestDataCase2.xml | 54 +++++ .../testsFiles/IPV4/ipv4TestDataCase3.xml | 54 +++++ 4 files changed, 182 insertions(+), 170 deletions(-) create mode 100644 pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml create mode 100644 pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase2.xml create mode 100644 pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase3.xml diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 7c3d930d..fb480114 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,73 +2,29 @@ package systemstatistics import ( "encoding/xml" + "io/ioutil" + "os" "testing" "github.com/stretchr/testify/assert" ) func TestStatisticsIPv4Unmarshaling(t *testing.T) { + + IPv4XMLDataCase1, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase1.xml") + IPv4DataCase1, _ := ioutil.ReadAll(IPv4XMLDataCase1) + IPv4XMLDataCase2, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase2.xml") + IPv4DataCase2, _ := ioutil.ReadAll(IPv4XMLDataCase2) + IPv4XMLDataCase3, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase3.xml") + IPv4DataCase3, _ := ioutil.ReadAll(IPv4XMLDataCase3) tests := []struct { name string xmlInput string expected SystemStatistics }{ { - name: "complete_ipv4_statistics", - xmlInput: ` - - - 1000 - 5 - 10 - 2 - 3 - 1 - 0 - 0 - 50 - 2 - 1 - 0 - 48 - 500 - 5 - 400 - 10 - 2 - 800 - 0 - 3 - 1 - 20 - 40 - 2 - 1 - 15 - 0 - 2 - 5 - 3 - 1 - 0 - 0 - 4 - 8 - 12 - 0 - 25 - 100 - 2 - 95 - 1 - 3 - 200 - - - - user@router> - - `, + name: "complete_ipv4_statistics", + xmlInput: string(IPv4DataCase1), expected: SystemStatistics{ Statistics: struct { Text string `xml:",chardata"` @@ -343,7 +299,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { ArpMgtDrop string `xml:"arp-mgt-drop"` } `xml:"arp"` Ip6 struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` TotalPacketsReceived float64 `xml:"total-packets-received"` Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` @@ -377,7 +333,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` HeaderType []struct { Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` LinkLocals float64 `xml:"link-locals"` Globals float64 `xml:"globals"` AddressScope float64 `xml:"address-scope"` @@ -598,61 +554,8 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { }, }, { - name: "empty_ipv4_statistics", - xmlInput: ` - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - - user@router> - - `, + name: "empty_ipv4_statistics", + xmlInput: string(IPv4DataCase2), expected: SystemStatistics{ Cli: struct { Text string `xml:",chardata"` @@ -663,61 +566,8 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { }, }, { - name: "high_values_ipv4_statistics", - xmlInput: ` - - - 999999999 - 12345 - 54321 - 1111 - 2222 - 3333 - 4444 - 5555 - 888888 - 6666 - 7777 - 8888 - 777777 - 555555 - 9999 - 444444 - 11111 - 12121 - 666666 - 13131 - 14141 - 15151 - 16161 - 17171 - 18181 - 19191 - 20202 - 21212 - 22222 - 23232 - 24242 - 25252 - 26262 - 27272 - 28282 - 29292 - 30303 - 31313 - 32323 - 33333 - 34343 - 35353 - 36363 - 37373 - 38383 - - - - admin@high-traffic-router> - - `, + name: "high_values_ipv4_statistics", + xmlInput: string(IPv4DataCase3), expected: SystemStatistics{ Statistics: struct { Text string `xml:",chardata"` @@ -992,7 +842,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { ArpMgtDrop string `xml:"arp-mgt-drop"` } `xml:"arp"` Ip6 struct { - Text string `xml:",chardata"` + Text string `xml:",chardata"` TotalPacketsReceived float64 `xml:"total-packets-received"` Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` @@ -1026,7 +876,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` HeaderType []struct { Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` LinkLocals float64 `xml:"link-locals"` Globals float64 `xml:"globals"` AddressScope float64 `xml:"address-scope"` @@ -1302,4 +1152,4 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { assert.Equal(t, tt.expected.Statistics.Ip.IncomingVirtualNodePacketsDelivered, result.Statistics.Ip.IncomingVirtualNodePacketsDelivered, "IncomingVirtualNodePacketsDelivered should match") }) } -} \ No newline at end of file +} diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml new file mode 100644 index 00000000..1fdadd28 --- /dev/null +++ b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml @@ -0,0 +1,54 @@ + + + + 1000 + 5 + 10 + 2 + 3 + 1 + 0 + 0 + 50 + 2 + 1 + 0 + 48 + 500 + 5 + 400 + 10 + 2 + 800 + 0 + 3 + 1 + 20 + 40 + 2 + 1 + 15 + 0 + 2 + 5 + 3 + 1 + 0 + 0 + 4 + 8 + 12 + 0 + 25 + 100 + 2 + 95 + 1 + 3 + 200 + + + + user@router> + + \ No newline at end of file diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase2.xml b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase2.xml new file mode 100644 index 00000000..9ea0384e --- /dev/null +++ b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase2.xml @@ -0,0 +1,54 @@ + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + user@router> + + \ No newline at end of file diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase3.xml b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase3.xml new file mode 100644 index 00000000..112cd09d --- /dev/null +++ b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase3.xml @@ -0,0 +1,54 @@ + + + + 999999999 + 12345 + 54321 + 1111 + 2222 + 3333 + 4444 + 5555 + 888888 + 6666 + 7777 + 8888 + 777777 + 555555 + 9999 + 444444 + 11111 + 12121 + 666666 + 13131 + 14141 + 15151 + 16161 + 17171 + 18181 + 19191 + 20202 + 21212 + 22222 + 23232 + 24242 + 25252 + 26262 + 27272 + 28282 + 29292 + 30303 + 31313 + 32323 + 33333 + 34343 + 35353 + 36363 + 37373 + 38383 + + + + admin@high-traffic-router> + + \ No newline at end of file From 3ecd599e3d1c16925896c46f538063a23da9fbc0 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Fri, 29 Aug 2025 09:22:54 +0200 Subject: [PATCH 12/27] small edit in tets --- pkg/features/systemstatistics/rpc_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index fb480114..0c1799fa 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -17,7 +17,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { IPv4DataCase2, _ := ioutil.ReadAll(IPv4XMLDataCase2) IPv4XMLDataCase3, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase3.xml") IPv4DataCase3, _ := ioutil.ReadAll(IPv4XMLDataCase3) - tests := []struct { + testsIPV4 := []struct { name string xmlInput string expected SystemStatistics @@ -1098,7 +1098,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { }, } - for _, tt := range tests { + for _, tt := range testsIPV4 { t.Run(tt.name, func(t *testing.T) { var result SystemStatistics err := xml.Unmarshal([]byte(tt.xmlInput), &result) From 3980664eeb0829e4d35e017cee5e8d4431e0ef53 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Fri, 29 Aug 2025 09:58:02 +0200 Subject: [PATCH 13/27] added tests for IPv6 --- pkg/features/systemstatistics/rpc_test.go | 1366 +++-------------- .../testsFiles/IPv6/ipv6TestDataCase1.xml | 59 + 2 files changed, 313 insertions(+), 1112 deletions(-) create mode 100644 pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 0c1799fa..f25700df 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,6 +2,7 @@ package systemstatistics import ( "encoding/xml" + "fmt" "io/ioutil" "os" "testing" @@ -10,1146 +11,287 @@ import ( ) func TestStatisticsIPv4Unmarshaling(t *testing.T) { - IPv4XMLDataCase1, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase1.xml") IPv4DataCase1, _ := ioutil.ReadAll(IPv4XMLDataCase1) IPv4XMLDataCase2, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase2.xml") IPv4DataCase2, _ := ioutil.ReadAll(IPv4XMLDataCase2) IPv4XMLDataCase3, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase3.xml") IPv4DataCase3, _ := ioutil.ReadAll(IPv4XMLDataCase3) - testsIPV4 := []struct { + + type testCase struct { name string xmlInput string - expected SystemStatistics - }{ + expect func(t *testing.T, got SystemStatistics) + } + + testsIPV4 := []testCase{ { name: "complete_ipv4_statistics", xmlInput: string(IPv4DataCase1), - expected: SystemStatistics{ - Statistics: struct { - Text string `xml:",chardata"` - Tcp struct { - Text string `xml:",chardata"` - PacketsSent float64 `xml:"packets-sent"` - SentDataPackets float64 `xml:"sent-data-packets"` - DataPacketsBytes float64 `xml:"data-packets-bytes"` - SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` - RetransmittedBytes float64 `xml:"retransmitted-bytes"` - SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` - SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` - SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` - SentPacketsDelayed float64 `xml:"sent-packets-delayed"` - SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` - SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` - SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` - SentControlPackets float64 `xml:"sent-control-packets"` - PacketsReceived float64 `xml:"packets-received"` - ReceivedAcks float64 `xml:"received-acks"` - AcksBytes float64 `xml:"acks-bytes"` - ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` - ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` - PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` - InSequenceBytes float64 `xml:"in-sequence-bytes"` - ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` - DuplicateInBytes float64 `xml:"duplicate-in-bytes"` - ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` - ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` - SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` - ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` - OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` - ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` - Bytes float64 `xml:"bytes"` - ReceivedWindowProbes float64 `xml:"received-window-probes"` - ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` - PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` - ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` - ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` - ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` - ConnectionRequests float64 `xml:"connection-requests"` - ConnectionAccepts float64 `xml:"connection-accepts"` - BadConnectionAttempts float64 `xml:"bad-connection-attempts"` - ListenQueueOverflows float64 `xml:"listen-queue-overflows"` - BadRstWindow float64 `xml:"bad-rst-window"` - ConnectionsEstablished float64 `xml:"connections-established"` - ConnectionsClosed float64 `xml:"connections-closed"` - Drops float64 `xml:"drops"` - ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` - ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` - ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` - EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` - SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` - Attempts float64 `xml:"attempts"` - RetransmitTimeouts float64 `xml:"retransmit-timeouts"` - ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` - PersistTimeouts float64 `xml:"persist-timeouts"` - ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` - KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` - KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` - KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` - AckHeaderPredictions float64 `xml:"ack-header-predictions"` - DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` - SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` - Retransmitted float64 `xml:"retransmitted"` - Dupsyn float64 `xml:"dupsyn"` - Dropped float64 `xml:"dropped"` - Completed float64 `xml:"completed"` - BucketOverflow float64 `xml:"bucket-overflow"` - CacheOverflow float64 `xml:"cache-overflow"` - Reset float64 `xml:"reset"` - Stale float64 `xml:"stale"` - Aborted float64 `xml:"aborted"` - Badack float64 `xml:"badack"` - Unreach float64 `xml:"unreach"` - ZoneFailures float64 `xml:"zone-failures"` - CookiesSent float64 `xml:"cookies-sent"` - CookiesReceived float64 `xml:"cookies-received"` - SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` - SegmentRetransmits float64 `xml:"segment-retransmits"` - ByteRetransmits float64 `xml:"byte-retransmits"` - SackOptionsReceived float64 `xml:"sack-options-received"` - SackOpitionsSent float64 `xml:"sack-opitions-sent"` - SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` - AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` - AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` - RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` - OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` - RstPackets float64 `xml:"rst-packets"` - IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` - SendPacketsDropped float64 `xml:"send-packets-dropped"` - RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` - OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` - ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` - ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` - ReceivedMacDropped float64 `xml:"received-mac-dropped"` - ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` - ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` - FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` - ReceivedDosAttack float64 `xml:"received-dos-attack"` - ReceivedBadSynack float64 `xml:"received-bad-synack"` - SyncacheZoneFull float64 `xml:"syncache-zone-full"` - ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` - ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` - ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` - ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` - ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` - ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` - ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` - ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` - ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` - ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` - ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` - OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` - OptionWindowLength float64 `xml:"option-window-length"` - OptionTimestampLength float64 `xml:"option-timestamp-length"` - OptionMd5Length float64 `xml:"option-md5-length"` - OptionAuthLength float64 `xml:"option-auth-length"` - OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` - OptionSackLength float64 `xml:"option-sack-length"` - OptionAuthoptionLength float64 `xml:"option-authoption-length"` - } `xml:"tcp"` - Udp struct { - Text string `xml:",chardata"` - DatagramsReceived float64 `xml:"datagrams-received"` - DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` - DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` - DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` - DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` - BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` - DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` - DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` - DatagramsDelivered float64 `xml:"datagrams-delivered"` - DatagramsOutput float64 `xml:"datagrams-output"` - } `xml:"udp"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - Icmp struct { - Text string `xml:",chardata"` - DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` - CallsToIcmpError string `xml:"calls-to-icmp-error"` - ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` - Histogram []struct { - Text string `xml:",chardata"` - TypeOfHistogram string `xml:"type-of-histogram"` - IcmpEchoReply string `xml:"icmp-echo-reply"` - DestinationUnreachable string `xml:"destination-unreachable"` - IcmpEcho string `xml:"icmp-echo"` - TimeStampReply string `xml:"time-stamp-reply"` - TimeExceeded string `xml:"time-exceeded"` - TimeStamp string `xml:"time-stamp"` - AddressMaskRequest string `xml:"address-mask-request"` - AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` - } `xml:"histogram"` - MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` - MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` - MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` - MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` - MessagesWithBadLength string `xml:"messages-with-bad-length"` - EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` - TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` - MessageResponsesGenerated string `xml:"message-responses-generated"` - } `xml:"icmp"` - Arp struct { - Text string `xml:",chardata"` - DatagramsReceived string `xml:"datagrams-received"` - ArpRequestsReceived string `xml:"arp-requests-received"` - ArpRepliesReceived string `xml:"arp-replies-received"` - ResolutionRequestReceived string `xml:"resolution-request-received"` - ResolutionRequestDropped string `xml:"resolution-request-dropped"` - UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` - RestrictedProxyRequests string `xml:"restricted-proxy-requests"` - ReceivedProxyRequests string `xml:"received-proxy-requests"` - ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` - RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` - DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` - DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` - DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` - DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` - DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` - DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` - DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` - DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` - DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` - DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` - DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` - DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` - DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` - PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` - PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` - ArpRequestsSent string `xml:"arp-requests-sent"` - ArpRepliesSent string `xml:"arp-replies-sent"` - RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` - RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` - RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` - RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` - RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` - NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` - RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` - RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` - RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` - ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` - ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` - ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` - ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` - ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` - SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` - ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` - ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` - ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` - ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` - GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` - ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` - ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` - ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` - ArpSystemMax string `xml:"arp-system-max"` - ArpPublicMax string `xml:"arp-public-max"` - ArpIriMax string `xml:"arp-iri-max"` - ArpMgtMax string `xml:"arp-mgt-max"` - ArpPublicCnt string `xml:"arp-public-cnt"` - ArpIriCnt string `xml:"arp-iri-cnt"` - ArpMgtCnt string `xml:"arp-mgt-cnt"` - ArpSystemDrop string `xml:"arp-system-drop"` - ArpPublicDrop string `xml:"arp-public-drop"` - ArpIriDrop string `xml:"arp-iri-drop"` - ArpMgtDrop string `xml:"arp-mgt-drop"` - } `xml:"arp"` - Ip6 struct { - Text string `xml:",chardata"` - TotalPacketsReceived float64 `xml:"total-packets-received"` - Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` - PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` - Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` - Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` - Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` - DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` - Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` - FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` - Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` - Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` - Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` - Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` - Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` - Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` - Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` - Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` - Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` - Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` - Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` - Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` - PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` - MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` - Histogram float64 `xml:"histogram"` - Ip6nhTcp float64 `xml:"ip6nh-tcp"` - Ip6nhUdp float64 `xml:"ip6nh-udp"` - Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` - PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` - TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` - PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` - FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` - HeaderType []struct { - Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` - LinkLocals float64 `xml:"link-locals"` - Globals float64 `xml:"globals"` - AddressScope float64 `xml:"address-scope"` - HexValue float64 `xml:"hex-value"` - } `xml:"header-type"` - ForwardCacheHit float64 `xml:"forward-cache-hit"` - ForwardCacheMiss float64 `xml:"forward-cache-miss"` - Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` - Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` - Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` - PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` - TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` - PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` - } `xml:"ip6"` - Icmp6 struct { - Text string `xml:",chardata"` - ProtocolName string `xml:"protocol-name"` - CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` - ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` - ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` - OutputHistogram struct { - Text string `xml:",chardata"` - Style string `xml:"style,attr"` - HistogramType string `xml:"histogram-type"` - UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` - Icmp6Echo string `xml:"icmp6-echo"` - Icmp6EchoReply string `xml:"icmp6-echo-reply"` - NeighborSolicitation string `xml:"neighbor-solicitation"` - NeighborAdvertisement string `xml:"neighbor-advertisement"` - } `xml:"output-histogram"` - Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` - MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` - BadChecksums string `xml:"bad-checksums"` - Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` - InputHistogram struct { - Text string `xml:",chardata"` - Style string `xml:"style,attr"` - HistogramType string `xml:"histogram-type"` - UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` - PacketTooBig string `xml:"packet-too-big"` - TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` - Icmp6Echo string `xml:"icmp6-echo"` - Icmp6EchoReply string `xml:"icmp6-echo-reply"` - RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` - NeighborSolicitation string `xml:"neighbor-solicitation"` - NeighborAdvertisement string `xml:"neighbor-advertisement"` - } `xml:"input-histogram"` - HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` - NoRoute string `xml:"no-route"` - AdministrativelyProhibited string `xml:"administratively-prohibited"` - BeyondScope string `xml:"beyond-scope"` - AddressUnreachable string `xml:"address-unreachable"` - PortUnreachable string `xml:"port-unreachable"` - PacketTooBig string `xml:"packet-too-big"` - TimeExceedTransit string `xml:"time-exceed-transit"` - TimeExceedReassembly string `xml:"time-exceed-reassembly"` - ErroneousHeaderField string `xml:"erroneous-header-field"` - UnrecognizedNextHeader string `xml:"unrecognized-next-header"` - UnrecognizedOption string `xml:"unrecognized-option"` - Redirect string `xml:"redirect"` - Unknown string `xml:"unknown"` - Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` - MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` - NdSystemMax string `xml:"nd-system-max"` - NdPublicMax string `xml:"nd-public-max"` - NdIriMax string `xml:"nd-iri-max"` - NdMgtMax string `xml:"nd-mgt-max"` - NdPublicCnt string `xml:"nd-public-cnt"` - NdIriCnt string `xml:"nd-iri-cnt"` - NdMgtCnt string `xml:"nd-mgt-cnt"` - NdSystemDrop string `xml:"nd-system-drop"` - NdPublicDrop string `xml:"nd-public-drop"` - NdIriDrop string `xml:"nd-iri-drop"` - NdMgtDrop string `xml:"nd-mgt-drop"` - Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` - Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` - Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` - Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` - Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` - Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` - Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` - Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` - Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` - Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` - Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` - Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` - Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` - Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` - Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` - Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` - Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` - Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` - Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` - Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` - } `xml:"icmp6"` - Mpls struct { - Text string `xml:",chardata"` - TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` - PacketsForwarded string `xml:"packets-forwarded"` - PacketsDropped string `xml:"packets-dropped"` - PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` - AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` - PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` - PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` - PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` - LspPingPackets string `xml:"lsp-ping-packets"` - PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` - PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` - PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` - PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` - PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` - PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` - PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` - } `xml:"mpls"` - }{ - Ip: struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - }{ - PacketsReceived: 1000, - BadHeaderChecksums: 5, - PacketsWithSizeSmallerThanMinimum: 10, - PacketsWithDataSizeLessThanDatalength: 2, - PacketsWithHeaderLengthLessThanDataSize: 3, - PacketsWithDataLengthLessThanHeaderlength: 1, - PacketsWithIncorrectVersionNumber: 0, - PacketsDestinedToDeadNextHop: 0, - FragmentsReceived: 50, - FragmentsDroppedDueToOutofspaceOrDup: 2, - FragmentsDroppedDueToQueueoverflow: 1, - FragmentsDroppedAfterTimeout: 0, - PacketsReassembledOk: 48, - PacketsForThisHost: 500, - PacketsForUnknownOrUnsupportedProtocol: 5, - PacketsForwarded: 400, - PacketsNotForwardable: 10, - RedirectsSent: 2, - PacketsSentFromThisHost: 800, - PacketsSentWithFabricatedIpHeader: 0, - OutputPacketsDroppedDueToNoBufs: 3, - OutputPacketsDiscardedDueToNoRoute: 1, - OutputDatagramsFragmented: 20, - FragmentsCreated: 40, - DatagramsThatCanNotBeFragmented: 2, - PacketsWithBadOptions: 1, - PacketsWithOptionsHandledWithoutError: 15, - StrictSourceAndRecordRouteOptions: 0, - LooseSourceAndRecordRouteOptions: 2, - RecordRouteOptions: 5, - TimestampOptions: 3, - TimestampAndAddressOptions: 1, - TimestampAndPrespecifiedAddressOptions: 0, - OptionPacketsDroppedDueToRateLimit: 0, - RouterAlertOptions: 4, - MulticastPacketsDropped: 8, - PacketsDropped: 12, - TransitRePacketsDroppedOnMgmtInterface: 0, - PacketsUsedFirstNexthopInEcmpUnilist: 25, - IncomingTtpoipPacketsReceived: 100, - IncomingTtpoipPacketsDropped: 2, - OutgoingTtpoipPacketsSent: 95, - OutgoingTtpoipPacketsDropped: 1, - IncomingRawipPacketsDroppedNoSocketBuffer: 3, - IncomingVirtualNodePacketsDelivered: 200, - }, - }, - Cli: struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - }{ - Banner: "user@router>", - }, + expect: func(t *testing.T, got SystemStatistics) { + ip := got.Statistics.Ip + assert.Equal(t, float64(1000), ip.PacketsReceived) + assert.Equal(t, float64(5), ip.BadHeaderChecksums) + assert.Equal(t, float64(10), ip.PacketsWithSizeSmallerThanMinimum) + assert.Equal(t, float64(2), ip.PacketsWithDataSizeLessThanDatalength) + assert.Equal(t, float64(3), ip.PacketsWithHeaderLengthLessThanDataSize) + assert.Equal(t, float64(1), ip.PacketsWithDataLengthLessThanHeaderlength) + assert.Equal(t, float64(0), ip.PacketsWithIncorrectVersionNumber) + assert.Equal(t, float64(0), ip.PacketsDestinedToDeadNextHop) + assert.Equal(t, float64(50), ip.FragmentsReceived) + assert.Equal(t, float64(2), ip.FragmentsDroppedDueToOutofspaceOrDup) + assert.Equal(t, float64(1), ip.FragmentsDroppedDueToQueueoverflow) + assert.Equal(t, float64(0), ip.FragmentsDroppedAfterTimeout) + assert.Equal(t, float64(48), ip.PacketsReassembledOk) + assert.Equal(t, float64(500), ip.PacketsForThisHost) + assert.Equal(t, float64(5), ip.PacketsForUnknownOrUnsupportedProtocol) + assert.Equal(t, float64(400), ip.PacketsForwarded) + assert.Equal(t, float64(10), ip.PacketsNotForwardable) + assert.Equal(t, float64(2), ip.RedirectsSent) + assert.Equal(t, float64(800), ip.PacketsSentFromThisHost) + assert.Equal(t, float64(0), ip.PacketsSentWithFabricatedIpHeader) + assert.Equal(t, float64(3), ip.OutputPacketsDroppedDueToNoBufs) + assert.Equal(t, float64(1), ip.OutputPacketsDiscardedDueToNoRoute) + assert.Equal(t, float64(20), ip.OutputDatagramsFragmented) + assert.Equal(t, float64(40), ip.FragmentsCreated) + assert.Equal(t, float64(2), ip.DatagramsThatCanNotBeFragmented) + assert.Equal(t, float64(1), ip.PacketsWithBadOptions) + assert.Equal(t, float64(15), ip.PacketsWithOptionsHandledWithoutError) + assert.Equal(t, float64(0), ip.StrictSourceAndRecordRouteOptions) + assert.Equal(t, float64(2), ip.LooseSourceAndRecordRouteOptions) + assert.Equal(t, float64(5), ip.RecordRouteOptions) + assert.Equal(t, float64(3), ip.TimestampOptions) + assert.Equal(t, float64(1), ip.TimestampAndAddressOptions) + assert.Equal(t, float64(0), ip.TimestampAndPrespecifiedAddressOptions) + assert.Equal(t, float64(0), ip.OptionPacketsDroppedDueToRateLimit) + assert.Equal(t, float64(4), ip.RouterAlertOptions) + assert.Equal(t, float64(8), ip.MulticastPacketsDropped) + assert.Equal(t, float64(12), ip.PacketsDropped) + assert.Equal(t, float64(0), ip.TransitRePacketsDroppedOnMgmtInterface) + assert.Equal(t, float64(25), ip.PacketsUsedFirstNexthopInEcmpUnilist) + assert.Equal(t, float64(100), ip.IncomingTtpoipPacketsReceived) + assert.Equal(t, float64(2), ip.IncomingTtpoipPacketsDropped) + assert.Equal(t, float64(95), ip.OutgoingTtpoipPacketsSent) + assert.Equal(t, float64(1), ip.OutgoingTtpoipPacketsDropped) + assert.Equal(t, float64(3), ip.IncomingRawipPacketsDroppedNoSocketBuffer) + assert.Equal(t, float64(200), ip.IncomingVirtualNodePacketsDelivered) + assert.Equal(t, "user@router>", got.Cli.Banner) }, }, { name: "empty_ipv4_statistics", xmlInput: string(IPv4DataCase2), - expected: SystemStatistics{ - Cli: struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - }{ - Banner: "user@router>", - }, + expect: func(t *testing.T, got SystemStatistics) { + assert.Equal(t, "user@router>", got.Cli.Banner) }, }, { name: "high_values_ipv4_statistics", xmlInput: string(IPv4DataCase3), - expected: SystemStatistics{ - Statistics: struct { - Text string `xml:",chardata"` - Tcp struct { - Text string `xml:",chardata"` - PacketsSent float64 `xml:"packets-sent"` - SentDataPackets float64 `xml:"sent-data-packets"` - DataPacketsBytes float64 `xml:"data-packets-bytes"` - SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` - RetransmittedBytes float64 `xml:"retransmitted-bytes"` - SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` - SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` - SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` - SentPacketsDelayed float64 `xml:"sent-packets-delayed"` - SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` - SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` - SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` - SentControlPackets float64 `xml:"sent-control-packets"` - PacketsReceived float64 `xml:"packets-received"` - ReceivedAcks float64 `xml:"received-acks"` - AcksBytes float64 `xml:"acks-bytes"` - ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` - ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` - PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` - InSequenceBytes float64 `xml:"in-sequence-bytes"` - ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` - DuplicateInBytes float64 `xml:"duplicate-in-bytes"` - ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` - ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` - SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` - ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` - OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` - ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` - Bytes float64 `xml:"bytes"` - ReceivedWindowProbes float64 `xml:"received-window-probes"` - ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` - PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` - ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` - ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` - ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` - ConnectionRequests float64 `xml:"connection-requests"` - ConnectionAccepts float64 `xml:"connection-accepts"` - BadConnectionAttempts float64 `xml:"bad-connection-attempts"` - ListenQueueOverflows float64 `xml:"listen-queue-overflows"` - BadRstWindow float64 `xml:"bad-rst-window"` - ConnectionsEstablished float64 `xml:"connections-established"` - ConnectionsClosed float64 `xml:"connections-closed"` - Drops float64 `xml:"drops"` - ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` - ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` - ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` - EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` - SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` - Attempts float64 `xml:"attempts"` - RetransmitTimeouts float64 `xml:"retransmit-timeouts"` - ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` - PersistTimeouts float64 `xml:"persist-timeouts"` - ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` - KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` - KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` - KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` - AckHeaderPredictions float64 `xml:"ack-header-predictions"` - DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` - SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` - Retransmitted float64 `xml:"retransmitted"` - Dupsyn float64 `xml:"dupsyn"` - Dropped float64 `xml:"dropped"` - Completed float64 `xml:"completed"` - BucketOverflow float64 `xml:"bucket-overflow"` - CacheOverflow float64 `xml:"cache-overflow"` - Reset float64 `xml:"reset"` - Stale float64 `xml:"stale"` - Aborted float64 `xml:"aborted"` - Badack float64 `xml:"badack"` - Unreach float64 `xml:"unreach"` - ZoneFailures float64 `xml:"zone-failures"` - CookiesSent float64 `xml:"cookies-sent"` - CookiesReceived float64 `xml:"cookies-received"` - SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` - SegmentRetransmits float64 `xml:"segment-retransmits"` - ByteRetransmits float64 `xml:"byte-retransmits"` - SackOptionsReceived float64 `xml:"sack-options-received"` - SackOpitionsSent float64 `xml:"sack-opitions-sent"` - SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` - AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` - AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` - RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` - OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` - RstPackets float64 `xml:"rst-packets"` - IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` - SendPacketsDropped float64 `xml:"send-packets-dropped"` - RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` - OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` - ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` - ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` - ReceivedMacDropped float64 `xml:"received-mac-dropped"` - ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` - ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` - FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` - ReceivedDosAttack float64 `xml:"received-dos-attack"` - ReceivedBadSynack float64 `xml:"received-bad-synack"` - SyncacheZoneFull float64 `xml:"syncache-zone-full"` - ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` - ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` - ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` - ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` - ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` - ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` - ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` - ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` - ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` - ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` - ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` - OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` - OptionWindowLength float64 `xml:"option-window-length"` - OptionTimestampLength float64 `xml:"option-timestamp-length"` - OptionMd5Length float64 `xml:"option-md5-length"` - OptionAuthLength float64 `xml:"option-auth-length"` - OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` - OptionSackLength float64 `xml:"option-sack-length"` - OptionAuthoptionLength float64 `xml:"option-authoption-length"` - } `xml:"tcp"` - Udp struct { - Text string `xml:",chardata"` - DatagramsReceived float64 `xml:"datagrams-received"` - DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` - DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` - DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` - DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` - BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` - DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` - DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` - DatagramsDelivered float64 `xml:"datagrams-delivered"` - DatagramsOutput float64 `xml:"datagrams-output"` - } `xml:"udp"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - Icmp struct { - Text string `xml:",chardata"` - DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` - CallsToIcmpError string `xml:"calls-to-icmp-error"` - ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` - Histogram []struct { - Text string `xml:",chardata"` - TypeOfHistogram string `xml:"type-of-histogram"` - IcmpEchoReply string `xml:"icmp-echo-reply"` - DestinationUnreachable string `xml:"destination-unreachable"` - IcmpEcho string `xml:"icmp-echo"` - TimeStampReply string `xml:"time-stamp-reply"` - TimeExceeded string `xml:"time-exceeded"` - TimeStamp string `xml:"time-stamp"` - AddressMaskRequest string `xml:"address-mask-request"` - AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` - } `xml:"histogram"` - MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` - MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` - MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` - MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` - MessagesWithBadLength string `xml:"messages-with-bad-length"` - EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` - TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` - MessageResponsesGenerated string `xml:"message-responses-generated"` - } `xml:"icmp"` - Arp struct { - Text string `xml:",chardata"` - DatagramsReceived string `xml:"datagrams-received"` - ArpRequestsReceived string `xml:"arp-requests-received"` - ArpRepliesReceived string `xml:"arp-replies-received"` - ResolutionRequestReceived string `xml:"resolution-request-received"` - ResolutionRequestDropped string `xml:"resolution-request-dropped"` - UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` - RestrictedProxyRequests string `xml:"restricted-proxy-requests"` - ReceivedProxyRequests string `xml:"received-proxy-requests"` - ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` - RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` - DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` - DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` - DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` - DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` - DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` - DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` - DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` - DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` - DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` - DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` - DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` - DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` - DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` - PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` - PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` - ArpRequestsSent string `xml:"arp-requests-sent"` - ArpRepliesSent string `xml:"arp-replies-sent"` - RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` - RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` - RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` - RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` - RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` - NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` - RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` - RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` - RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` - ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` - ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` - ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` - ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` - ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` - SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` - ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` - ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` - ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` - ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` - GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` - ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` - ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` - ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` - ArpSystemMax string `xml:"arp-system-max"` - ArpPublicMax string `xml:"arp-public-max"` - ArpIriMax string `xml:"arp-iri-max"` - ArpMgtMax string `xml:"arp-mgt-max"` - ArpPublicCnt string `xml:"arp-public-cnt"` - ArpIriCnt string `xml:"arp-iri-cnt"` - ArpMgtCnt string `xml:"arp-mgt-cnt"` - ArpSystemDrop string `xml:"arp-system-drop"` - ArpPublicDrop string `xml:"arp-public-drop"` - ArpIriDrop string `xml:"arp-iri-drop"` - ArpMgtDrop string `xml:"arp-mgt-drop"` - } `xml:"arp"` - Ip6 struct { - Text string `xml:",chardata"` - TotalPacketsReceived float64 `xml:"total-packets-received"` - Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` - PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` - Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` - Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` - Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` - DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` - Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` - FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` - Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` - Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` - Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` - Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` - Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` - Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` - Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` - Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` - Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` - Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` - Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` - Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` - PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` - MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` - Histogram float64 `xml:"histogram"` - Ip6nhTcp float64 `xml:"ip6nh-tcp"` - Ip6nhUdp float64 `xml:"ip6nh-udp"` - Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` - PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` - TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` - PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` - FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` - HeaderType []struct { - Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` - LinkLocals float64 `xml:"link-locals"` - Globals float64 `xml:"globals"` - AddressScope float64 `xml:"address-scope"` - HexValue float64 `xml:"hex-value"` - } `xml:"header-type"` - ForwardCacheHit float64 `xml:"forward-cache-hit"` - ForwardCacheMiss float64 `xml:"forward-cache-miss"` - Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` - Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` - Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` - PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` - TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` - PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` - } `xml:"ip6"` - Icmp6 struct { - Text string `xml:",chardata"` - ProtocolName string `xml:"protocol-name"` - CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` - ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` - ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` - OutputHistogram struct { - Text string `xml:",chardata"` - Style string `xml:"style,attr"` - HistogramType string `xml:"histogram-type"` - UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` - Icmp6Echo string `xml:"icmp6-echo"` - Icmp6EchoReply string `xml:"icmp6-echo-reply"` - NeighborSolicitation string `xml:"neighbor-solicitation"` - NeighborAdvertisement string `xml:"neighbor-advertisement"` - } `xml:"output-histogram"` - Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` - MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` - BadChecksums string `xml:"bad-checksums"` - Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` - InputHistogram struct { - Text string `xml:",chardata"` - Style string `xml:"style,attr"` - HistogramType string `xml:"histogram-type"` - UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` - PacketTooBig string `xml:"packet-too-big"` - TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` - Icmp6Echo string `xml:"icmp6-echo"` - Icmp6EchoReply string `xml:"icmp6-echo-reply"` - RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` - NeighborSolicitation string `xml:"neighbor-solicitation"` - NeighborAdvertisement string `xml:"neighbor-advertisement"` - } `xml:"input-histogram"` - HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` - NoRoute string `xml:"no-route"` - AdministrativelyProhibited string `xml:"administratively-prohibited"` - BeyondScope string `xml:"beyond-scope"` - AddressUnreachable string `xml:"address-unreachable"` - PortUnreachable string `xml:"port-unreachable"` - PacketTooBig string `xml:"packet-too-big"` - TimeExceedTransit string `xml:"time-exceed-transit"` - TimeExceedReassembly string `xml:"time-exceed-reassembly"` - ErroneousHeaderField string `xml:"erroneous-header-field"` - UnrecognizedNextHeader string `xml:"unrecognized-next-header"` - UnrecognizedOption string `xml:"unrecognized-option"` - Redirect string `xml:"redirect"` - Unknown string `xml:"unknown"` - Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` - MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` - NdSystemMax string `xml:"nd-system-max"` - NdPublicMax string `xml:"nd-public-max"` - NdIriMax string `xml:"nd-iri-max"` - NdMgtMax string `xml:"nd-mgt-max"` - NdPublicCnt string `xml:"nd-public-cnt"` - NdIriCnt string `xml:"nd-iri-cnt"` - NdMgtCnt string `xml:"nd-mgt-cnt"` - NdSystemDrop string `xml:"nd-system-drop"` - NdPublicDrop string `xml:"nd-public-drop"` - NdIriDrop string `xml:"nd-iri-drop"` - NdMgtDrop string `xml:"nd-mgt-drop"` - Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` - Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` - Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` - Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` - Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` - Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` - Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` - Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` - Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` - Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` - Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` - Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` - Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` - Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` - Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` - Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` - Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` - Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` - Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` - Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` - } `xml:"icmp6"` - Mpls struct { - Text string `xml:",chardata"` - TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` - PacketsForwarded string `xml:"packets-forwarded"` - PacketsDropped string `xml:"packets-dropped"` - PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` - AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` - PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` - PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` - PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` - LspPingPackets string `xml:"lsp-ping-packets"` - PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` - PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` - PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` - PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` - PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` - PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` - PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` - } `xml:"mpls"` - }{ - Ip: struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - }{ - PacketsReceived: 999999999, - BadHeaderChecksums: 12345, - PacketsWithSizeSmallerThanMinimum: 54321, - PacketsWithDataSizeLessThanDatalength: 1111, - PacketsWithHeaderLengthLessThanDataSize: 2222, - PacketsWithDataLengthLessThanHeaderlength: 3333, - PacketsWithIncorrectVersionNumber: 4444, - PacketsDestinedToDeadNextHop: 5555, - FragmentsReceived: 888888, - FragmentsDroppedDueToOutofspaceOrDup: 6666, - FragmentsDroppedDueToQueueoverflow: 7777, - FragmentsDroppedAfterTimeout: 8888, - PacketsReassembledOk: 777777, - PacketsForThisHost: 555555, - PacketsForUnknownOrUnsupportedProtocol: 9999, - PacketsForwarded: 444444, - PacketsNotForwardable: 11111, - RedirectsSent: 12121, - PacketsSentFromThisHost: 666666, - PacketsSentWithFabricatedIpHeader: 13131, - OutputPacketsDroppedDueToNoBufs: 14141, - OutputPacketsDiscardedDueToNoRoute: 15151, - OutputDatagramsFragmented: 16161, - FragmentsCreated: 17171, - DatagramsThatCanNotBeFragmented: 18181, - PacketsWithBadOptions: 19191, - PacketsWithOptionsHandledWithoutError: 20202, - StrictSourceAndRecordRouteOptions: 21212, - LooseSourceAndRecordRouteOptions: 22222, - RecordRouteOptions: 23232, - TimestampOptions: 24242, - TimestampAndAddressOptions: 25252, - TimestampAndPrespecifiedAddressOptions: 26262, - OptionPacketsDroppedDueToRateLimit: 27272, - RouterAlertOptions: 28282, - MulticastPacketsDropped: 29292, - PacketsDropped: 30303, - TransitRePacketsDroppedOnMgmtInterface: 31313, - PacketsUsedFirstNexthopInEcmpUnilist: 32323, - IncomingTtpoipPacketsReceived: 33333, - IncomingTtpoipPacketsDropped: 34343, - OutgoingTtpoipPacketsSent: 35353, - OutgoingTtpoipPacketsDropped: 36363, - IncomingRawipPacketsDroppedNoSocketBuffer: 37373, - IncomingVirtualNodePacketsDelivered: 38383, - }, - }, - Cli: struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - }{ - Banner: "admin@high-traffic-router>", - }, + expect: func(t *testing.T, got SystemStatistics) { + ip := got.Statistics.Ip + assert.Equal(t, float64(999999999), ip.PacketsReceived) + assert.Equal(t, float64(12345), ip.BadHeaderChecksums) + assert.Equal(t, float64(54321), ip.PacketsWithSizeSmallerThanMinimum) + assert.Equal(t, float64(1111), ip.PacketsWithDataSizeLessThanDatalength) + assert.Equal(t, float64(2222), ip.PacketsWithHeaderLengthLessThanDataSize) + assert.Equal(t, float64(3333), ip.PacketsWithDataLengthLessThanHeaderlength) + assert.Equal(t, float64(4444), ip.PacketsWithIncorrectVersionNumber) + assert.Equal(t, float64(5555), ip.PacketsDestinedToDeadNextHop) + assert.Equal(t, float64(888888), ip.FragmentsReceived) + assert.Equal(t, float64(6666), ip.FragmentsDroppedDueToOutofspaceOrDup) + assert.Equal(t, float64(7777), ip.FragmentsDroppedDueToQueueoverflow) + assert.Equal(t, float64(8888), ip.FragmentsDroppedAfterTimeout) + assert.Equal(t, float64(777777), ip.PacketsReassembledOk) + assert.Equal(t, float64(555555), ip.PacketsForThisHost) + assert.Equal(t, float64(9999), ip.PacketsForUnknownOrUnsupportedProtocol) + assert.Equal(t, float64(444444), ip.PacketsForwarded) + assert.Equal(t, float64(11111), ip.PacketsNotForwardable) + assert.Equal(t, float64(12121), ip.RedirectsSent) + assert.Equal(t, float64(666666), ip.PacketsSentFromThisHost) + assert.Equal(t, float64(13131), ip.PacketsSentWithFabricatedIpHeader) + assert.Equal(t, float64(14141), ip.OutputPacketsDroppedDueToNoBufs) + assert.Equal(t, float64(15151), ip.OutputPacketsDiscardedDueToNoRoute) + assert.Equal(t, float64(16161), ip.OutputDatagramsFragmented) + assert.Equal(t, float64(17171), ip.FragmentsCreated) + assert.Equal(t, float64(18181), ip.DatagramsThatCanNotBeFragmented) + assert.Equal(t, float64(19191), ip.PacketsWithBadOptions) + assert.Equal(t, float64(20202), ip.PacketsWithOptionsHandledWithoutError) + assert.Equal(t, float64(21212), ip.StrictSourceAndRecordRouteOptions) + assert.Equal(t, float64(22222), ip.LooseSourceAndRecordRouteOptions) + assert.Equal(t, float64(23232), ip.RecordRouteOptions) + assert.Equal(t, float64(24242), ip.TimestampOptions) + assert.Equal(t, float64(25252), ip.TimestampAndAddressOptions) + assert.Equal(t, float64(26262), ip.TimestampAndPrespecifiedAddressOptions) + assert.Equal(t, float64(27272), ip.OptionPacketsDroppedDueToRateLimit) + assert.Equal(t, float64(28282), ip.RouterAlertOptions) + assert.Equal(t, float64(29292), ip.MulticastPacketsDropped) + assert.Equal(t, float64(30303), ip.PacketsDropped) + assert.Equal(t, float64(31313), ip.TransitRePacketsDroppedOnMgmtInterface) + assert.Equal(t, float64(32323), ip.PacketsUsedFirstNexthopInEcmpUnilist) + assert.Equal(t, float64(33333), ip.IncomingTtpoipPacketsReceived) + assert.Equal(t, float64(34343), ip.IncomingTtpoipPacketsDropped) + assert.Equal(t, float64(35353), ip.OutgoingTtpoipPacketsSent) + assert.Equal(t, float64(36363), ip.OutgoingTtpoipPacketsDropped) + assert.Equal(t, float64(37373), ip.IncomingRawipPacketsDroppedNoSocketBuffer) + assert.Equal(t, float64(38383), ip.IncomingVirtualNodePacketsDelivered) + assert.Equal(t, "admin@high-traffic-router>", got.Cli.Banner) }, }, } - for _, tt := range testsIPV4 { - t.Run(tt.name, func(t *testing.T) { + for _, tc := range testsIPV4 { + t.Run(tc.name, func(t *testing.T) { var result SystemStatistics - err := xml.Unmarshal([]byte(tt.xmlInput), &result) + err := xml.Unmarshal([]byte(tc.xmlInput), &result) assert.NoError(t, err, "unmarshal should not return error") + tc.expect(t, result) + }) + } +} + +// Tests for the IPv6 sub-structure (Ip6) of SystemStatistics. We use inline XML to focus on Ip6. +func TestStatisticsIPv6Unmarshaling(t *testing.T) { + IPv6XMLDataCase1, _ := os.Open("testsFiles/IPV6/ipv6TestDataCase1.xml") + IPv6DataCase1, _ := ioutil.ReadAll(IPv6XMLDataCase1) + fmt.Printf("%v", string(IPv6DataCase1)) + type testCase struct { + name string + xmlInput string + expect func(t *testing.T, got SystemStatistics) + } + + completeIPv6 := ` + + + + 100 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + + default + 30 + 31 + 0 + 0 + + + policy + 32 + 33 + 0 + 0 + + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + + + user@router> +` - // Test all IP struct fields - assert.Equal(t, tt.expected.Statistics.Ip.PacketsReceived, result.Statistics.Ip.PacketsReceived, "PacketsReceived should match") - assert.Equal(t, tt.expected.Statistics.Ip.BadHeaderChecksums, result.Statistics.Ip.BadHeaderChecksums, "BadHeaderChecksums should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, result.Statistics.Ip.PacketsWithSizeSmallerThanMinimum, "PacketsWithSizeSmallerThanMinimum should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, result.Statistics.Ip.PacketsWithDataSizeLessThanDatalength, "PacketsWithDataSizeLessThanDatalength should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, result.Statistics.Ip.PacketsWithHeaderLengthLessThanDataSize, "PacketsWithHeaderLengthLessThanDataSize should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, result.Statistics.Ip.PacketsWithDataLengthLessThanHeaderlength, "PacketsWithDataLengthLessThanHeaderlength should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithIncorrectVersionNumber, result.Statistics.Ip.PacketsWithIncorrectVersionNumber, "PacketsWithIncorrectVersionNumber should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsDestinedToDeadNextHop, result.Statistics.Ip.PacketsDestinedToDeadNextHop, "PacketsDestinedToDeadNextHop should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsReceived, result.Statistics.Ip.FragmentsReceived, "FragmentsReceived should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, result.Statistics.Ip.FragmentsDroppedDueToOutofspaceOrDup, "FragmentsDroppedDueToOutofspaceOrDup should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, result.Statistics.Ip.FragmentsDroppedDueToQueueoverflow, "FragmentsDroppedDueToQueueoverflow should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsDroppedAfterTimeout, result.Statistics.Ip.FragmentsDroppedAfterTimeout, "FragmentsDroppedAfterTimeout should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsReassembledOk, result.Statistics.Ip.PacketsReassembledOk, "PacketsReassembledOk should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsForThisHost, result.Statistics.Ip.PacketsForThisHost, "PacketsForThisHost should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, result.Statistics.Ip.PacketsForUnknownOrUnsupportedProtocol, "PacketsForUnknownOrUnsupportedProtocol should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsForwarded, result.Statistics.Ip.PacketsForwarded, "PacketsForwarded should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsNotForwardable, result.Statistics.Ip.PacketsNotForwardable, "PacketsNotForwardable should match") - assert.Equal(t, tt.expected.Statistics.Ip.RedirectsSent, result.Statistics.Ip.RedirectsSent, "RedirectsSent should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentFromThisHost, result.Statistics.Ip.PacketsSentFromThisHost, "PacketsSentFromThisHost should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsSentWithFabricatedIpHeader, result.Statistics.Ip.PacketsSentWithFabricatedIpHeader, "PacketsSentWithFabricatedIpHeader should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, result.Statistics.Ip.OutputPacketsDroppedDueToNoBufs, "OutputPacketsDroppedDueToNoBufs should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, result.Statistics.Ip.OutputPacketsDiscardedDueToNoRoute, "OutputPacketsDiscardedDueToNoRoute should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutputDatagramsFragmented, result.Statistics.Ip.OutputDatagramsFragmented, "OutputDatagramsFragmented should match") - assert.Equal(t, tt.expected.Statistics.Ip.FragmentsCreated, result.Statistics.Ip.FragmentsCreated, "FragmentsCreated should match") - assert.Equal(t, tt.expected.Statistics.Ip.DatagramsThatCanNotBeFragmented, result.Statistics.Ip.DatagramsThatCanNotBeFragmented, "DatagramsThatCanNotBeFragmented should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithBadOptions, result.Statistics.Ip.PacketsWithBadOptions, "PacketsWithBadOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsWithOptionsHandledWithoutError, result.Statistics.Ip.PacketsWithOptionsHandledWithoutError, "PacketsWithOptionsHandledWithoutError should match") - assert.Equal(t, tt.expected.Statistics.Ip.StrictSourceAndRecordRouteOptions, result.Statistics.Ip.StrictSourceAndRecordRouteOptions, "StrictSourceAndRecordRouteOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.LooseSourceAndRecordRouteOptions, result.Statistics.Ip.LooseSourceAndRecordRouteOptions, "LooseSourceAndRecordRouteOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.RecordRouteOptions, result.Statistics.Ip.RecordRouteOptions, "RecordRouteOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.TimestampOptions, result.Statistics.Ip.TimestampOptions, "TimestampOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndAddressOptions, result.Statistics.Ip.TimestampAndAddressOptions, "TimestampAndAddressOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, result.Statistics.Ip.TimestampAndPrespecifiedAddressOptions, "TimestampAndPrespecifiedAddressOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, result.Statistics.Ip.OptionPacketsDroppedDueToRateLimit, "OptionPacketsDroppedDueToRateLimit should match") - assert.Equal(t, tt.expected.Statistics.Ip.RouterAlertOptions, result.Statistics.Ip.RouterAlertOptions, "RouterAlertOptions should match") - assert.Equal(t, tt.expected.Statistics.Ip.MulticastPacketsDropped, result.Statistics.Ip.MulticastPacketsDropped, "MulticastPacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsDropped, result.Statistics.Ip.PacketsDropped, "PacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, result.Statistics.Ip.TransitRePacketsDroppedOnMgmtInterface, "TransitRePacketsDroppedOnMgmtInterface should match") - assert.Equal(t, tt.expected.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, result.Statistics.Ip.PacketsUsedFirstNexthopInEcmpUnilist, "PacketsUsedFirstNexthopInEcmpUnilist should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsReceived, result.Statistics.Ip.IncomingTtpoipPacketsReceived, "IncomingTtpoipPacketsReceived should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingTtpoipPacketsDropped, result.Statistics.Ip.IncomingTtpoipPacketsDropped, "IncomingTtpoipPacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsSent, result.Statistics.Ip.OutgoingTtpoipPacketsSent, "OutgoingTtpoipPacketsSent should match") - assert.Equal(t, tt.expected.Statistics.Ip.OutgoingTtpoipPacketsDropped, result.Statistics.Ip.OutgoingTtpoipPacketsDropped, "OutgoingTtpoipPacketsDropped should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, result.Statistics.Ip.IncomingRawipPacketsDroppedNoSocketBuffer, "IncomingRawipPacketsDroppedNoSocketBuffer should match") - assert.Equal(t, tt.expected.Statistics.Ip.IncomingVirtualNodePacketsDelivered, result.Statistics.Ip.IncomingVirtualNodePacketsDelivered, "IncomingVirtualNodePacketsDelivered should match") + tests := []testCase{ + { + name: "complete_ipv6_statistics", + xmlInput: completeIPv6, + expect: func(t *testing.T, got SystemStatistics) { + ip6 := got.Statistics.Ip6 + assert.Equal(t, float64(100), ip6.TotalPacketsReceived) + assert.Equal(t, float64(1), ip6.Ip6PacketsWithSizeSmallerThanMinimum) + assert.Equal(t, float64(2), ip6.PacketsWithDatasizeLessThanDataLength) + assert.Equal(t, float64(3), ip6.Ip6PacketsWithBadOptions) + assert.Equal(t, float64(4), ip6.Ip6PacketsWithIncorrectVersionNumber) + assert.Equal(t, float64(5), ip6.Ip6FragmentsReceived) + assert.Equal(t, float64(6), ip6.DuplicateOrOutOfSpaceFragmentsDropped) + assert.Equal(t, float64(7), ip6.Ip6FragmentsDroppedAfterTimeout) + assert.Equal(t, float64(8), ip6.FragmentsThatExceededLimit) + assert.Equal(t, float64(9), ip6.Ip6PacketsReassembledOk) + assert.Equal(t, float64(10), ip6.Ip6PacketsForThisHost) + assert.Equal(t, float64(11), ip6.Ip6PacketsForwarded) + assert.Equal(t, float64(12), ip6.Ip6PacketsNotForwardable) + assert.Equal(t, float64(13), ip6.Ip6RedirectsSent) + assert.Equal(t, float64(14), ip6.Ip6PacketsSentFromThisHost) + assert.Equal(t, float64(15), ip6.Ip6PacketsSentWithFabricatedIpHeader) + assert.Equal(t, float64(16), ip6.Ip6OutputPacketsDroppedDueToNoBufs) + assert.Equal(t, float64(17), ip6.Ip6OutputPacketsDiscardedDueToNoRoute) + assert.Equal(t, float64(18), ip6.Ip6OutputDatagramsFragmented) + assert.Equal(t, float64(19), ip6.Ip6FragmentsCreated) + assert.Equal(t, float64(20), ip6.Ip6DatagramsThatCanNotBeFragmented) + assert.Equal(t, float64(21), ip6.PacketsThatViolatedScopeRules) + assert.Equal(t, float64(22), ip6.MulticastPacketsWhichWeDoNotJoin) + assert.Equal(t, float64(23), ip6.Ip6nhTcp) + assert.Equal(t, float64(24), ip6.Ip6nhUdp) + assert.Equal(t, float64(25), ip6.Ip6nhIcmp6) + assert.Equal(t, float64(26), ip6.PacketsWhoseHeadersAreNotContinuous) + assert.Equal(t, float64(27), ip6.TunnelingPacketsThatCanNotFindGif) + assert.Equal(t, float64(28), ip6.PacketsDiscardedDueToTooMayHeaders) + assert.Equal(t, float64(29), ip6.FailuresOfSourceAddressSelection) + assert.Equal(t, 2, len(ip6.HeaderType)) + var defLink, defGlob, polLink, polGlob float64 + for _, h := range ip6.HeaderType { + switch h.HeaderForSourceAddressSelection { + case "default": + defLink = h.LinkLocals + defGlob = h.Globals + case "policy": + polLink = h.LinkLocals + polGlob = h.Globals + } + } + assert.Equal(t, float64(30), defLink) + assert.Equal(t, float64(31), defGlob) + assert.Equal(t, float64(32), polLink) + assert.Equal(t, float64(33), polGlob) + assert.Equal(t, float64(34), ip6.ForwardCacheHit) + assert.Equal(t, float64(35), ip6.ForwardCacheMiss) + assert.Equal(t, float64(36), ip6.Ip6PacketsDestinedToDeadNextHop) + assert.Equal(t, float64(37), ip6.Ip6OptionPacketsDroppedDueToRateLimit) + assert.Equal(t, float64(38), ip6.Ip6PacketsDropped) + assert.Equal(t, float64(39), ip6.PacketsDroppedDueToBadProtocol) + assert.Equal(t, float64(40), ip6.TransitRePacketDroppedOnMgmtInterface) + assert.Equal(t, float64(41), ip6.PacketUsedFirstNexthopInEcmpUnilist) + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + var got SystemStatistics + err := xml.Unmarshal([]byte(tc.xmlInput), &got) + assert.NoError(t, err, "unmarshal should not return error") + tc.expect(t, got) }) } } diff --git a/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml new file mode 100644 index 00000000..1d876ff8 --- /dev/null +++ b/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml @@ -0,0 +1,59 @@ + + + + 100 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + + default + 30 + 31 + 0 + 0 + + + policy + 32 + 33 + 0 + 0 + + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + + + user@router> + \ No newline at end of file From 44dc7fa800a12f63d9368b826a2ae9a03460596f Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Tue, 2 Sep 2025 09:57:29 +0200 Subject: [PATCH 14/27] added ipv6 tests --- pkg/features/systemstatistics/rpc_test.go | 70 +---------------------- 1 file changed, 3 insertions(+), 67 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index f25700df..481d2a63 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,7 +2,6 @@ package systemstatistics import ( "encoding/xml" - "fmt" "io/ioutil" "os" "testing" @@ -152,80 +151,17 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { // Tests for the IPv6 sub-structure (Ip6) of SystemStatistics. We use inline XML to focus on Ip6. func TestStatisticsIPv6Unmarshaling(t *testing.T) { - IPv6XMLDataCase1, _ := os.Open("testsFiles/IPV6/ipv6TestDataCase1.xml") + IPv6XMLDataCase1, _ := os.Open("testsFiles/IPv6/ipv6TestDataCase1.xml") IPv6DataCase1, _ := ioutil.ReadAll(IPv6XMLDataCase1) - fmt.Printf("%v", string(IPv6DataCase1)) type testCase struct { name string xmlInput string expect func(t *testing.T, got SystemStatistics) } - - completeIPv6 := ` - - - - 100 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - - default - 30 - 31 - 0 - 0 - - - policy - 32 - 33 - 0 - 0 - - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - - - user@router> -` - tests := []testCase{ { - name: "complete_ipv6_statistics", - xmlInput: completeIPv6, + name: "complete_ipv6_statistics", + xmlInput: string(IPv6DataCase1), expect: func(t *testing.T, got SystemStatistics) { ip6 := got.Statistics.Ip6 assert.Equal(t, float64(100), ip6.TotalPacketsReceived) From c486f2194fefdc1bfe276ee64f84d79e1c0a2198 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Tue, 2 Sep 2025 11:39:18 +0200 Subject: [PATCH 15/27] added udp tests --- pkg/features/systemstatistics/rpc_test.go | 42 +++++++++++++++++++ .../testsFiles/UDP/UDPTestDataCase1.xml | 17 ++++++++ 2 files changed, 59 insertions(+) create mode 100644 pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 481d2a63..f156340c 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -231,3 +231,45 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { }) } } + +func TestStatisticsUDPUnmarshaling(t *testing.T) { + UDPXMLDataCase1, _ := os.Open("testsFiles/UDP/UDPTestDataCase1.xml") + UDPDataCase1, _ := ioutil.ReadAll(UDPXMLDataCase1) + type testCase struct { + name string + xmlInput string + expect func(t *testing.T, got SystemStatistics) + } + + tests := []testCase{ + { + name: "complete_udp_statistics", + xmlInput: string(UDPDataCase1), + expect: func(t *testing.T, got SystemStatistics) { + udp := got.Statistics.Udp + assert.Equal(t, float64(100), udp.DatagramsReceived) + assert.Equal(t, float64(1), udp.DatagramsWithIncompleteHeader) + assert.Equal(t, float64(2), udp.DatagramsWithBadDatalengthField) + assert.Equal(t, float64(3), udp.DatagramsWithBadChecksum) + assert.Equal(t, float64(4), udp.DatagramsDroppedDueToNoSocket) + assert.Equal(t, float64(5), udp.BroadcastOrMulticastDatagramsDroppedDueToNoSocket) + assert.Equal(t, float64(6), udp.DatagramsDroppedDueToFullSocketBuffers) + assert.Equal(t, float64(7), udp.DatagramsNotForHashedPcb) + assert.Equal(t, float64(8), udp.DatagramsDelivered) + assert.Equal(t, float64(9), udp.DatagramsOutput) + assert.Equal(t, "user@router>", got.Cli.Banner) + }, + }, + } + + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + var got SystemStatistics + err := xml.Unmarshal([]byte(tc.xmlInput), &got) + assert.NoError(t, err, "unmarshal should not return error") + tc.expect(t, got) + }) + } +} + diff --git a/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml new file mode 100644 index 00000000..721a8c9f --- /dev/null +++ b/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml @@ -0,0 +1,17 @@ + + + + 100 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + + user@router> + \ No newline at end of file From c7ec81292ff90bc5789b7a8117932d9fd44adb5d Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Tue, 2 Sep 2025 11:56:44 +0200 Subject: [PATCH 16/27] added tests for TCP --- pkg/features/systemstatistics/rpc_test.go | 61 +++++++++ .../testsFiles/TCP/TCPTestDataCase1.xml | 123 ++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index f156340c..a800879a 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -273,3 +273,64 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { } } +func TestStatisticsTCPUnmarshaling(t *testing.T) { + TCPXMLDataCase1, _ := os.Open("testsFiles/TCP/TCPTestDataCase1.xml") + TCPDataCase1, _ := ioutil.ReadAll(TCPXMLDataCase1) + type testCase struct { + name string + xmlInput string + expect func(t *testing.T, got SystemStatistics) + } + + tests := []testCase{ + { + name: "complete_tcp_statistics", + xmlInput: string(TCPDataCase1), + expect: func(t *testing.T, got SystemStatistics) { + tcp := got.Statistics.Tcp + assert.Equal(t, float64(1000), tcp.PacketsSent) + assert.Equal(t, float64(900), tcp.SentDataPackets) + assert.Equal(t, float64(123456), tcp.DataPacketsBytes) + assert.Equal(t, float64(10), tcp.SentDataPacketsRetransmitted) + assert.Equal(t, float64(2048), tcp.RetransmittedBytes) + assert.Equal(t, float64(50), tcp.SentAckOnlyPackets) + assert.Equal(t, float64(1100), tcp.PacketsReceived) + assert.Equal(t, float64(980), tcp.ReceivedAcks) + assert.Equal(t, float64(654321), tcp.AcksBytes) + assert.Equal(t, float64(1005), tcp.PacketsReceivedInSequence) + assert.Equal(t, float64(222333), tcp.Bytes) + assert.Equal(t, float64(40), tcp.ConnectionRequests) + assert.Equal(t, float64(39), tcp.ConnectionAccepts) + assert.Equal(t, float64(2), tcp.BadConnectionAttempts) + assert.Equal(t, float64(1), tcp.ListenQueueOverflows) + assert.Equal(t, float64(38), tcp.ConnectionsEstablished) + assert.Equal(t, float64(30), tcp.ConnectionsClosed) + assert.Equal(t, float64(3), tcp.Drops) + assert.Equal(t, float64(44), tcp.Attempts) + assert.Equal(t, float64(6), tcp.RetransmitTimeouts) + assert.Equal(t, float64(5), tcp.KeepaliveTimeouts) + assert.Equal(t, float64(15), tcp.KeepaliveProbesSent) + assert.Equal(t, float64(2), tcp.KeepaliveConnectionsDropped) + assert.Equal(t, float64(12), tcp.RstPackets) + assert.Equal(t, float64(7), tcp.SendPacketsDropped) + assert.Equal(t, float64(6), tcp.RcvPacketsDropped) + assert.Equal(t, float64(5), tcp.OutgoingSegmentsDropped) + assert.Equal(t, float64(20), tcp.OptionMaxsegmentLength) + assert.Equal(t, float64(10), tcp.OptionWindowLength) + assert.Equal(t, float64(12), tcp.OptionTimestampLength) + assert.Equal(t, "user@router>", got.Cli.Banner) + }, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + var got SystemStatistics + err := xml.Unmarshal([]byte(tc.xmlInput), &got) + assert.NoError(t, err, "unmarshal should not return error") + tc.expect(t, got) + }) + } +} + + diff --git a/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml new file mode 100644 index 00000000..e1ed6c55 --- /dev/null +++ b/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml @@ -0,0 +1,123 @@ + + + + 1000 + 900 + 123456 + 10 + 2048 + 50 + 5 + 2 + 3 + 4 + 7 + 1100 + 980 + 654321 + 8 + 1 + 1005 + 111222 + 6 + 777 + 4 + 3 + 88 + 9 + 999 + 2 + 222333 + 5 + 6 + 1 + 2 + 3 + 4 + 40 + 39 + 2 + 1 + 0 + 38 + 30 + 3 + 12 + 11 + 10 + 1 + 25 + 44 + 6 + 1 + 2 + 1 + 5 + 15 + 2 + 100 + 200 + 12 + 8 + 1 + 2 + 37 + 0 + 0 + 4 + 0 + 1 + 0 + 0 + 0 + 5 + 6 + 3 + 9 + 1024 + 7 + 6 + 0 + 2 + 1 + 3 + 4 + 12 + 0 + 7 + 6 + 5 + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + 20 + 10 + 12 + 0 + 0 + 8 + 16 + 0 + + + user@router> +` \ No newline at end of file From b526a09290d78d2290e216588c7cdeeab25e31d8 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Tue, 2 Sep 2025 14:04:48 +0200 Subject: [PATCH 17/27] updated tests for TCP --- pkg/features/systemstatistics/rpc_test.go | 141 +++++++++--- .../testsFiles/TCP/TCPTestDataCase1.xml | 216 +++++++++--------- 2 files changed, 219 insertions(+), 138 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index a800879a..cbc343be 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -160,7 +160,7 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { } tests := []testCase{ { - name: "complete_ipv6_statistics", + name: "complete_ipv6_statistics", xmlInput: string(IPv6DataCase1), expect: func(t *testing.T, got SystemStatistics) { ip6 := got.Statistics.Ip6 @@ -243,7 +243,7 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { tests := []testCase{ { - name: "complete_udp_statistics", + name: "complete_udp_statistics", xmlInput: string(UDPDataCase1), expect: func(t *testing.T, got SystemStatistics) { udp := got.Statistics.Udp @@ -262,7 +262,6 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { }, } - for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { var got SystemStatistics @@ -284,7 +283,7 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { tests := []testCase{ { - name: "complete_tcp_statistics", + name: "complete_tcp_statistics", xmlInput: string(TCPDataCase1), expect: func(t *testing.T, got SystemStatistics) { tcp := got.Statistics.Tcp @@ -294,30 +293,114 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { assert.Equal(t, float64(10), tcp.SentDataPacketsRetransmitted) assert.Equal(t, float64(2048), tcp.RetransmittedBytes) assert.Equal(t, float64(50), tcp.SentAckOnlyPackets) - assert.Equal(t, float64(1100), tcp.PacketsReceived) - assert.Equal(t, float64(980), tcp.ReceivedAcks) - assert.Equal(t, float64(654321), tcp.AcksBytes) - assert.Equal(t, float64(1005), tcp.PacketsReceivedInSequence) - assert.Equal(t, float64(222333), tcp.Bytes) - assert.Equal(t, float64(40), tcp.ConnectionRequests) - assert.Equal(t, float64(39), tcp.ConnectionAccepts) - assert.Equal(t, float64(2), tcp.BadConnectionAttempts) - assert.Equal(t, float64(1), tcp.ListenQueueOverflows) - assert.Equal(t, float64(38), tcp.ConnectionsEstablished) - assert.Equal(t, float64(30), tcp.ConnectionsClosed) - assert.Equal(t, float64(3), tcp.Drops) - assert.Equal(t, float64(44), tcp.Attempts) - assert.Equal(t, float64(6), tcp.RetransmitTimeouts) - assert.Equal(t, float64(5), tcp.KeepaliveTimeouts) - assert.Equal(t, float64(15), tcp.KeepaliveProbesSent) - assert.Equal(t, float64(2), tcp.KeepaliveConnectionsDropped) - assert.Equal(t, float64(12), tcp.RstPackets) - assert.Equal(t, float64(7), tcp.SendPacketsDropped) - assert.Equal(t, float64(6), tcp.RcvPacketsDropped) - assert.Equal(t, float64(5), tcp.OutgoingSegmentsDropped) - assert.Equal(t, float64(20), tcp.OptionMaxsegmentLength) - assert.Equal(t, float64(10), tcp.OptionWindowLength) - assert.Equal(t, float64(12), tcp.OptionTimestampLength) + assert.Equal(t, float64(51), tcp.SentPacketsDelayed) + assert.Equal(t, float64(52), tcp.SentUrgOnlyPackets) + assert.Equal(t, float64(53), tcp.SentWindowProbePackets) + assert.Equal(t, float64(54), tcp.SentWindowUpdatePackets) + assert.Equal(t, float64(55), tcp.SentControlPackets) + assert.Equal(t, float64(56), tcp.PacketsReceived) + assert.Equal(t, float64(57), tcp.ReceivedAcks) + assert.Equal(t, float64(58), tcp.AcksBytes) + assert.Equal(t, float64(59), tcp.ReceivedDuplicateAcks) + assert.Equal(t, float64(60), tcp.ReceivedAcksForUnsentData) + assert.Equal(t, float64(61), tcp.PacketsReceivedInSequence) + assert.Equal(t, float64(62), tcp.InSequenceBytes) + assert.Equal(t, float64(63), tcp.ReceivedCompletelyDuplicatePacket) + assert.Equal(t, float64(64), tcp.DuplicateInBytes) + assert.Equal(t, float64(65), tcp.ReceivedOldDuplicatePackets) + assert.Equal(t, float64(66), tcp.ReceivedPacketsWithSomeDupliacteData) + assert.Equal(t, float64(67), tcp.SomeDuplicateInBytes) + assert.Equal(t, float64(68), tcp.ReceivedOutOfOrderPackets) + assert.Equal(t, float64(69), tcp.OutOfOrderInBytes) + assert.Equal(t, float64(70), tcp.ReceivedPacketsOfDataAfterWindow) + assert.Equal(t, float64(71), tcp.Bytes) + assert.Equal(t, float64(72), tcp.ReceivedWindowProbes) + assert.Equal(t, float64(73), tcp.ReceivedWindowUpdatePackets) + assert.Equal(t, float64(74), tcp.PacketsReceivedAfterClose) + assert.Equal(t, float64(75), tcp.ReceivedDiscardedForBadChecksum) + assert.Equal(t, float64(76), tcp.ReceivedDiscardedForBadHeaderOffset) + assert.Equal(t, float64(77), tcp.ReceivedDiscardedBecausePacketTooShort) + assert.Equal(t, float64(78), tcp.ConnectionRequests) + assert.Equal(t, float64(79), tcp.ConnectionAccepts) + assert.Equal(t, float64(80), tcp.BadConnectionAttempts) + assert.Equal(t, float64(81), tcp.ListenQueueOverflows) + assert.Equal(t, float64(82), tcp.BadRstWindow) + assert.Equal(t, float64(83), tcp.ConnectionsEstablished) + assert.Equal(t, float64(84), tcp.ConnectionsClosed) + assert.Equal(t, float64(85), tcp.Drops) + assert.Equal(t, float64(86), tcp.ConnectionsUpdatedRttOnClose) + assert.Equal(t, float64(87), tcp.ConnectionsUpdatedVarianceOnClose) + assert.Equal(t, float64(88), tcp.ConnectionsUpdatedSsthreshOnClose) + assert.Equal(t, float64(89), tcp.EmbryonicConnectionsDropped) + assert.Equal(t, float64(90), tcp.SegmentsUpdatedRtt) + assert.Equal(t, float64(91), tcp.Attempts) + assert.Equal(t, float64(92), tcp.RetransmitTimeouts) + assert.Equal(t, float64(93), tcp.ConnectionsDroppedByRetransmitTimeout) + assert.Equal(t, float64(94), tcp.PersistTimeouts) + assert.Equal(t, float64(95), tcp.ConnectionsDroppedByPersistTimeout) + assert.Equal(t, float64(96), tcp.KeepaliveTimeouts) + assert.Equal(t, float64(97), tcp.KeepaliveProbesSent) + assert.Equal(t, float64(98), tcp.KeepaliveConnectionsDropped) + assert.Equal(t, float64(99), tcp.AckHeaderPredictions) + assert.Equal(t, float64(100), tcp.DataPacketHeaderPredictions) + assert.Equal(t, float64(101), tcp.SyncacheEntriesAdded) + assert.Equal(t, float64(102), tcp.Retransmitted) + assert.Equal(t, float64(103), tcp.Dupsyn) + assert.Equal(t, float64(104), tcp.Dropped) + assert.Equal(t, float64(105), tcp.Completed) + assert.Equal(t, float64(106), tcp.BucketOverflow) + assert.Equal(t, float64(107), tcp.CacheOverflow) + assert.Equal(t, float64(108), tcp.Reset) + assert.Equal(t, float64(109), tcp.Stale) + assert.Equal(t, float64(110), tcp.Aborted) + assert.Equal(t, float64(111), tcp.Badack) + assert.Equal(t, float64(112), tcp.Unreach) + assert.Equal(t, float64(113), tcp.ZoneFailures) + assert.Equal(t, float64(114), tcp.CookiesSent) + assert.Equal(t, float64(115), tcp.CookiesReceived) + assert.Equal(t, float64(116), tcp.SackRecoveryEpisodes) + assert.Equal(t, float64(117), tcp.SegmentRetransmits) + assert.Equal(t, float64(118), tcp.ByteRetransmits) + assert.Equal(t, float64(119), tcp.SackOptionsReceived) + assert.Equal(t, float64(120), tcp.SackOpitionsSent) + assert.Equal(t, float64(121), tcp.SackScoreboardOverflow) + assert.Equal(t, float64(122), tcp.AcksSentInResponseButNotExactRsts) + assert.Equal(t, float64(123), tcp.AcksSentInResponseToSynsOnEstablishedConnections) + assert.Equal(t, float64(124), tcp.RcvPacketsDroppedDueToBadAddress) + assert.Equal(t, float64(125), tcp.OutOfSequenceSegmentDrops) + assert.Equal(t, float64(126), tcp.RstPackets) + assert.Equal(t, float64(127), tcp.IcmpPacketsIgnored) + assert.Equal(t, float64(128), tcp.SendPacketsDropped) + assert.Equal(t, float64(129), tcp.RcvPacketsDropped) + assert.Equal(t, float64(130), tcp.OutgoingSegmentsDropped) + assert.Equal(t, float64(131), tcp.ReceivedSynfinDropped) + assert.Equal(t, float64(132), tcp.ReceivedIpsecDropped) + assert.Equal(t, float64(133), tcp.ReceivedMacDropped) + assert.Equal(t, float64(134), tcp.ReceivedMinttlExceeded) + assert.Equal(t, float64(135), tcp.ListenstateBadflagsDropped) + assert.Equal(t, float64(136), tcp.FinwaitstateBadflagsDropped) + assert.Equal(t, float64(137), tcp.ReceivedDosAttack) + assert.Equal(t, float64(138), tcp.ReceivedBadSynack) + assert.Equal(t, float64(139), tcp.SyncacheZoneFull) + assert.Equal(t, float64(140), tcp.ReceivedRstFirewallfilter) + assert.Equal(t, float64(141), tcp.ReceivedNoackTimewait) + assert.Equal(t, float64(142), tcp.ReceivedNoTimewaitState) + assert.Equal(t, float64(143), tcp.ReceivedRstTimewaitState) + assert.Equal(t, float64(144), tcp.ReceivedTimewaitDrops) + assert.Equal(t, float64(145), tcp.ReceivedBadaddrTimewaitState) + assert.Equal(t, float64(146), tcp.ReceivedAckoffInSynSentrcvd) + assert.Equal(t, float64(147), tcp.ReceivedBadaddrFirewall) + assert.Equal(t, float64(148), tcp.ReceivedNosynSynSent) + assert.Equal(t, float64(149), tcp.ReceivedBadrstSynSent) + assert.Equal(t, float64(150), tcp.ReceivedBadrstListenState) + assert.Equal(t, float64(151), tcp.OptionMaxsegmentLength) + assert.Equal(t, float64(152), tcp.OptionWindowLength) + assert.Equal(t, float64(153), tcp.OptionTimestampLength) + assert.Equal(t, float64(154), tcp.OptionMd5Length) + assert.Equal(t, float64(155), tcp.OptionAuthLength) + assert.Equal(t, float64(156), tcp.OptionSackpermittedLength) + assert.Equal(t, float64(157), tcp.OptionSackLength) + assert.Equal(t, float64(158), tcp.OptionAuthoptionLength) assert.Equal(t, "user@router>", got.Cli.Banner) }, }, @@ -332,5 +415,3 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { }) } } - - diff --git a/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml index e1ed6c55..861e6e1a 100644 --- a/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml +++ b/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml @@ -7,116 +7,116 @@ 10 2048 50 - 5 - 2 - 3 - 4 - 7 - 1100 - 980 - 654321 - 8 - 1 - 1005 - 111222 - 6 - 777 - 4 - 3 - 88 - 9 - 999 - 2 - 222333 - 5 - 6 - 1 - 2 - 3 - 4 - 40 - 39 - 2 - 1 - 0 - 38 - 30 - 3 - 12 - 11 - 10 - 1 - 25 - 44 - 6 - 1 - 2 - 1 - 5 - 15 - 2 - 100 - 200 - 12 - 8 - 1 - 2 - 37 - 0 - 0 - 4 - 0 - 1 - 0 - 0 - 0 - 5 - 6 - 3 - 9 - 1024 - 7 - 6 - 0 - 2 - 1 - 3 - 4 - 12 - 0 - 7 - 6 - 5 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 - 20 - 10 - 12 - 0 - 0 - 8 - 16 - 0 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 user@router> From e83546e0242419180107ae9477786cc190f89c4f Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Wed, 3 Sep 2025 16:29:57 +0200 Subject: [PATCH 18/27] refactoring test + fixed bug in the collector --- pkg/features/systemstatistics/collector.go | 12 + pkg/features/systemstatistics/rpc.go | 4 +- pkg/features/systemstatistics/rpc_test.go | 286 ++++++++++-------- .../testsFiles/IPV4/ipv4TestDataCase1.xml | 88 +++--- .../testsFiles/IPv6/ipv6TestDataCase1.xml | 90 +++--- 5 files changed, 260 insertions(+), 220 deletions(-) diff --git a/pkg/features/systemstatistics/collector.go b/pkg/features/systemstatistics/collector.go index 393b58f4..95559f80 100644 --- a/pkg/features/systemstatistics/collector.go +++ b/pkg/features/systemstatistics/collector.go @@ -680,8 +680,20 @@ func (c *systemstatisticsCollector) Collect(client collector.Client, ch chan<- p return err } c.collectSystemStatisticsIPV4(ch, labelValues, s) + err = client.RunCommandAndParse("show system statistics ip6", &s) + if err != nil { + return err + } c.collectSystemStatisticsIPV6(ch, labelValues, s) + err = client.RunCommandAndParse("show system statistics udp", &s) + if err != nil { + return err + } c.collectSystemStatisticsUDP(ch, labelValues, s) + err = client.RunCommandAndParse("show system statistics tcp", &s) + if err != nil { + return err + } c.collectSystemStatisticsTCP(ch, labelValues, s) return nil } diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go index eaa74bc8..8570d4df 100644 --- a/pkg/features/systemstatistics/rpc.go +++ b/pkg/features/systemstatistics/rpc.go @@ -303,7 +303,7 @@ type SystemStatistics struct { Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` - Histogram float64 `xml:"histogram"` + Histogram string `xml:"histogram"` Ip6nhTcp float64 `xml:"ip6nh-tcp"` Ip6nhUdp float64 `xml:"ip6nh-udp"` Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` @@ -434,4 +434,4 @@ type SystemStatistics struct { Text string `xml:",chardata"` Banner string `xml:"banner"` } `xml:"cli"` -} +} \ No newline at end of file diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index cbc343be..f65c1018 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,7 +2,7 @@ package systemstatistics import ( "encoding/xml" - "io/ioutil" + "io" "os" "testing" @@ -10,149 +10,181 @@ import ( ) func TestStatisticsIPv4Unmarshaling(t *testing.T) { - IPv4XMLDataCase1, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase1.xml") - IPv4DataCase1, _ := ioutil.ReadAll(IPv4XMLDataCase1) - IPv4XMLDataCase2, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase2.xml") - IPv4DataCase2, _ := ioutil.ReadAll(IPv4XMLDataCase2) - IPv4XMLDataCase3, _ := os.Open("testsFiles/IPV4/ipv4TestDataCase3.xml") - IPv4DataCase3, _ := ioutil.ReadAll(IPv4XMLDataCase3) - type testCase struct { - name string - xmlInput string - expect func(t *testing.T, got SystemStatistics) + name string + xmlFile string + expect SystemStatistics } testsIPV4 := []testCase{ { - name: "complete_ipv4_statistics", - xmlInput: string(IPv4DataCase1), - expect: func(t *testing.T, got SystemStatistics) { - ip := got.Statistics.Ip - assert.Equal(t, float64(1000), ip.PacketsReceived) - assert.Equal(t, float64(5), ip.BadHeaderChecksums) - assert.Equal(t, float64(10), ip.PacketsWithSizeSmallerThanMinimum) - assert.Equal(t, float64(2), ip.PacketsWithDataSizeLessThanDatalength) - assert.Equal(t, float64(3), ip.PacketsWithHeaderLengthLessThanDataSize) - assert.Equal(t, float64(1), ip.PacketsWithDataLengthLessThanHeaderlength) - assert.Equal(t, float64(0), ip.PacketsWithIncorrectVersionNumber) - assert.Equal(t, float64(0), ip.PacketsDestinedToDeadNextHop) - assert.Equal(t, float64(50), ip.FragmentsReceived) - assert.Equal(t, float64(2), ip.FragmentsDroppedDueToOutofspaceOrDup) - assert.Equal(t, float64(1), ip.FragmentsDroppedDueToQueueoverflow) - assert.Equal(t, float64(0), ip.FragmentsDroppedAfterTimeout) - assert.Equal(t, float64(48), ip.PacketsReassembledOk) - assert.Equal(t, float64(500), ip.PacketsForThisHost) - assert.Equal(t, float64(5), ip.PacketsForUnknownOrUnsupportedProtocol) - assert.Equal(t, float64(400), ip.PacketsForwarded) - assert.Equal(t, float64(10), ip.PacketsNotForwardable) - assert.Equal(t, float64(2), ip.RedirectsSent) - assert.Equal(t, float64(800), ip.PacketsSentFromThisHost) - assert.Equal(t, float64(0), ip.PacketsSentWithFabricatedIpHeader) - assert.Equal(t, float64(3), ip.OutputPacketsDroppedDueToNoBufs) - assert.Equal(t, float64(1), ip.OutputPacketsDiscardedDueToNoRoute) - assert.Equal(t, float64(20), ip.OutputDatagramsFragmented) - assert.Equal(t, float64(40), ip.FragmentsCreated) - assert.Equal(t, float64(2), ip.DatagramsThatCanNotBeFragmented) - assert.Equal(t, float64(1), ip.PacketsWithBadOptions) - assert.Equal(t, float64(15), ip.PacketsWithOptionsHandledWithoutError) - assert.Equal(t, float64(0), ip.StrictSourceAndRecordRouteOptions) - assert.Equal(t, float64(2), ip.LooseSourceAndRecordRouteOptions) - assert.Equal(t, float64(5), ip.RecordRouteOptions) - assert.Equal(t, float64(3), ip.TimestampOptions) - assert.Equal(t, float64(1), ip.TimestampAndAddressOptions) - assert.Equal(t, float64(0), ip.TimestampAndPrespecifiedAddressOptions) - assert.Equal(t, float64(0), ip.OptionPacketsDroppedDueToRateLimit) - assert.Equal(t, float64(4), ip.RouterAlertOptions) - assert.Equal(t, float64(8), ip.MulticastPacketsDropped) - assert.Equal(t, float64(12), ip.PacketsDropped) - assert.Equal(t, float64(0), ip.TransitRePacketsDroppedOnMgmtInterface) - assert.Equal(t, float64(25), ip.PacketsUsedFirstNexthopInEcmpUnilist) - assert.Equal(t, float64(100), ip.IncomingTtpoipPacketsReceived) - assert.Equal(t, float64(2), ip.IncomingTtpoipPacketsDropped) - assert.Equal(t, float64(95), ip.OutgoingTtpoipPacketsSent) - assert.Equal(t, float64(1), ip.OutgoingTtpoipPacketsDropped) - assert.Equal(t, float64(3), ip.IncomingRawipPacketsDroppedNoSocketBuffer) - assert.Equal(t, float64(200), ip.IncomingVirtualNodePacketsDelivered) - assert.Equal(t, "user@router>", got.Cli.Banner) - }, - }, - { - name: "empty_ipv4_statistics", - xmlInput: string(IPv4DataCase2), - expect: func(t *testing.T, got SystemStatistics) { - assert.Equal(t, "user@router>", got.Cli.Banner) + name: "complete_ipv4_statistics", + xmlFile: "testsFiles/IPV4/ipv4TestDataCase1.xml", + expect: SystemStatistics{ + Statistics: Statistics{ + Ip: IP{ + PacketsReceived: 1000, + BadHeaderChecksums: 1001, + PacketsWithSizeSmallerThanMinimum: 1002, + PacketsWithDataSizeLessThanDatalength: 1003, + PacketsWithHeaderLengthLessThanDataSize: 1004, + PacketsWithDataLengthLessThanHeaderlength: 1005, + PacketsWithIncorrectVersionNumber: 1006, + PacketsDestinedToDeadNextHop: 1007, + FragmentsReceived: 1008, + FragmentsDroppedDueToOutofspaceOrDup: 1009, + FragmentsDroppedDueToQueueoverflow: 1010, + FragmentsDroppedAfterTimeout: 1011, + PacketsReassembledOk: 1012, + PacketsForThisHost: 1013, + PacketsForUnknownOrUnsupportedProtocol: 1014, + PacketsForwarded: 1015, + PacketsNotForwardable: 1016, + RedirectsSent: 1017, + PacketsSentFromThisHost: 1018, + PacketsSentWithFabricatedIpHeader: 1019, + OutputPacketsDroppedDueToNoBufs: 1020, + OutputPacketsDiscardedDueToNoRoute: 1021, + OutputDatagramsFragmented: 1022, + FragmentsCreated: 1023, + DatagramsThatCanNotBeFragmented: 1024, + PacketsWithBadOptions: 1025, + PacketsWithOptionsHandledWithoutError: 1026, + StrictSourceAndRecordRouteOptions: 1027, + LooseSourceAndRecordRouteOptions: 1028, + RecordRouteOptions: 1029, + TimestampOptions: 1030, + TimestampAndAddressOptions: 1031, + TimestampAndPrespecifiedAddressOptions: 1032, + OptionPacketsDroppedDueToRateLimit: 1033, + RouterAlertOptions: 1034, + MulticastPacketsDropped: 1035, + PacketsDropped: 1036, + TransitRePacketsDroppedOnMgmtInterface: 1037, + PacketsUsedFirstNexthopInEcmpUnilist: 1038, + IncomingTtpoipPacketsReceived: 1039, + IncomingTtpoipPacketsDropped: 1040, + OutgoingTtpoipPacketsSent: 1041, + OutgoingTtpoipPacketsDropped: 1042, + IncomingRawipPacketsDroppedNoSocketBuffer: 1043, + IncomingVirtualNodePacketsDelivered: 1044, + }, + }, }, }, + } + + for _, tc := range testsIPV4 { + t.Run(tc.name, func(t *testing.T) { + fc, err := os.ReadFile(tc.xmlFile) + if err != nil { + + } + var result SystemStatistics + err = xml.Unmarshal(fc, &result) + if err != nil { + + } + + result.Statistics.Ip.Text = "" + assert.Equal(t, tc.expect.Statistics.Ip, result.Statistics.Ip, tc.name) + assert.NoError(t, err, "unmarshal should not return error") + }) + } +} + +func TestStatisticsIPv6Unmarshaling(t *testing.T) { + type testCase struct { + name string + xmlFile string + expect SystemStatistics + } + + testsIPV4 := []testCase{ { - name: "high_values_ipv4_statistics", - xmlInput: string(IPv4DataCase3), - expect: func(t *testing.T, got SystemStatistics) { - ip := got.Statistics.Ip - assert.Equal(t, float64(999999999), ip.PacketsReceived) - assert.Equal(t, float64(12345), ip.BadHeaderChecksums) - assert.Equal(t, float64(54321), ip.PacketsWithSizeSmallerThanMinimum) - assert.Equal(t, float64(1111), ip.PacketsWithDataSizeLessThanDatalength) - assert.Equal(t, float64(2222), ip.PacketsWithHeaderLengthLessThanDataSize) - assert.Equal(t, float64(3333), ip.PacketsWithDataLengthLessThanHeaderlength) - assert.Equal(t, float64(4444), ip.PacketsWithIncorrectVersionNumber) - assert.Equal(t, float64(5555), ip.PacketsDestinedToDeadNextHop) - assert.Equal(t, float64(888888), ip.FragmentsReceived) - assert.Equal(t, float64(6666), ip.FragmentsDroppedDueToOutofspaceOrDup) - assert.Equal(t, float64(7777), ip.FragmentsDroppedDueToQueueoverflow) - assert.Equal(t, float64(8888), ip.FragmentsDroppedAfterTimeout) - assert.Equal(t, float64(777777), ip.PacketsReassembledOk) - assert.Equal(t, float64(555555), ip.PacketsForThisHost) - assert.Equal(t, float64(9999), ip.PacketsForUnknownOrUnsupportedProtocol) - assert.Equal(t, float64(444444), ip.PacketsForwarded) - assert.Equal(t, float64(11111), ip.PacketsNotForwardable) - assert.Equal(t, float64(12121), ip.RedirectsSent) - assert.Equal(t, float64(666666), ip.PacketsSentFromThisHost) - assert.Equal(t, float64(13131), ip.PacketsSentWithFabricatedIpHeader) - assert.Equal(t, float64(14141), ip.OutputPacketsDroppedDueToNoBufs) - assert.Equal(t, float64(15151), ip.OutputPacketsDiscardedDueToNoRoute) - assert.Equal(t, float64(16161), ip.OutputDatagramsFragmented) - assert.Equal(t, float64(17171), ip.FragmentsCreated) - assert.Equal(t, float64(18181), ip.DatagramsThatCanNotBeFragmented) - assert.Equal(t, float64(19191), ip.PacketsWithBadOptions) - assert.Equal(t, float64(20202), ip.PacketsWithOptionsHandledWithoutError) - assert.Equal(t, float64(21212), ip.StrictSourceAndRecordRouteOptions) - assert.Equal(t, float64(22222), ip.LooseSourceAndRecordRouteOptions) - assert.Equal(t, float64(23232), ip.RecordRouteOptions) - assert.Equal(t, float64(24242), ip.TimestampOptions) - assert.Equal(t, float64(25252), ip.TimestampAndAddressOptions) - assert.Equal(t, float64(26262), ip.TimestampAndPrespecifiedAddressOptions) - assert.Equal(t, float64(27272), ip.OptionPacketsDroppedDueToRateLimit) - assert.Equal(t, float64(28282), ip.RouterAlertOptions) - assert.Equal(t, float64(29292), ip.MulticastPacketsDropped) - assert.Equal(t, float64(30303), ip.PacketsDropped) - assert.Equal(t, float64(31313), ip.TransitRePacketsDroppedOnMgmtInterface) - assert.Equal(t, float64(32323), ip.PacketsUsedFirstNexthopInEcmpUnilist) - assert.Equal(t, float64(33333), ip.IncomingTtpoipPacketsReceived) - assert.Equal(t, float64(34343), ip.IncomingTtpoipPacketsDropped) - assert.Equal(t, float64(35353), ip.OutgoingTtpoipPacketsSent) - assert.Equal(t, float64(36363), ip.OutgoingTtpoipPacketsDropped) - assert.Equal(t, float64(37373), ip.IncomingRawipPacketsDroppedNoSocketBuffer) - assert.Equal(t, float64(38383), ip.IncomingVirtualNodePacketsDelivered) - assert.Equal(t, "admin@high-traffic-router>", got.Cli.Banner) + name: "complete_ipv6_statistics", + xmlFile: "testsFiles/IPV6/ipv6TestDataCase1.xml", + expect: SystemStatistics{ + Statistics: Statistics{ + Ip6: IP6{ + TotalPacketsReceived: 2000, + Ip6PacketsWithSizeSmallerThanMinimum: 2001, + PacketsWithDatasizeLessThanDataLength: 2002, + Ip6PacketsWithBadOptions: 2003, + Ip6PacketsWithIncorrectVersionNumber: 2004, + Ip6FragmentsReceived: 2005, + DuplicateOrOutOfSpaceFragmentsDropped: 2006, + Ip6FragmentsDroppedAfterTimeout: 2007, + FragmentsThatExceededLimit: 2008, + Ip6PacketsReassembledOk: 2009, + Ip6PacketsForThisHost: 2010, + Ip6PacketsForwarded: 2011, + Ip6PacketsNotForwardable: 2012, + Ip6RedirectsSent: 2013, + Ip6PacketsSentFromThisHost: 2014, + Ip6PacketsSentWithFabricatedIpHeader: 2015, + Ip6OutputPacketsDroppedDueToNoBufs: 2016, + Ip6OutputPacketsDiscardedDueToNoRoute: 2017, + Ip6OutputDatagramsFragmented: 2018, + Ip6FragmentsCreated: 2019, + Ip6DatagramsThatCanNotBeFragmented: 2020, + PacketsThatViolatedScopeRules: 2021, + MulticastPacketsWhichWeDoNotJoin: 2022, + Ip6nhTcp: 2023, + Ip6nhUdp: 2024, + Ip6nhIcmp6: 2025, + PacketsWhoseHeadersAreNotContinuous: 2026, + TunnelingPacketsThatCanNotFindGif: 2027, + PacketsDiscardedDueToTooMayHeaders: 2028, + FailuresOfSourceAddressSelection: 2029, + HeaderType: []HeaderType{ + { + LinkLocals: 2030, + Globals: 2031, + }, + { + LinkLocals: 2100, + Globals: 2101, + }, + }, + ForwardCacheHit: 2032, + ForwardCacheMiss: 2033, + Ip6PacketsDestinedToDeadNextHop: 2034, + Ip6OptionPacketsDroppedDueToRateLimit: 2035, + Ip6PacketsDropped: 2036, + PacketsDroppedDueToBadProtocol: 2037, + TransitRePacketDroppedOnMgmtInterface: 2038, + PacketUsedFirstNexthopInEcmpUnilist: 2039, + }, + }, }, }, } for _, tc := range testsIPV4 { t.Run(tc.name, func(t *testing.T) { + fc, err := os.ReadFile(tc.xmlFile) + if err != nil { + + } var result SystemStatistics - err := xml.Unmarshal([]byte(tc.xmlInput), &result) + err = xml.Unmarshal(fc, &result) + if err != nil { + + } + + result.Statistics.Ip6.Text = "" + assert.Equal(t, tc.expect.Statistics.Ip6, result.Statistics.Ip6, tc.name) assert.NoError(t, err, "unmarshal should not return error") - tc.expect(t, result) }) } } // Tests for the IPv6 sub-structure (Ip6) of SystemStatistics. We use inline XML to focus on Ip6. -func TestStatisticsIPv6Unmarshaling(t *testing.T) { +/* +func TestStatisticsIPv66Unmarshaling(t *testing.T) { IPv6XMLDataCase1, _ := os.Open("testsFiles/IPv6/ipv6TestDataCase1.xml") - IPv6DataCase1, _ := ioutil.ReadAll(IPv6XMLDataCase1) + IPv6DataCase1, _ := io.ReadAll(IPv6XMLDataCase1) type testCase struct { name string xmlInput string @@ -232,9 +264,11 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { } } + */ + func TestStatisticsUDPUnmarshaling(t *testing.T) { UDPXMLDataCase1, _ := os.Open("testsFiles/UDP/UDPTestDataCase1.xml") - UDPDataCase1, _ := ioutil.ReadAll(UDPXMLDataCase1) + UDPDataCase1, _ := io.ReadAll(UDPXMLDataCase1) type testCase struct { name string xmlInput string @@ -257,7 +291,7 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { assert.Equal(t, float64(7), udp.DatagramsNotForHashedPcb) assert.Equal(t, float64(8), udp.DatagramsDelivered) assert.Equal(t, float64(9), udp.DatagramsOutput) - assert.Equal(t, "user@router>", got.Cli.Banner) + //assert.Equal(t, "user@router>", got.Cli.Banner) }, }, } @@ -274,7 +308,7 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { func TestStatisticsTCPUnmarshaling(t *testing.T) { TCPXMLDataCase1, _ := os.Open("testsFiles/TCP/TCPTestDataCase1.xml") - TCPDataCase1, _ := ioutil.ReadAll(TCPXMLDataCase1) + TCPDataCase1, _ := io.ReadAll(TCPXMLDataCase1) type testCase struct { name string xmlInput string @@ -401,7 +435,7 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { assert.Equal(t, float64(156), tcp.OptionSackpermittedLength) assert.Equal(t, float64(157), tcp.OptionSackLength) assert.Equal(t, float64(158), tcp.OptionAuthoptionLength) - assert.Equal(t, "user@router>", got.Cli.Banner) + //assert.Equal(t, "user@router>", got.Cli.Banner) }, }, } diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml index 1fdadd28..91566bf8 100644 --- a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml +++ b/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml @@ -2,50 +2,50 @@ 1000 - 5 - 10 - 2 - 3 - 1 - 0 - 0 - 50 - 2 - 1 - 0 - 48 - 500 - 5 - 400 - 10 - 2 - 800 - 0 - 3 - 1 - 20 - 40 - 2 - 1 - 15 - 0 - 2 - 5 - 3 - 1 - 0 - 0 - 4 - 8 - 12 - 0 - 25 - 100 - 2 - 95 - 1 - 3 - 200 + 1001 + 1002 + 1003 + 1004 + 1005 + 1006 + 1007 + 1008 + 1009 + 1010 + 1011 + 1012 + 1013 + 1014 + 1015 + 1016 + 1017 + 1018 + 1019 + 1020 + 1021 + 1022 + 1023 + 1024 + 1025 + 1026 + 1027 + 1028 + 1029 + 1030 + 1031 + 1032 + 1033 + 1034 + 1035 + 1036 + 1037 + 1038 + 1039 + 1040 + 1041 + 1042 + 1043 + 1044 diff --git a/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml index 1d876ff8..5b219174 100644 --- a/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml +++ b/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml @@ -1,58 +1,52 @@ - 100 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 + 2000 + 2001 + 2002 + 2003 + 2004 + 2005 + 2006 + 2007 + 2008 + 2009 + 2010 + 2011 + 2012 + 2013 + 2014 + 2015 + 2016 + 2017 + 2018 + 2019 + 2020 + 2021 + 2022 + 2023 + 2024 + 2025 + 2026 + 2027 + 2028 + 2029 - default - 30 - 31 - 0 - 0 + 2030 + 2031 - policy - 32 - 33 - 0 - 0 + 2100 + 2101 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 + 2032 + 2033 + 2034 + 2035 + 2036 + 2037 + 2038 + 2039 user@router> From ee02e8377ec5e076793e390b1edeb79852c1305c Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Wed, 3 Sep 2025 16:56:25 +0200 Subject: [PATCH 19/27] fixing pipeline --- pkg/features/systemstatistics/rpc.go | 875 +++++++++--------- pkg/features/systemstatistics/rpc_test.go | 8 +- .../testsFiles/IPv6/ipv6TestDataCase1.xml | 6 +- 3 files changed, 452 insertions(+), 437 deletions(-) diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go index 8570d4df..1470897c 100644 --- a/pkg/features/systemstatistics/rpc.go +++ b/pkg/features/systemstatistics/rpc.go @@ -3,435 +3,448 @@ package systemstatistics import "encoding/xml" type SystemStatistics struct { - XMLName xml.Name `xml:"rpc-reply"` - Text string `xml:",chardata"` - Junos string `xml:"junos,attr"` - Statistics struct { - Text string `xml:",chardata"` - Tcp struct { - Text string `xml:",chardata"` - PacketsSent float64 `xml:"packets-sent"` - SentDataPackets float64 `xml:"sent-data-packets"` - DataPacketsBytes float64 `xml:"data-packets-bytes"` - SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` - RetransmittedBytes float64 `xml:"retransmitted-bytes"` - SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` - SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` - SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` - SentPacketsDelayed float64 `xml:"sent-packets-delayed"` - SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` - SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` - SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` - SentControlPackets float64 `xml:"sent-control-packets"` - PacketsReceived float64 `xml:"packets-received"` - ReceivedAcks float64 `xml:"received-acks"` - AcksBytes float64 `xml:"acks-bytes"` - ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` - ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` - PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` - InSequenceBytes float64 `xml:"in-sequence-bytes"` - ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` - DuplicateInBytes float64 `xml:"duplicate-in-bytes"` - ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` - ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` - SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` - ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` - OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` - ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` - Bytes float64 `xml:"bytes"` - ReceivedWindowProbes float64 `xml:"received-window-probes"` - ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` - PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` - ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` - ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` - ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` - ConnectionRequests float64 `xml:"connection-requests"` - ConnectionAccepts float64 `xml:"connection-accepts"` - BadConnectionAttempts float64 `xml:"bad-connection-attempts"` - ListenQueueOverflows float64 `xml:"listen-queue-overflows"` - BadRstWindow float64 `xml:"bad-rst-window"` - ConnectionsEstablished float64 `xml:"connections-established"` - ConnectionsClosed float64 `xml:"connections-closed"` - Drops float64 `xml:"drops"` - ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` - ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` - ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` - EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` - SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` - Attempts float64 `xml:"attempts"` - RetransmitTimeouts float64 `xml:"retransmit-timeouts"` - ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` - PersistTimeouts float64 `xml:"persist-timeouts"` - ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` - KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` - KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` - KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` - AckHeaderPredictions float64 `xml:"ack-header-predictions"` - DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` - SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` - Retransmitted float64 `xml:"retransmitted"` - Dupsyn float64 `xml:"dupsyn"` - Dropped float64 `xml:"dropped"` - Completed float64 `xml:"completed"` - BucketOverflow float64 `xml:"bucket-overflow"` - CacheOverflow float64 `xml:"cache-overflow"` - Reset float64 `xml:"reset"` - Stale float64 `xml:"stale"` - Aborted float64 `xml:"aborted"` - Badack float64 `xml:"badack"` - Unreach float64 `xml:"unreach"` - ZoneFailures float64 `xml:"zone-failures"` - CookiesSent float64 `xml:"cookies-sent"` - CookiesReceived float64 `xml:"cookies-received"` - SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` - SegmentRetransmits float64 `xml:"segment-retransmits"` - ByteRetransmits float64 `xml:"byte-retransmits"` - SackOptionsReceived float64 `xml:"sack-options-received"` - SackOpitionsSent float64 `xml:"sack-opitions-sent"` - SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` - AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` - AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` - RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` - OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` - RstPackets float64 `xml:"rst-packets"` - IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` - SendPacketsDropped float64 `xml:"send-packets-dropped"` - RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` - OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` - ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` - ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` - ReceivedMacDropped float64 `xml:"received-mac-dropped"` - ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` - ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` - FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` - ReceivedDosAttack float64 `xml:"received-dos-attack"` - ReceivedBadSynack float64 `xml:"received-bad-synack"` - SyncacheZoneFull float64 `xml:"syncache-zone-full"` - ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` - ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` - ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` - ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` - ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` - ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` - ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` - ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` - ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` - ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` - ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` - OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` - OptionWindowLength float64 `xml:"option-window-length"` - OptionTimestampLength float64 `xml:"option-timestamp-length"` - OptionMd5Length float64 `xml:"option-md5-length"` - OptionAuthLength float64 `xml:"option-auth-length"` - OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` - OptionSackLength float64 `xml:"option-sack-length"` - OptionAuthoptionLength float64 `xml:"option-authoption-length"` - } `xml:"tcp"` - Udp struct { - Text string `xml:",chardata"` - DatagramsReceived float64 `xml:"datagrams-received"` - DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` - DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` - DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` - DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` - BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` - DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` - DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` - DatagramsDelivered float64 `xml:"datagrams-delivered"` - DatagramsOutput float64 `xml:"datagrams-output"` - } `xml:"udp"` - Ip struct { - Text string `xml:",chardata"` - PacketsReceived float64 `xml:"packets-received"` - BadHeaderChecksums float64 `xml:"bad-header-checksums"` - PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` - PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` - PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` - PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` - PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` - PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` - FragmentsReceived float64 `xml:"fragments-received"` - FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` - FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` - FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` - PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` - PacketsForThisHost float64 `xml:"packets-for-this-host"` - PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` - PacketsForwarded float64 `xml:"packets-forwarded"` - PacketsNotForwardable float64 `xml:"packets-not-forwardable"` - RedirectsSent float64 `xml:"redirects-sent"` - PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` - PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` - OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` - OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` - OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` - FragmentsCreated float64 `xml:"fragments-created"` - DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` - PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` - PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` - StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` - LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` - RecordRouteOptions float64 `xml:"record-route-options"` - TimestampOptions float64 `xml:"timestamp-options"` - TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` - TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` - OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` - RouterAlertOptions float64 `xml:"router-alert-options"` - MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` - PacketsDropped float64 `xml:"packets-dropped"` - TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` - PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` - IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` - OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` - OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` - IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` - IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` - } `xml:"ip"` - Icmp struct { - Text string `xml:",chardata"` - DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` - CallsToIcmpError string `xml:"calls-to-icmp-error"` - ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` - Histogram []struct { - Text string `xml:",chardata"` - TypeOfHistogram string `xml:"type-of-histogram"` - IcmpEchoReply string `xml:"icmp-echo-reply"` - DestinationUnreachable string `xml:"destination-unreachable"` - IcmpEcho string `xml:"icmp-echo"` - TimeStampReply string `xml:"time-stamp-reply"` - TimeExceeded string `xml:"time-exceeded"` - TimeStamp string `xml:"time-stamp"` - AddressMaskRequest string `xml:"address-mask-request"` - AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` - } `xml:"histogram"` - MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` - MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` - MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` - MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` - MessagesWithBadLength string `xml:"messages-with-bad-length"` - EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` - TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` - MessageResponsesGenerated string `xml:"message-responses-generated"` - } `xml:"icmp"` - Arp struct { - Text string `xml:",chardata"` - DatagramsReceived string `xml:"datagrams-received"` - ArpRequestsReceived string `xml:"arp-requests-received"` - ArpRepliesReceived string `xml:"arp-replies-received"` - ResolutionRequestReceived string `xml:"resolution-request-received"` - ResolutionRequestDropped string `xml:"resolution-request-dropped"` - UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` - RestrictedProxyRequests string `xml:"restricted-proxy-requests"` - ReceivedProxyRequests string `xml:"received-proxy-requests"` - ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` - RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` - DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` - DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` - DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` - DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` - DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` - DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` - DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` - DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` - DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` - DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` - DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` - DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` - DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` - PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` - PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` - ArpRequestsSent string `xml:"arp-requests-sent"` - ArpRepliesSent string `xml:"arp-replies-sent"` - RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` - RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` - RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` - RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` - RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` - NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` - RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` - RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` - RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` - ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` - ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` - ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` - ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` - ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` - SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` - ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` - ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` - ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` - ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` - GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` - ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` - ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` - ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` - ArpSystemMax string `xml:"arp-system-max"` - ArpPublicMax string `xml:"arp-public-max"` - ArpIriMax string `xml:"arp-iri-max"` - ArpMgtMax string `xml:"arp-mgt-max"` - ArpPublicCnt string `xml:"arp-public-cnt"` - ArpIriCnt string `xml:"arp-iri-cnt"` - ArpMgtCnt string `xml:"arp-mgt-cnt"` - ArpSystemDrop string `xml:"arp-system-drop"` - ArpPublicDrop string `xml:"arp-public-drop"` - ArpIriDrop string `xml:"arp-iri-drop"` - ArpMgtDrop string `xml:"arp-mgt-drop"` - } `xml:"arp"` - Ip6 struct { - Text string `xml:",chardata"` - TotalPacketsReceived float64 `xml:"total-packets-received"` - Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` - PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` - Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` - Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` - Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` - DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` - Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` - FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` - Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` - Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` - Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` - Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` - Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` - Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` - Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` - Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` - Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` - Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` - Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` - Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` - PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` - MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` - Histogram string `xml:"histogram"` - Ip6nhTcp float64 `xml:"ip6nh-tcp"` - Ip6nhUdp float64 `xml:"ip6nh-udp"` - Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` - PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` - TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` - PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` - FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` - HeaderType []struct { - Text string `xml:",chardata"` - HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` - LinkLocals float64 `xml:"link-locals"` - Globals float64 `xml:"globals"` - AddressScope float64 `xml:"address-scope"` - HexValue float64 `xml:"hex-value"` - } `xml:"header-type"` - ForwardCacheHit float64 `xml:"forward-cache-hit"` - ForwardCacheMiss float64 `xml:"forward-cache-miss"` - Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` - Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` - Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` - PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` - TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` - PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` - } `xml:"ip6"` - Icmp6 struct { - Text string `xml:",chardata"` - ProtocolName string `xml:"protocol-name"` - CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` - ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` - ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` - OutputHistogram struct { - Text string `xml:",chardata"` - Style string `xml:"style,attr"` - HistogramType string `xml:"histogram-type"` - UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` - Icmp6Echo string `xml:"icmp6-echo"` - Icmp6EchoReply string `xml:"icmp6-echo-reply"` - NeighborSolicitation string `xml:"neighbor-solicitation"` - NeighborAdvertisement string `xml:"neighbor-advertisement"` - } `xml:"output-histogram"` - Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` - MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` - BadChecksums string `xml:"bad-checksums"` - Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` - InputHistogram struct { - Text string `xml:",chardata"` - Style string `xml:"style,attr"` - HistogramType string `xml:"histogram-type"` - UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` - PacketTooBig string `xml:"packet-too-big"` - TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` - Icmp6Echo string `xml:"icmp6-echo"` - Icmp6EchoReply string `xml:"icmp6-echo-reply"` - RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` - NeighborSolicitation string `xml:"neighbor-solicitation"` - NeighborAdvertisement string `xml:"neighbor-advertisement"` - } `xml:"input-histogram"` - HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` - NoRoute string `xml:"no-route"` - AdministrativelyProhibited string `xml:"administratively-prohibited"` - BeyondScope string `xml:"beyond-scope"` - AddressUnreachable string `xml:"address-unreachable"` - PortUnreachable string `xml:"port-unreachable"` - PacketTooBig string `xml:"packet-too-big"` - TimeExceedTransit string `xml:"time-exceed-transit"` - TimeExceedReassembly string `xml:"time-exceed-reassembly"` - ErroneousHeaderField string `xml:"erroneous-header-field"` - UnrecognizedNextHeader string `xml:"unrecognized-next-header"` - UnrecognizedOption string `xml:"unrecognized-option"` - Redirect string `xml:"redirect"` - Unknown string `xml:"unknown"` - Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` - MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` - NdSystemMax string `xml:"nd-system-max"` - NdPublicMax string `xml:"nd-public-max"` - NdIriMax string `xml:"nd-iri-max"` - NdMgtMax string `xml:"nd-mgt-max"` - NdPublicCnt string `xml:"nd-public-cnt"` - NdIriCnt string `xml:"nd-iri-cnt"` - NdMgtCnt string `xml:"nd-mgt-cnt"` - NdSystemDrop string `xml:"nd-system-drop"` - NdPublicDrop string `xml:"nd-public-drop"` - NdIriDrop string `xml:"nd-iri-drop"` - NdMgtDrop string `xml:"nd-mgt-drop"` - Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` - Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` - Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` - Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` - Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` - Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` - Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` - Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` - Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` - Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` - Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` - Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` - Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` - Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` - Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` - Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` - Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` - Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` - Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` - Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` - } `xml:"icmp6"` - Mpls struct { - Text string `xml:",chardata"` - TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` - PacketsForwarded string `xml:"packets-forwarded"` - PacketsDropped string `xml:"packets-dropped"` - PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` - AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` - PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` - PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` - PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` - LspPingPackets string `xml:"lsp-ping-packets"` - PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` - PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` - PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` - PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` - PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` - PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` - PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` - PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` - } `xml:"mpls"` - } `xml:"statistics"` - Cli struct { - Text string `xml:",chardata"` - Banner string `xml:"banner"` - } `xml:"cli"` + //XMLName xml.Name `xml:"rpc-reply"` + //Text string `xml:",chardata"` + //Junos string `xml:"junos,attr"` + rpcReply rpcReply `xml:"rpc-reply"` + Statistics Statistics `xml:"statistics"` + /* + Cli struct { + Text string `xml:",chardata"` + Banner string `xml:"banner"` + } `xml:"cli"` + */ +} + +type rpcReply struct { + XMLName xml.Name `xml:"rpc-reply"` +} +type Statistics struct { + Text string `xml:",chardata"` + Tcp struct { + Text string `xml:",chardata"` + PacketsSent float64 `xml:"packets-sent"` + SentDataPackets float64 `xml:"sent-data-packets"` + DataPacketsBytes float64 `xml:"data-packets-bytes"` + SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` + RetransmittedBytes float64 `xml:"retransmitted-bytes"` + SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` + SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` + SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` + SentPacketsDelayed float64 `xml:"sent-packets-delayed"` + SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` + SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` + SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` + SentControlPackets float64 `xml:"sent-control-packets"` + PacketsReceived float64 `xml:"packets-received"` + ReceivedAcks float64 `xml:"received-acks"` + AcksBytes float64 `xml:"acks-bytes"` + ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` + ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` + PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` + InSequenceBytes float64 `xml:"in-sequence-bytes"` + ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` + DuplicateInBytes float64 `xml:"duplicate-in-bytes"` + ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` + ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` + SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` + ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` + OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` + ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` + Bytes float64 `xml:"bytes"` + ReceivedWindowProbes float64 `xml:"received-window-probes"` + ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` + PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` + ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` + ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` + ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` + ConnectionRequests float64 `xml:"connection-requests"` + ConnectionAccepts float64 `xml:"connection-accepts"` + BadConnectionAttempts float64 `xml:"bad-connection-attempts"` + ListenQueueOverflows float64 `xml:"listen-queue-overflows"` + BadRstWindow float64 `xml:"bad-rst-window"` + ConnectionsEstablished float64 `xml:"connections-established"` + ConnectionsClosed float64 `xml:"connections-closed"` + Drops float64 `xml:"drops"` + ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` + ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` + ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` + EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` + SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` + Attempts float64 `xml:"attempts"` + RetransmitTimeouts float64 `xml:"retransmit-timeouts"` + ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` + PersistTimeouts float64 `xml:"persist-timeouts"` + ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` + KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` + KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` + KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` + AckHeaderPredictions float64 `xml:"ack-header-predictions"` + DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` + SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` + Retransmitted float64 `xml:"retransmitted"` + Dupsyn float64 `xml:"dupsyn"` + Dropped float64 `xml:"dropped"` + Completed float64 `xml:"completed"` + BucketOverflow float64 `xml:"bucket-overflow"` + CacheOverflow float64 `xml:"cache-overflow"` + Reset float64 `xml:"reset"` + Stale float64 `xml:"stale"` + Aborted float64 `xml:"aborted"` + Badack float64 `xml:"badack"` + Unreach float64 `xml:"unreach"` + ZoneFailures float64 `xml:"zone-failures"` + CookiesSent float64 `xml:"cookies-sent"` + CookiesReceived float64 `xml:"cookies-received"` + SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` + SegmentRetransmits float64 `xml:"segment-retransmits"` + ByteRetransmits float64 `xml:"byte-retransmits"` + SackOptionsReceived float64 `xml:"sack-options-received"` + SackOpitionsSent float64 `xml:"sack-opitions-sent"` + SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` + AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` + AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` + RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` + OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` + RstPackets float64 `xml:"rst-packets"` + IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` + SendPacketsDropped float64 `xml:"send-packets-dropped"` + RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` + OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` + ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` + ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` + ReceivedMacDropped float64 `xml:"received-mac-dropped"` + ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` + ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` + FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` + ReceivedDosAttack float64 `xml:"received-dos-attack"` + ReceivedBadSynack float64 `xml:"received-bad-synack"` + SyncacheZoneFull float64 `xml:"syncache-zone-full"` + ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` + ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` + ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` + ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` + ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` + ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` + ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` + ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` + ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` + ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` + ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` + OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` + OptionWindowLength float64 `xml:"option-window-length"` + OptionTimestampLength float64 `xml:"option-timestamp-length"` + OptionMd5Length float64 `xml:"option-md5-length"` + OptionAuthLength float64 `xml:"option-auth-length"` + OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` + OptionSackLength float64 `xml:"option-sack-length"` + OptionAuthoptionLength float64 `xml:"option-authoption-length"` + } `xml:"tcp"` + Udp struct { + Text string `xml:",chardata"` + DatagramsReceived float64 `xml:"datagrams-received"` + DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` + DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` + DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` + DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` + BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` + DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` + DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` + DatagramsDelivered float64 `xml:"datagrams-delivered"` + DatagramsOutput float64 `xml:"datagrams-output"` + } `xml:"udp"` + Ip IP `xml:"ip"` + Icmp struct { + Text string `xml:",chardata"` + DropsDueToRateLimit string `xml:"drops-due-to-rate-limit"` + CallsToIcmpError string `xml:"calls-to-icmp-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmp string `xml:"errors-not-generated-because-old-message-was-icmp"` + Histogram []struct { + Text string `xml:",chardata"` + TypeOfHistogram string `xml:"type-of-histogram"` + IcmpEchoReply string `xml:"icmp-echo-reply"` + DestinationUnreachable string `xml:"destination-unreachable"` + IcmpEcho string `xml:"icmp-echo"` + TimeStampReply string `xml:"time-stamp-reply"` + TimeExceeded string `xml:"time-exceeded"` + TimeStamp string `xml:"time-stamp"` + AddressMaskRequest string `xml:"address-mask-request"` + AnEndpointChangedItsCookiesecret string `xml:"an-endpoint-changed-its-cookiesecret"` + } `xml:"histogram"` + MessagesWithBadCodeFields string `xml:"messages-with-bad-code-fields"` + MessagesLessThanTheMinimumLength string `xml:"messages-less-than-the-minimum-length"` + MessagesWithBadChecksum string `xml:"messages-with-bad-checksum"` + MessagesWithBadSourceAddress string `xml:"messages-with-bad-source-address"` + MessagesWithBadLength string `xml:"messages-with-bad-length"` + EchoDropsWithBroadcastOrMulticastDestinatonAddress string `xml:"echo-drops-with-broadcast-or-multicast-destinaton-address"` + TimestampDropsWithBroadcastOrMulticastDestinationAddress string `xml:"timestamp-drops-with-broadcast-or-multicast-destination-address"` + MessageResponsesGenerated string `xml:"message-responses-generated"` + } `xml:"icmp"` + Arp struct { + Text string `xml:",chardata"` + DatagramsReceived string `xml:"datagrams-received"` + ArpRequestsReceived string `xml:"arp-requests-received"` + ArpRepliesReceived string `xml:"arp-replies-received"` + ResolutionRequestReceived string `xml:"resolution-request-received"` + ResolutionRequestDropped string `xml:"resolution-request-dropped"` + UnrestrictedProxyRequests string `xml:"unrestricted-proxy-requests"` + RestrictedProxyRequests string `xml:"restricted-proxy-requests"` + ReceivedProxyRequests string `xml:"received-proxy-requests"` + ProxyRequestsNotProxied string `xml:"proxy-requests-not-proxied"` + RestrictedProxyRequestsNotProxied string `xml:"restricted-proxy-requests-not-proxied"` + DatagramsWithBogusInterface string `xml:"datagrams-with-bogus-interface"` + DatagramsWithIncorrectLength string `xml:"datagrams-with-incorrect-length"` + DatagramsForNonIpProtocol string `xml:"datagrams-for-non-ip-protocol"` + DatagramsWithUnsupportedOpcode string `xml:"datagrams-with-unsupported-opcode"` + DatagramsWithBadProtocolAddressLength string `xml:"datagrams-with-bad-protocol-address-length"` + DatagramsWithBadHardwareAddressLength string `xml:"datagrams-with-bad-hardware-address-length"` + DatagramsWithMulticastSourceAddress string `xml:"datagrams-with-multicast-source-address"` + DatagramsWithMulticastTargetAddress string `xml:"datagrams-with-multicast-target-address"` + DatagramsWithMyOwnHardwareAddress string `xml:"datagrams-with-my-own-hardware-address"` + DatagramsForAnAddressNotOnTheInterface string `xml:"datagrams-for-an-address-not-on-the-interface"` + DatagramsWithABroadcastSourceAddress string `xml:"datagrams-with-a-broadcast-source-address"` + DatagramsWithSourceAddressDuplicateToMine string `xml:"datagrams-with-source-address-duplicate-to-mine"` + DatagramsWhichWereNotForMe string `xml:"datagrams-which-were-not-for-me"` + PacketsDiscardedWaitingForResolution string `xml:"packets-discarded-waiting-for-resolution"` + PacketsSentAfterWaitingForResolution string `xml:"packets-sent-after-waiting-for-resolution"` + ArpRequestsSent string `xml:"arp-requests-sent"` + ArpRepliesSent string `xml:"arp-replies-sent"` + RequestsForMemoryDenied string `xml:"requests-for-memory-denied"` + RequestsDroppedOnEntry string `xml:"requests-dropped-on-entry"` + RequestsDroppedDuringRetry string `xml:"requests-dropped-during-retry"` + RequestsDroppedDueToInterfaceDeletion string `xml:"requests-dropped-due-to-interface-deletion"` + RequestsOnUnnumberedInterfaces string `xml:"requests-on-unnumbered-interfaces"` + NewRequestsOnUnnumberedInterfaces string `xml:"new-requests-on-unnumbered-interfaces"` + RepliesFromUnnumberedInterfaces string `xml:"replies-from-unnumbered-interfaces"` + RequestsOnUnnumberedInterfaceWithNonSubnettedDonor string `xml:"requests-on-unnumbered-interface-with-non-subnetted-donor"` + RepliesFromUnnumberedInterfaceWithNonSubnettedDonor string `xml:"replies-from-unnumbered-interface-with-non-subnetted-donor"` + ArpPacketsRejectedAsFamilyIsConfiguredWithDenyArp string `xml:"arp-packets-rejected-as-family-is-configured-with-deny-arp"` + ArpResponsePacketsAreRejectedOnMcAeIclInterface string `xml:"arp-response-packets-are-rejected-on-mc-ae-icl-interface"` + ArpRepliesAreRejectedAsSourceAndDestinationIsSame string `xml:"arp-replies-are-rejected-as-source-and-destination-is-same"` + ArpProbeForProxyAddressReachableFromTheIncomingInterface string `xml:"arp-probe-for-proxy-address-reachable-from-the-incoming-interface"` + ArpRequestDiscardedForVrrpSourceAddress string `xml:"arp-request-discarded-for-vrrp-source-address"` + SelfArpRequestPacketReceivedOnIrbInterface string `xml:"self-arp-request-packet-received-on-irb-interface"` + ProxyArpRequestDiscardedAsSourceIpIsAProxyTarget string `xml:"proxy-arp-request-discarded-as-source-ip-is-a-proxy-target"` + ArpPacketsAreDroppedAsNexthopAllocationFailed string `xml:"arp-packets-are-dropped-as-nexthop-allocation-failed"` + ArpPacketsReceivedFromPeerVrrpRouterAndDiscarded string `xml:"arp-packets-received-from-peer-vrrp-router-and-discarded"` + ArpPacketsAreRejectedAsTargetIpArpResolveIsInProgress string `xml:"arp-packets-are-rejected-as-target-ip-arp-resolve-is-in-progress"` + GratArpPacketsAreIgnoredAsMacAddressIsNotChanged string `xml:"grat-arp-packets-are-ignored-as-mac-address-is-not-changed"` + ArpPacketsAreDroppedFromPeerVrrp string `xml:"arp-packets-are-dropped-from-peer-vrrp"` + ArpPacketsAreDroppedAsDriverCallFailed string `xml:"arp-packets-are-dropped-as-driver-call-failed"` + ArpPacketsAreDroppedAsSourceIsNotValidated string `xml:"arp-packets-are-dropped-as-source-is-not-validated"` + ArpSystemMax string `xml:"arp-system-max"` + ArpPublicMax string `xml:"arp-public-max"` + ArpIriMax string `xml:"arp-iri-max"` + ArpMgtMax string `xml:"arp-mgt-max"` + ArpPublicCnt string `xml:"arp-public-cnt"` + ArpIriCnt string `xml:"arp-iri-cnt"` + ArpMgtCnt string `xml:"arp-mgt-cnt"` + ArpSystemDrop string `xml:"arp-system-drop"` + ArpPublicDrop string `xml:"arp-public-drop"` + ArpIriDrop string `xml:"arp-iri-drop"` + ArpMgtDrop string `xml:"arp-mgt-drop"` + } `xml:"arp"` + Ip6 IP6 `xml:"ip6"` + Icmp6 struct { + Text string `xml:",chardata"` + ProtocolName string `xml:"protocol-name"` + CallsToIcmp6Error string `xml:"calls-to-icmp6-error"` + ErrorsNotGeneratedBecauseOldMessageWasIcmpError string `xml:"errors-not-generated-because-old-message-was-icmp-error"` + ErrorsNotGeneratedBecauseRateLimitation string `xml:"errors-not-generated-because-rate-limitation"` + OutputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"output-histogram"` + Icmp6MessagesWithBadCodeFields string `xml:"icmp6-messages-with-bad-code-fields"` + MessagesLessThanMinimumLength string `xml:"messages-less-than-minimum-length"` + BadChecksums string `xml:"bad-checksums"` + Icmp6MessagesWithBadLength string `xml:"icmp6-messages-with-bad-length"` + InputHistogram struct { + Text string `xml:",chardata"` + Style string `xml:"style,attr"` + HistogramType string `xml:"histogram-type"` + UnreachableIcmp6Packets string `xml:"unreachable-icmp6-packets"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceededIcmp6Packets string `xml:"time-exceeded-icmp6-packets"` + Icmp6Echo string `xml:"icmp6-echo"` + Icmp6EchoReply string `xml:"icmp6-echo-reply"` + RouterSolicitationIcmp6Packets string `xml:"router-solicitation-icmp6-packets"` + NeighborSolicitation string `xml:"neighbor-solicitation"` + NeighborAdvertisement string `xml:"neighbor-advertisement"` + } `xml:"input-histogram"` + HistogramOfErrorMessagesToBeGenerated string `xml:"histogram-of-error-messages-to-be-generated"` + NoRoute string `xml:"no-route"` + AdministrativelyProhibited string `xml:"administratively-prohibited"` + BeyondScope string `xml:"beyond-scope"` + AddressUnreachable string `xml:"address-unreachable"` + PortUnreachable string `xml:"port-unreachable"` + PacketTooBig string `xml:"packet-too-big"` + TimeExceedTransit string `xml:"time-exceed-transit"` + TimeExceedReassembly string `xml:"time-exceed-reassembly"` + ErroneousHeaderField string `xml:"erroneous-header-field"` + UnrecognizedNextHeader string `xml:"unrecognized-next-header"` + UnrecognizedOption string `xml:"unrecognized-option"` + Redirect string `xml:"redirect"` + Unknown string `xml:"unknown"` + Icmp6MessageResponsesGenerated string `xml:"icmp6-message-responses-generated"` + MessagesWithTooManyNdOptions string `xml:"messages-with-too-many-nd-options"` + NdSystemMax string `xml:"nd-system-max"` + NdPublicMax string `xml:"nd-public-max"` + NdIriMax string `xml:"nd-iri-max"` + NdMgtMax string `xml:"nd-mgt-max"` + NdPublicCnt string `xml:"nd-public-cnt"` + NdIriCnt string `xml:"nd-iri-cnt"` + NdMgtCnt string `xml:"nd-mgt-cnt"` + NdSystemDrop string `xml:"nd-system-drop"` + NdPublicDrop string `xml:"nd-public-drop"` + NdIriDrop string `xml:"nd-iri-drop"` + NdMgtDrop string `xml:"nd-mgt-drop"` + Nd6NdpProxyRequests string `xml:"nd6-ndp-proxy-requests"` + Nd6DadProxyRequests string `xml:"nd6-dad-proxy-requests"` + Nd6NdpProxyResponses string `xml:"nd6-ndp-proxy-responses"` + Nd6DadProxyConflicts string `xml:"nd6-dad-proxy-conflicts"` + Nd6DupProxyResponses string `xml:"nd6-dup-proxy-responses"` + Nd6NdpProxyResolveCnt string `xml:"nd6-ndp-proxy-resolve-cnt"` + Nd6DadProxyResolveCnt string `xml:"nd6-dad-proxy-resolve-cnt"` + Nd6DadProxyEqmacDrop string `xml:"nd6-dad-proxy-eqmac-drop"` + Nd6DadProxyNomacDrop string `xml:"nd6-dad-proxy-nomac-drop"` + Nd6NdpProxyUnrRequests string `xml:"nd6-ndp-proxy-unr-requests"` + Nd6DadProxyUnrRequests string `xml:"nd6-dad-proxy-unr-requests"` + Nd6NdpProxyUnrResponses string `xml:"nd6-ndp-proxy-unr-responses"` + Nd6DadProxyUnrConflicts string `xml:"nd6-dad-proxy-unr-conflicts"` + Nd6DadProxyUnrResponses string `xml:"nd6-dad-proxy-unr-responses"` + Nd6NdpProxyUnrResolveCnt string `xml:"nd6-ndp-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrResolveCnt string `xml:"nd6-dad-proxy-unr-resolve-cnt"` + Nd6DadProxyUnrEqportDrop string `xml:"nd6-dad-proxy-unr-eqport-drop"` + Nd6DadProxyUnrNomacDrop string `xml:"nd6-dad-proxy-unr-nomac-drop"` + Nd6RequestsDroppedOnEntry string `xml:"nd6-requests-dropped-on-entry"` + Nd6RequestsDroppedDuringRetry string `xml:"nd6-requests-dropped-during-retry"` + } `xml:"icmp6"` + Mpls struct { + Text string `xml:",chardata"` + TotalMplsPacketsReceived string `xml:"total-mpls-packets-received"` + PacketsForwarded string `xml:"packets-forwarded"` + PacketsDropped string `xml:"packets-dropped"` + PacketsWithHeaderTooSmall string `xml:"packets-with-header-too-small"` + AfterTaggingPacketsCanNotFitLinkMtu string `xml:"after-tagging-packets-can-not-fit-link-mtu"` + PacketsWithIpv4ExplicitNullTag string `xml:"packets-with-ipv4-explicit-null-tag"` + PacketsWithIpv4ExplicitNullChecksumErrors string `xml:"packets-with-ipv4-explicit-null-checksum-errors"` + PacketsWithRouterAlertTag string `xml:"packets-with-router-alert-tag"` + LspPingPackets string `xml:"lsp-ping-packets"` + PacketsWithTtlExpired string `xml:"packets-with-ttl-expired"` + PacketsWithTagEncodingError string `xml:"packets-with-tag-encoding-error"` + PacketsDiscardedDueToNoRoute string `xml:"packets-discarded-due-to-no-route"` + PacketsUsedFirstNexthopInEcmpUnilist string `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + PacketsDroppedDueToIflDown string `xml:"packets-dropped-due-to-ifl-down"` + PacketsDroppedAtMplsSocketSend string `xml:"packets-dropped-at-mpls-socket-send"` + PacketsForwardedAtMplsSocketSend string `xml:"packets-forwarded-at-mpls-socket-send"` + PacketsDroppedAtP2mpCnhOutput string `xml:"packets-dropped-at-p2mp-cnh-output"` + } `xml:"mpls"` +} + +type IP struct { + Text string `xml:",chardata"` + PacketsReceived float64 `xml:"packets-received"` + BadHeaderChecksums float64 `xml:"bad-header-checksums"` + PacketsWithSizeSmallerThanMinimum float64 `xml:"packets-with-size-smaller-than-minimum"` + PacketsWithDataSizeLessThanDatalength float64 `xml:"packets-with-data-size-less-than-datalength"` + PacketsWithHeaderLengthLessThanDataSize float64 `xml:"packets-with-header-length-less-than-data-size"` + PacketsWithDataLengthLessThanHeaderlength float64 `xml:"packets-with-data-length-less-than-headerlength"` + PacketsWithIncorrectVersionNumber float64 `xml:"packets-with-incorrect-version-number"` + PacketsDestinedToDeadNextHop float64 `xml:"packets-destined-to-dead-next-hop"` + FragmentsReceived float64 `xml:"fragments-received"` + FragmentsDroppedDueToOutofspaceOrDup float64 `xml:"fragments-dropped-due-to-outofspace-or-dup"` + FragmentsDroppedDueToQueueoverflow float64 `xml:"fragments-dropped-due-to-queueoverflow"` + FragmentsDroppedAfterTimeout float64 `xml:"fragments-dropped-after-timeout"` + PacketsReassembledOk float64 `xml:"packets-reassembled-ok"` + PacketsForThisHost float64 `xml:"packets-for-this-host"` + PacketsForUnknownOrUnsupportedProtocol float64 `xml:"packets-for-unknown-or-unsupported-protocol"` + PacketsForwarded float64 `xml:"packets-forwarded"` + PacketsNotForwardable float64 `xml:"packets-not-forwardable"` + RedirectsSent float64 `xml:"redirects-sent"` + PacketsSentFromThisHost float64 `xml:"packets-sent-from-this-host"` + PacketsSentWithFabricatedIpHeader float64 `xml:"packets-sent-with-fabricated-ip-header"` + OutputPacketsDroppedDueToNoBufs float64 `xml:"output-packets-dropped-due-to-no-bufs"` + OutputPacketsDiscardedDueToNoRoute float64 `xml:"output-packets-discarded-due-to-no-route"` + OutputDatagramsFragmented float64 `xml:"output-datagrams-fragmented"` + FragmentsCreated float64 `xml:"fragments-created"` + DatagramsThatCanNotBeFragmented float64 `xml:"datagrams-that-can-not-be-fragmented"` + PacketsWithBadOptions float64 `xml:"packets-with-bad-options"` + PacketsWithOptionsHandledWithoutError float64 `xml:"packets-with-options-handled-without-error"` + StrictSourceAndRecordRouteOptions float64 `xml:"strict-source-and-record-route-options"` + LooseSourceAndRecordRouteOptions float64 `xml:"loose-source-and-record-route-options"` + RecordRouteOptions float64 `xml:"record-route-options"` + TimestampOptions float64 `xml:"timestamp-options"` + TimestampAndAddressOptions float64 `xml:"timestamp-and-address-options"` + TimestampAndPrespecifiedAddressOptions float64 `xml:"timestamp-and-prespecified-address-options"` + OptionPacketsDroppedDueToRateLimit float64 `xml:"option-packets-dropped-due-to-rate-limit"` + RouterAlertOptions float64 `xml:"router-alert-options"` + MulticastPacketsDropped float64 `xml:"multicast-packets-dropped"` + PacketsDropped float64 `xml:"packets-dropped"` + TransitRePacketsDroppedOnMgmtInterface float64 `xml:"transit-re-packets-dropped-on-mgmt-interface"` + PacketsUsedFirstNexthopInEcmpUnilist float64 `xml:"packets-used-first-nexthop-in-ecmp-unilist"` + IncomingTtpoipPacketsReceived float64 `xml:"incoming-ttpoip-packets-received"` + IncomingTtpoipPacketsDropped float64 `xml:"incoming-ttpoip-packets-dropped"` + OutgoingTtpoipPacketsSent float64 `xml:"outgoing-ttpoip-packets-sent"` + OutgoingTtpoipPacketsDropped float64 `xml:"outgoing-ttpoip-packets-dropped"` + IncomingRawipPacketsDroppedNoSocketBuffer float64 `xml:"incoming-rawip-packets-dropped-no-socket-buffer"` + IncomingVirtualNodePacketsDelivered float64 `xml:"incoming-virtual-node-packets-delivered"` +} + +type IP6 struct { + Text string `xml:",chardata"` + TotalPacketsReceived float64 `xml:"total-packets-received"` + Ip6PacketsWithSizeSmallerThanMinimum float64 `xml:"ip6-packets-with-size-smaller-than-minimum"` + PacketsWithDatasizeLessThanDataLength float64 `xml:"packets-with-datasize-less-than-data-length"` + Ip6PacketsWithBadOptions float64 `xml:"ip6-packets-with-bad-options"` + Ip6PacketsWithIncorrectVersionNumber float64 `xml:"ip6-packets-with-incorrect-version-number"` + Ip6FragmentsReceived float64 `xml:"ip6-fragments-received"` + DuplicateOrOutOfSpaceFragmentsDropped float64 `xml:"duplicate-or-out-of-space-fragments-dropped"` + Ip6FragmentsDroppedAfterTimeout float64 `xml:"ip6-fragments-dropped-after-timeout"` + FragmentsThatExceededLimit float64 `xml:"fragments-that-exceeded-limit"` + Ip6PacketsReassembledOk float64 `xml:"ip6-packets-reassembled-ok"` + Ip6PacketsForThisHost float64 `xml:"ip6-packets-for-this-host"` + Ip6PacketsForwarded float64 `xml:"ip6-packets-forwarded"` + Ip6PacketsNotForwardable float64 `xml:"ip6-packets-not-forwardable"` + Ip6RedirectsSent float64 `xml:"ip6-redirects-sent"` + Ip6PacketsSentFromThisHost float64 `xml:"ip6-packets-sent-from-this-host"` + Ip6PacketsSentWithFabricatedIpHeader float64 `xml:"ip6-packets-sent-with-fabricated-ip-header"` + Ip6OutputPacketsDroppedDueToNoBufs float64 `xml:"ip6-output-packets-dropped-due-to-no-bufs"` + Ip6OutputPacketsDiscardedDueToNoRoute float64 `xml:"ip6-output-packets-discarded-due-to-no-route"` + Ip6OutputDatagramsFragmented float64 `xml:"ip6-output-datagrams-fragmented"` + Ip6FragmentsCreated float64 `xml:"ip6-fragments-created"` + Ip6DatagramsThatCanNotBeFragmented float64 `xml:"ip6-datagrams-that-can-not-be-fragmented"` + PacketsThatViolatedScopeRules float64 `xml:"packets-that-violated-scope-rules"` + MulticastPacketsWhichWeDoNotJoin float64 `xml:"multicast-packets-which-we-do-not-join"` + Histogram string `xml:"histogram"` + Ip6nhTcp float64 `xml:"ip6nh-tcp"` + Ip6nhUdp float64 `xml:"ip6nh-udp"` + Ip6nhIcmp6 float64 `xml:"ip6nh-icmp6"` + PacketsWhoseHeadersAreNotContinuous float64 `xml:"packets-whose-headers-are-not-continuous"` + TunnelingPacketsThatCanNotFindGif float64 `xml:"tunneling-packets-that-can-not-find-gif"` + PacketsDiscardedDueToTooMayHeaders float64 `xml:"packets-discarded-due-to-too-may-headers"` + FailuresOfSourceAddressSelection float64 `xml:"failures-of-source-address-selection"` + HeaderType []HeaderType `xml:"header-type"` + ForwardCacheHit float64 `xml:"forward-cache-hit"` + ForwardCacheMiss float64 `xml:"forward-cache-miss"` + Ip6PacketsDestinedToDeadNextHop float64 `xml:"ip6-packets-destined-to-dead-next-hop"` + Ip6OptionPacketsDroppedDueToRateLimit float64 `xml:"ip6-option-packets-dropped-due-to-rate-limit"` + Ip6PacketsDropped float64 `xml:"ip6-packets-dropped"` + PacketsDroppedDueToBadProtocol float64 `xml:"packets-dropped-due-to-bad-protocol"` + TransitRePacketDroppedOnMgmtInterface float64 `xml:"transit-re-packet-dropped-on-mgmt-interface"` + PacketUsedFirstNexthopInEcmpUnilist float64 `xml:"packet-used-first-nexthop-in-ecmp-unilist"` +} +type HeaderType struct { + Text string `xml:",chardata"` + HeaderForSourceAddressSelection string `xml:"header-for-source-address-selection"` + LinkLocals float64 `xml:"link-locals"` + Globals float64 `xml:"globals"` + AddressScope float64 `xml:"address-scope"` + HexValue float64 `xml:"hex-value"` } \ No newline at end of file diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index f65c1018..f833730f 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -140,11 +140,11 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { HeaderType: []HeaderType{ { LinkLocals: 2030, - Globals: 2031, + Globals: 2031, }, { LinkLocals: 2100, - Globals: 2101, + Globals: 2101, }, }, ForwardCacheHit: 2032, @@ -174,7 +174,7 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { } result.Statistics.Ip6.Text = "" - assert.Equal(t, tc.expect.Statistics.Ip6, result.Statistics.Ip6, tc.name) + assert.Equal(t, tc.expect.Statistics.Ip6.TotalPacketsReceived, result.Statistics.Ip6.TotalPacketsReceived, tc.name) assert.NoError(t, err, "unmarshal should not return error") }) } @@ -264,7 +264,7 @@ func TestStatisticsIPv66Unmarshaling(t *testing.T) { } } - */ +*/ func TestStatisticsUDPUnmarshaling(t *testing.T) { UDPXMLDataCase1, _ := os.Open("testsFiles/UDP/UDPTestDataCase1.xml") diff --git a/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml index 5b219174..4a124431 100644 --- a/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml +++ b/pkg/features/systemstatistics/testsFiles/IPv6/ipv6TestDataCase1.xml @@ -1,4 +1,4 @@ - + 2000 @@ -49,5 +49,7 @@ 2039 - user@router> + + user@router> + \ No newline at end of file From 122744033d35df92706c2e4054955ab9132a4d72 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Wed, 3 Sep 2025 17:17:00 +0200 Subject: [PATCH 20/27] fixed one, but not the last one issue in IPv6 testing --- pkg/features/systemstatistics/rpc.go | 5 ++--- pkg/features/systemstatistics/rpc_test.go | 14 ++++++++++---- .../{IPV4 => IPv4}/ipv4TestDataCase1.xml | 0 .../{IPV4 => IPv4}/ipv4TestDataCase2.xml | 0 .../{IPV4 => IPv4}/ipv4TestDataCase3.xml | 0 5 files changed, 12 insertions(+), 7 deletions(-) rename pkg/features/systemstatistics/testsFiles/{IPV4 => IPv4}/ipv4TestDataCase1.xml (100%) rename pkg/features/systemstatistics/testsFiles/{IPV4 => IPv4}/ipv4TestDataCase2.xml (100%) rename pkg/features/systemstatistics/testsFiles/{IPV4 => IPv4}/ipv4TestDataCase3.xml (100%) diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go index 1470897c..5bf34693 100644 --- a/pkg/features/systemstatistics/rpc.go +++ b/pkg/features/systemstatistics/rpc.go @@ -3,17 +3,16 @@ package systemstatistics import "encoding/xml" type SystemStatistics struct { - //XMLName xml.Name `xml:"rpc-reply"` + XMLName xml.Name `xml:"rpc-reply"` //Text string `xml:",chardata"` //Junos string `xml:"junos,attr"` rpcReply rpcReply `xml:"rpc-reply"` Statistics Statistics `xml:"statistics"` - /* Cli struct { Text string `xml:",chardata"` Banner string `xml:"banner"` } `xml:"cli"` - */ + } type rpcReply struct { diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index f833730f..2098e250 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,6 +2,7 @@ package systemstatistics import ( "encoding/xml" + "fmt" "io" "os" "testing" @@ -19,7 +20,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { testsIPV4 := []testCase{ { name: "complete_ipv4_statistics", - xmlFile: "testsFiles/IPV4/ipv4TestDataCase1.xml", + xmlFile: "testsFiles/IPv4/ipv4TestDataCase1.xml", expect: SystemStatistics{ Statistics: Statistics{ Ip: IP{ @@ -100,10 +101,10 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { expect SystemStatistics } - testsIPV4 := []testCase{ + testsIPV6 := []testCase{ { name: "complete_ipv6_statistics", - xmlFile: "testsFiles/IPV6/ipv6TestDataCase1.xml", + xmlFile: "testsFiles/IPv6/ipv6TestDataCase1.xml", expect: SystemStatistics{ Statistics: Statistics{ Ip6: IP6{ @@ -161,7 +162,7 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { }, } - for _, tc := range testsIPV4 { + for _, tc := range testsIPV6 { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { @@ -172,8 +173,13 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { if err != nil { } + fmt.Printf("total packets received is %v", result.Statistics.Ip6.TotalPacketsReceived) + result.Statistics.Text = "" result.Statistics.Ip6.Text = "" + tc.expect.Statistics.Text = "" + tc.expect.Statistics.Ip6.Text = "" + assert.Equal(t, tc.expect.Statistics.Ip6.TotalPacketsReceived, result.Statistics.Ip6.TotalPacketsReceived, tc.name) assert.NoError(t, err, "unmarshal should not return error") }) diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/IPv4/ipv4TestDataCase1.xml similarity index 100% rename from pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase1.xml rename to pkg/features/systemstatistics/testsFiles/IPv4/ipv4TestDataCase1.xml diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase2.xml b/pkg/features/systemstatistics/testsFiles/IPv4/ipv4TestDataCase2.xml similarity index 100% rename from pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase2.xml rename to pkg/features/systemstatistics/testsFiles/IPv4/ipv4TestDataCase2.xml diff --git a/pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase3.xml b/pkg/features/systemstatistics/testsFiles/IPv4/ipv4TestDataCase3.xml similarity index 100% rename from pkg/features/systemstatistics/testsFiles/IPV4/ipv4TestDataCase3.xml rename to pkg/features/systemstatistics/testsFiles/IPv4/ipv4TestDataCase3.xml From 8d2f8051ebcce44c4eb86e827d3cf16e8f9bc8da Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 08:11:48 +0200 Subject: [PATCH 21/27] finished refactoring tests for ipv6 --- pkg/features/systemstatistics/rpc_test.go | 99 ++--------------------- 1 file changed, 5 insertions(+), 94 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 2098e250..3e4be3f9 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,7 +2,6 @@ package systemstatistics import ( "encoding/xml" - "fmt" "io" "os" "testing" @@ -173,105 +172,17 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { if err != nil { } - fmt.Printf("total packets received is %v", result.Statistics.Ip6.TotalPacketsReceived) - - result.Statistics.Text = "" result.Statistics.Ip6.Text = "" - tc.expect.Statistics.Text = "" - tc.expect.Statistics.Ip6.Text = "" - - assert.Equal(t, tc.expect.Statistics.Ip6.TotalPacketsReceived, result.Statistics.Ip6.TotalPacketsReceived, tc.name) - assert.NoError(t, err, "unmarshal should not return error") - }) - } -} - -// Tests for the IPv6 sub-structure (Ip6) of SystemStatistics. We use inline XML to focus on Ip6. -/* -func TestStatisticsIPv66Unmarshaling(t *testing.T) { - IPv6XMLDataCase1, _ := os.Open("testsFiles/IPv6/ipv6TestDataCase1.xml") - IPv6DataCase1, _ := io.ReadAll(IPv6XMLDataCase1) - type testCase struct { - name string - xmlInput string - expect func(t *testing.T, got SystemStatistics) - } - tests := []testCase{ - { - name: "complete_ipv6_statistics", - xmlInput: string(IPv6DataCase1), - expect: func(t *testing.T, got SystemStatistics) { - ip6 := got.Statistics.Ip6 - assert.Equal(t, float64(100), ip6.TotalPacketsReceived) - assert.Equal(t, float64(1), ip6.Ip6PacketsWithSizeSmallerThanMinimum) - assert.Equal(t, float64(2), ip6.PacketsWithDatasizeLessThanDataLength) - assert.Equal(t, float64(3), ip6.Ip6PacketsWithBadOptions) - assert.Equal(t, float64(4), ip6.Ip6PacketsWithIncorrectVersionNumber) - assert.Equal(t, float64(5), ip6.Ip6FragmentsReceived) - assert.Equal(t, float64(6), ip6.DuplicateOrOutOfSpaceFragmentsDropped) - assert.Equal(t, float64(7), ip6.Ip6FragmentsDroppedAfterTimeout) - assert.Equal(t, float64(8), ip6.FragmentsThatExceededLimit) - assert.Equal(t, float64(9), ip6.Ip6PacketsReassembledOk) - assert.Equal(t, float64(10), ip6.Ip6PacketsForThisHost) - assert.Equal(t, float64(11), ip6.Ip6PacketsForwarded) - assert.Equal(t, float64(12), ip6.Ip6PacketsNotForwardable) - assert.Equal(t, float64(13), ip6.Ip6RedirectsSent) - assert.Equal(t, float64(14), ip6.Ip6PacketsSentFromThisHost) - assert.Equal(t, float64(15), ip6.Ip6PacketsSentWithFabricatedIpHeader) - assert.Equal(t, float64(16), ip6.Ip6OutputPacketsDroppedDueToNoBufs) - assert.Equal(t, float64(17), ip6.Ip6OutputPacketsDiscardedDueToNoRoute) - assert.Equal(t, float64(18), ip6.Ip6OutputDatagramsFragmented) - assert.Equal(t, float64(19), ip6.Ip6FragmentsCreated) - assert.Equal(t, float64(20), ip6.Ip6DatagramsThatCanNotBeFragmented) - assert.Equal(t, float64(21), ip6.PacketsThatViolatedScopeRules) - assert.Equal(t, float64(22), ip6.MulticastPacketsWhichWeDoNotJoin) - assert.Equal(t, float64(23), ip6.Ip6nhTcp) - assert.Equal(t, float64(24), ip6.Ip6nhUdp) - assert.Equal(t, float64(25), ip6.Ip6nhIcmp6) - assert.Equal(t, float64(26), ip6.PacketsWhoseHeadersAreNotContinuous) - assert.Equal(t, float64(27), ip6.TunnelingPacketsThatCanNotFindGif) - assert.Equal(t, float64(28), ip6.PacketsDiscardedDueToTooMayHeaders) - assert.Equal(t, float64(29), ip6.FailuresOfSourceAddressSelection) - assert.Equal(t, 2, len(ip6.HeaderType)) - var defLink, defGlob, polLink, polGlob float64 - for _, h := range ip6.HeaderType { - switch h.HeaderForSourceAddressSelection { - case "default": - defLink = h.LinkLocals - defGlob = h.Globals - case "policy": - polLink = h.LinkLocals - polGlob = h.Globals - } - } - assert.Equal(t, float64(30), defLink) - assert.Equal(t, float64(31), defGlob) - assert.Equal(t, float64(32), polLink) - assert.Equal(t, float64(33), polGlob) - assert.Equal(t, float64(34), ip6.ForwardCacheHit) - assert.Equal(t, float64(35), ip6.ForwardCacheMiss) - assert.Equal(t, float64(36), ip6.Ip6PacketsDestinedToDeadNextHop) - assert.Equal(t, float64(37), ip6.Ip6OptionPacketsDroppedDueToRateLimit) - assert.Equal(t, float64(38), ip6.Ip6PacketsDropped) - assert.Equal(t, float64(39), ip6.PacketsDroppedDueToBadProtocol) - assert.Equal(t, float64(40), ip6.TransitRePacketDroppedOnMgmtInterface) - assert.Equal(t, float64(41), ip6.PacketUsedFirstNexthopInEcmpUnilist) - }, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - var got SystemStatistics - err := xml.Unmarshal([]byte(tc.xmlInput), &got) + for i, _ := range result.Statistics.Ip6.HeaderType { + result.Statistics.Ip6.HeaderType[i].Text = "" + tc.expect.Statistics.Ip6.HeaderType[i].HeaderForSourceAddressSelection = "" + } + assert.Equal(t, tc.expect.Statistics.Ip6, result.Statistics.Ip6, tc.name) assert.NoError(t, err, "unmarshal should not return error") - tc.expect(t, got) }) } } -*/ - func TestStatisticsUDPUnmarshaling(t *testing.T) { UDPXMLDataCase1, _ := os.Open("testsFiles/UDP/UDPTestDataCase1.xml") UDPDataCase1, _ := io.ReadAll(UDPXMLDataCase1) From e451978c94c16ea1fc10c3f08925ada80214e7bd Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 08:28:40 +0200 Subject: [PATCH 22/27] refactored tests for UDP --- pkg/features/systemstatistics/rpc.go | 28 +++++----- pkg/features/systemstatistics/rpc_test.go | 52 +++++++++++++++++++ .../testsFiles/UDP/UDPTestDataCase1.xml | 20 +++---- 3 files changed, 77 insertions(+), 23 deletions(-) diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go index 5bf34693..db178b2a 100644 --- a/pkg/features/systemstatistics/rpc.go +++ b/pkg/features/systemstatistics/rpc.go @@ -139,19 +139,7 @@ type Statistics struct { OptionSackLength float64 `xml:"option-sack-length"` OptionAuthoptionLength float64 `xml:"option-authoption-length"` } `xml:"tcp"` - Udp struct { - Text string `xml:",chardata"` - DatagramsReceived float64 `xml:"datagrams-received"` - DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` - DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` - DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` - DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` - BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` - DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` - DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` - DatagramsDelivered float64 `xml:"datagrams-delivered"` - DatagramsOutput float64 `xml:"datagrams-output"` - } `xml:"udp"` + Udp UDP `xml:"udp"` Ip IP `xml:"ip"` Icmp struct { Text string `xml:",chardata"` @@ -446,4 +434,18 @@ type HeaderType struct { Globals float64 `xml:"globals"` AddressScope float64 `xml:"address-scope"` HexValue float64 `xml:"hex-value"` +} + +type UDP struct { + Text string `xml:",chardata"` + DatagramsReceived float64 `xml:"datagrams-received"` + DatagramsWithIncompleteHeader float64 `xml:"datagrams-with-incomplete-header"` + DatagramsWithBadDatalengthField float64 `xml:"datagrams-with-bad-datalength-field"` + DatagramsWithBadChecksum float64 `xml:"datagrams-with-bad-checksum"` + DatagramsDroppedDueToNoSocket float64 `xml:"datagrams-dropped-due-to-no-socket"` + BroadcastOrMulticastDatagramsDroppedDueToNoSocket float64 `xml:"broadcast-or-multicast-datagrams-dropped-due-to-no-socket"` + DatagramsDroppedDueToFullSocketBuffers float64 `xml:"datagrams-dropped-due-to-full-socket-buffers"` + DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` + DatagramsDelivered float64 `xml:"datagrams-delivered"` + DatagramsOutput float64 `xml:"datagrams-output"` } \ No newline at end of file diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 3e4be3f9..218224b5 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -183,6 +183,56 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { } } +func TestStatisticsUDPUnmarshaling(t *testing.T) { + type testCase struct { + name string + xmlFile string + expect SystemStatistics + } + + testsUDP := []testCase{ + { + name: "complete_udp_statistics", + xmlFile: "testsFiles/UDP/UDPTestDataCase1.xml", + expect: SystemStatistics{ + Statistics: Statistics{ + Udp: UDP{ + DatagramsReceived: 3000, + DatagramsWithIncompleteHeader: 3001, + DatagramsWithBadDatalengthField: 3002, + DatagramsWithBadChecksum: 3003, + DatagramsDroppedDueToNoSocket: 3004, + BroadcastOrMulticastDatagramsDroppedDueToNoSocket: 3005, + DatagramsDroppedDueToFullSocketBuffers: 3006, + DatagramsNotForHashedPcb: 3007, + DatagramsDelivered: 3008, + DatagramsOutput: 3009, + }, + }, + }, + }, + } + + for _, tc := range testsUDP { + t.Run(tc.name, func(t *testing.T) { + fc, err := os.ReadFile(tc.xmlFile) + if err != nil { + + } + var result SystemStatistics + err = xml.Unmarshal(fc, &result) + if err != nil { + + } + + result.Statistics.Udp.Text = "" + assert.Equal(t, tc.expect.Statistics.Udp, result.Statistics.Udp, tc.name) + assert.NoError(t, err, "unmarshal should not return error") + }) + } +} + +/* func TestStatisticsUDPUnmarshaling(t *testing.T) { UDPXMLDataCase1, _ := os.Open("testsFiles/UDP/UDPTestDataCase1.xml") UDPDataCase1, _ := io.ReadAll(UDPXMLDataCase1) @@ -222,6 +272,8 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { }) } } +*/ + func TestStatisticsTCPUnmarshaling(t *testing.T) { TCPXMLDataCase1, _ := os.Open("testsFiles/TCP/TCPTestDataCase1.xml") diff --git a/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml index 721a8c9f..64592244 100644 --- a/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml +++ b/pkg/features/systemstatistics/testsFiles/UDP/UDPTestDataCase1.xml @@ -1,16 +1,16 @@ - 100 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 + 3000 + 3001 + 3002 + 3003 + 3004 + 3005 + 3006 + 3007 + 3008 + 3009 user@router> From f31cebc9a5c2d3ab094d50e7ecd3e26e4fd02b67 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 08:29:17 +0200 Subject: [PATCH 23/27] removing comments --- pkg/features/systemstatistics/rpc_test.go | 61 ++++------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 218224b5..4cc337f0 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -197,16 +197,16 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { expect: SystemStatistics{ Statistics: Statistics{ Udp: UDP{ - DatagramsReceived: 3000, - DatagramsWithIncompleteHeader: 3001, - DatagramsWithBadDatalengthField: 3002, - DatagramsWithBadChecksum: 3003, - DatagramsDroppedDueToNoSocket: 3004, + DatagramsReceived: 3000, + DatagramsWithIncompleteHeader: 3001, + DatagramsWithBadDatalengthField: 3002, + DatagramsWithBadChecksum: 3003, + DatagramsDroppedDueToNoSocket: 3004, BroadcastOrMulticastDatagramsDroppedDueToNoSocket: 3005, - DatagramsDroppedDueToFullSocketBuffers: 3006, - DatagramsNotForHashedPcb: 3007, - DatagramsDelivered: 3008, - DatagramsOutput: 3009, + DatagramsDroppedDueToFullSocketBuffers: 3006, + DatagramsNotForHashedPcb: 3007, + DatagramsDelivered: 3008, + DatagramsOutput: 3009, }, }, }, @@ -232,49 +232,6 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { } } -/* -func TestStatisticsUDPUnmarshaling(t *testing.T) { - UDPXMLDataCase1, _ := os.Open("testsFiles/UDP/UDPTestDataCase1.xml") - UDPDataCase1, _ := io.ReadAll(UDPXMLDataCase1) - type testCase struct { - name string - xmlInput string - expect func(t *testing.T, got SystemStatistics) - } - - tests := []testCase{ - { - name: "complete_udp_statistics", - xmlInput: string(UDPDataCase1), - expect: func(t *testing.T, got SystemStatistics) { - udp := got.Statistics.Udp - assert.Equal(t, float64(100), udp.DatagramsReceived) - assert.Equal(t, float64(1), udp.DatagramsWithIncompleteHeader) - assert.Equal(t, float64(2), udp.DatagramsWithBadDatalengthField) - assert.Equal(t, float64(3), udp.DatagramsWithBadChecksum) - assert.Equal(t, float64(4), udp.DatagramsDroppedDueToNoSocket) - assert.Equal(t, float64(5), udp.BroadcastOrMulticastDatagramsDroppedDueToNoSocket) - assert.Equal(t, float64(6), udp.DatagramsDroppedDueToFullSocketBuffers) - assert.Equal(t, float64(7), udp.DatagramsNotForHashedPcb) - assert.Equal(t, float64(8), udp.DatagramsDelivered) - assert.Equal(t, float64(9), udp.DatagramsOutput) - //assert.Equal(t, "user@router>", got.Cli.Banner) - }, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - var got SystemStatistics - err := xml.Unmarshal([]byte(tc.xmlInput), &got) - assert.NoError(t, err, "unmarshal should not return error") - tc.expect(t, got) - }) - } -} -*/ - - func TestStatisticsTCPUnmarshaling(t *testing.T) { TCPXMLDataCase1, _ := os.Open("testsFiles/TCP/TCPTestDataCase1.xml") TCPDataCase1, _ := io.ReadAll(TCPXMLDataCase1) From cb715ad38bf716cdfc349a1d198c49eb5640f015 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 09:36:08 +0200 Subject: [PATCH 24/27] refactored tests for TCP --- pkg/features/systemstatistics/rpc.go | 240 ++++++++-------- pkg/features/systemstatistics/rpc_test.go | 269 +++++++++--------- .../testsFiles/TCP/TCPTestDataCase1.xml | 234 +++++++-------- 3 files changed, 377 insertions(+), 366 deletions(-) diff --git a/pkg/features/systemstatistics/rpc.go b/pkg/features/systemstatistics/rpc.go index db178b2a..4d3c8b93 100644 --- a/pkg/features/systemstatistics/rpc.go +++ b/pkg/features/systemstatistics/rpc.go @@ -20,125 +20,7 @@ type rpcReply struct { } type Statistics struct { Text string `xml:",chardata"` - Tcp struct { - Text string `xml:",chardata"` - PacketsSent float64 `xml:"packets-sent"` - SentDataPackets float64 `xml:"sent-data-packets"` - DataPacketsBytes float64 `xml:"data-packets-bytes"` - SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` - RetransmittedBytes float64 `xml:"retransmitted-bytes"` - SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` - SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` - SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` - SentPacketsDelayed float64 `xml:"sent-packets-delayed"` - SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` - SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` - SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` - SentControlPackets float64 `xml:"sent-control-packets"` - PacketsReceived float64 `xml:"packets-received"` - ReceivedAcks float64 `xml:"received-acks"` - AcksBytes float64 `xml:"acks-bytes"` - ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` - ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` - PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` - InSequenceBytes float64 `xml:"in-sequence-bytes"` - ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` - DuplicateInBytes float64 `xml:"duplicate-in-bytes"` - ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` - ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` - SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` - ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` - OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` - ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` - Bytes float64 `xml:"bytes"` - ReceivedWindowProbes float64 `xml:"received-window-probes"` - ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` - PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` - ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` - ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` - ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` - ConnectionRequests float64 `xml:"connection-requests"` - ConnectionAccepts float64 `xml:"connection-accepts"` - BadConnectionAttempts float64 `xml:"bad-connection-attempts"` - ListenQueueOverflows float64 `xml:"listen-queue-overflows"` - BadRstWindow float64 `xml:"bad-rst-window"` - ConnectionsEstablished float64 `xml:"connections-established"` - ConnectionsClosed float64 `xml:"connections-closed"` - Drops float64 `xml:"drops"` - ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` - ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` - ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` - EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` - SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` - Attempts float64 `xml:"attempts"` - RetransmitTimeouts float64 `xml:"retransmit-timeouts"` - ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` - PersistTimeouts float64 `xml:"persist-timeouts"` - ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` - KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` - KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` - KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` - AckHeaderPredictions float64 `xml:"ack-header-predictions"` - DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` - SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` - Retransmitted float64 `xml:"retransmitted"` - Dupsyn float64 `xml:"dupsyn"` - Dropped float64 `xml:"dropped"` - Completed float64 `xml:"completed"` - BucketOverflow float64 `xml:"bucket-overflow"` - CacheOverflow float64 `xml:"cache-overflow"` - Reset float64 `xml:"reset"` - Stale float64 `xml:"stale"` - Aborted float64 `xml:"aborted"` - Badack float64 `xml:"badack"` - Unreach float64 `xml:"unreach"` - ZoneFailures float64 `xml:"zone-failures"` - CookiesSent float64 `xml:"cookies-sent"` - CookiesReceived float64 `xml:"cookies-received"` - SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` - SegmentRetransmits float64 `xml:"segment-retransmits"` - ByteRetransmits float64 `xml:"byte-retransmits"` - SackOptionsReceived float64 `xml:"sack-options-received"` - SackOpitionsSent float64 `xml:"sack-opitions-sent"` - SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` - AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` - AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` - RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` - OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` - RstPackets float64 `xml:"rst-packets"` - IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` - SendPacketsDropped float64 `xml:"send-packets-dropped"` - RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` - OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` - ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` - ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` - ReceivedMacDropped float64 `xml:"received-mac-dropped"` - ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` - ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` - FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` - ReceivedDosAttack float64 `xml:"received-dos-attack"` - ReceivedBadSynack float64 `xml:"received-bad-synack"` - SyncacheZoneFull float64 `xml:"syncache-zone-full"` - ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` - ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` - ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` - ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` - ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` - ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` - ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` - ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` - ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` - ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` - ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` - OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` - OptionWindowLength float64 `xml:"option-window-length"` - OptionTimestampLength float64 `xml:"option-timestamp-length"` - OptionMd5Length float64 `xml:"option-md5-length"` - OptionAuthLength float64 `xml:"option-auth-length"` - OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` - OptionSackLength float64 `xml:"option-sack-length"` - OptionAuthoptionLength float64 `xml:"option-authoption-length"` - } `xml:"tcp"` + Tcp TCP `xml:"tcp"` Udp UDP `xml:"udp"` Ip IP `xml:"ip"` Icmp struct { @@ -448,4 +330,124 @@ type UDP struct { DatagramsNotForHashedPcb float64 `xml:"datagrams-not-for-hashed-pcb"` DatagramsDelivered float64 `xml:"datagrams-delivered"` DatagramsOutput float64 `xml:"datagrams-output"` +} + +type TCP struct { + Text string `xml:",chardata"` + PacketsSent float64 `xml:"packets-sent"` + SentDataPackets float64 `xml:"sent-data-packets"` + DataPacketsBytes float64 `xml:"data-packets-bytes"` + SentDataPacketsRetransmitted float64 `xml:"sent-data-packets-retransmitted"` + RetransmittedBytes float64 `xml:"retransmitted-bytes"` + SentDataUnnecessaryRetransmitted float64 `xml:"sent-data-unnecessary-retransmitted"` + SentResendsByMtuDiscovery float64 `xml:"sent-resends-by-mtu-discovery"` + SentAckOnlyPackets float64 `xml:"sent-ack-only-packets"` + SentPacketsDelayed float64 `xml:"sent-packets-delayed"` + SentUrgOnlyPackets float64 `xml:"sent-urg-only-packets"` + SentWindowProbePackets float64 `xml:"sent-window-probe-packets"` + SentWindowUpdatePackets float64 `xml:"sent-window-update-packets"` + SentControlPackets float64 `xml:"sent-control-packets"` + PacketsReceived float64 `xml:"packets-received"` + ReceivedAcks float64 `xml:"received-acks"` + AcksBytes float64 `xml:"acks-bytes"` + ReceivedDuplicateAcks float64 `xml:"received-duplicate-acks"` + ReceivedAcksForUnsentData float64 `xml:"received-acks-for-unsent-data"` + PacketsReceivedInSequence float64 `xml:"packets-received-in-sequence"` + InSequenceBytes float64 `xml:"in-sequence-bytes"` + ReceivedCompletelyDuplicatePacket float64 `xml:"received-completely-duplicate-packet"` + DuplicateInBytes float64 `xml:"duplicate-in-bytes"` + ReceivedOldDuplicatePackets float64 `xml:"received-old-duplicate-packets"` + ReceivedPacketsWithSomeDupliacteData float64 `xml:"received-packets-with-some-dupliacte-data"` + SomeDuplicateInBytes float64 `xml:"some-duplicate-in-bytes"` + ReceivedOutOfOrderPackets float64 `xml:"received-out-of-order-packets"` + OutOfOrderInBytes float64 `xml:"out-of-order-in-bytes"` + ReceivedPacketsOfDataAfterWindow float64 `xml:"received-packets-of-data-after-window"` + Bytes float64 `xml:"bytes"` + ReceivedWindowProbes float64 `xml:"received-window-probes"` + ReceivedWindowUpdatePackets float64 `xml:"received-window-update-packets"` + PacketsReceivedAfterClose float64 `xml:"packets-received-after-close"` + ReceivedDiscardedForBadChecksum float64 `xml:"received-discarded-for-bad-checksum"` + ReceivedDiscardedForBadHeaderOffset float64 `xml:"received-discarded-for-bad-header-offset"` + ReceivedDiscardedBecausePacketTooShort float64 `xml:"received-discarded-because-packet-too-short"` + ConnectionRequests float64 `xml:"connection-requests"` + ConnectionAccepts float64 `xml:"connection-accepts"` + BadConnectionAttempts float64 `xml:"bad-connection-attempts"` + ListenQueueOverflows float64 `xml:"listen-queue-overflows"` + BadRstWindow float64 `xml:"bad-rst-window"` + ConnectionsEstablished float64 `xml:"connections-established"` + ConnectionsClosed float64 `xml:"connections-closed"` + Drops float64 `xml:"drops"` + ConnectionsUpdatedRttOnClose float64 `xml:"connections-updated-rtt-on-close"` + ConnectionsUpdatedVarianceOnClose float64 `xml:"connections-updated-variance-on-close"` + ConnectionsUpdatedSsthreshOnClose float64 `xml:"connections-updated-ssthresh-on-close"` + EmbryonicConnectionsDropped float64 `xml:"embryonic-connections-dropped"` + SegmentsUpdatedRtt float64 `xml:"segments-updated-rtt"` + Attempts float64 `xml:"attempts"` + RetransmitTimeouts float64 `xml:"retransmit-timeouts"` + ConnectionsDroppedByRetransmitTimeout float64 `xml:"connections-dropped-by-retransmit-timeout"` + PersistTimeouts float64 `xml:"persist-timeouts"` + ConnectionsDroppedByPersistTimeout float64 `xml:"connections-dropped-by-persist-timeout"` + KeepaliveTimeouts float64 `xml:"keepalive-timeouts"` + KeepaliveProbesSent float64 `xml:"keepalive-probes-sent"` + KeepaliveConnectionsDropped float64 `xml:"keepalive-connections-dropped"` + AckHeaderPredictions float64 `xml:"ack-header-predictions"` + DataPacketHeaderPredictions float64 `xml:"data-packet-header-predictions"` + SyncacheEntriesAdded float64 `xml:"syncache-entries-added"` + Retransmitted float64 `xml:"retransmitted"` + Dupsyn float64 `xml:"dupsyn"` + Dropped float64 `xml:"dropped"` + Completed float64 `xml:"completed"` + BucketOverflow float64 `xml:"bucket-overflow"` + CacheOverflow float64 `xml:"cache-overflow"` + Reset float64 `xml:"reset"` + Stale float64 `xml:"stale"` + Aborted float64 `xml:"aborted"` + Badack float64 `xml:"badack"` + Unreach float64 `xml:"unreach"` + ZoneFailures float64 `xml:"zone-failures"` + CookiesSent float64 `xml:"cookies-sent"` + CookiesReceived float64 `xml:"cookies-received"` + SackRecoveryEpisodes float64 `xml:"sack-recovery-episodes"` + SegmentRetransmits float64 `xml:"segment-retransmits"` + ByteRetransmits float64 `xml:"byte-retransmits"` + SackOptionsReceived float64 `xml:"sack-options-received"` + SackOpitionsSent float64 `xml:"sack-opitions-sent"` + SackScoreboardOverflow float64 `xml:"sack-scoreboard-overflow"` + AcksSentInResponseButNotExactRsts float64 `xml:"acks-sent-in-response-but-not-exact-rsts"` + AcksSentInResponseToSynsOnEstablishedConnections float64 `xml:"acks-sent-in-response-to-syns-on-established-connections"` + RcvPacketsDroppedDueToBadAddress float64 `xml:"rcv-packets-dropped-due-to-bad-address"` + OutOfSequenceSegmentDrops float64 `xml:"out-of-sequence-segment-drops"` + RstPackets float64 `xml:"rst-packets"` + IcmpPacketsIgnored float64 `xml:"icmp-packets-ignored"` + SendPacketsDropped float64 `xml:"send-packets-dropped"` + RcvPacketsDropped float64 `xml:"rcv-packets-dropped"` + OutgoingSegmentsDropped float64 `xml:"outgoing-segments-dropped"` + ReceivedSynfinDropped float64 `xml:"received-synfin-dropped"` + ReceivedIpsecDropped float64 `xml:"received-ipsec-dropped"` + ReceivedMacDropped float64 `xml:"received-mac-dropped"` + ReceivedMinttlExceeded float64 `xml:"received-minttl-exceeded"` + ListenstateBadflagsDropped float64 `xml:"listenstate-badflags-dropped"` + FinwaitstateBadflagsDropped float64 `xml:"finwaitstate-badflags-dropped"` + ReceivedDosAttack float64 `xml:"received-dos-attack"` + ReceivedBadSynack float64 `xml:"received-bad-synack"` + SyncacheZoneFull float64 `xml:"syncache-zone-full"` + ReceivedRstFirewallfilter float64 `xml:"received-rst-firewallfilter"` + ReceivedNoackTimewait float64 `xml:"received-noack-timewait"` + ReceivedNoTimewaitState float64 `xml:"received-no-timewait-state"` + ReceivedRstTimewaitState float64 `xml:"received-rst-timewait-state"` + ReceivedTimewaitDrops float64 `xml:"received-timewait-drops"` + ReceivedBadaddrTimewaitState float64 `xml:"received-badaddr-timewait-state"` + ReceivedAckoffInSynSentrcvd float64 `xml:"received-ackoff-in-syn-sentrcvd"` + ReceivedBadaddrFirewall float64 `xml:"received-badaddr-firewall"` + ReceivedNosynSynSent float64 `xml:"received-nosyn-syn-sent"` + ReceivedBadrstSynSent float64 `xml:"received-badrst-syn-sent"` + ReceivedBadrstListenState float64 `xml:"received-badrst-listen-state"` + OptionMaxsegmentLength float64 `xml:"option-maxsegment-length"` + OptionWindowLength float64 `xml:"option-window-length"` + OptionTimestampLength float64 `xml:"option-timestamp-length"` + OptionMd5Length float64 `xml:"option-md5-length"` + OptionAuthLength float64 `xml:"option-auth-length"` + OptionSackpermittedLength float64 `xml:"option-sackpermitted-length"` + OptionSackLength float64 `xml:"option-sack-length"` + OptionAuthoptionLength float64 `xml:"option-authoption-length"` } \ No newline at end of file diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 4cc337f0..cb974f6c 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,7 +2,6 @@ package systemstatistics import ( "encoding/xml" - "io" "os" "testing" @@ -233,145 +232,155 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { } func TestStatisticsTCPUnmarshaling(t *testing.T) { - TCPXMLDataCase1, _ := os.Open("testsFiles/TCP/TCPTestDataCase1.xml") - TCPDataCase1, _ := io.ReadAll(TCPXMLDataCase1) type testCase struct { - name string - xmlInput string - expect func(t *testing.T, got SystemStatistics) + name string + xmlFile string + expect SystemStatistics } - tests := []testCase{ + testsTCP := []testCase{ { - name: "complete_tcp_statistics", - xmlInput: string(TCPDataCase1), - expect: func(t *testing.T, got SystemStatistics) { - tcp := got.Statistics.Tcp - assert.Equal(t, float64(1000), tcp.PacketsSent) - assert.Equal(t, float64(900), tcp.SentDataPackets) - assert.Equal(t, float64(123456), tcp.DataPacketsBytes) - assert.Equal(t, float64(10), tcp.SentDataPacketsRetransmitted) - assert.Equal(t, float64(2048), tcp.RetransmittedBytes) - assert.Equal(t, float64(50), tcp.SentAckOnlyPackets) - assert.Equal(t, float64(51), tcp.SentPacketsDelayed) - assert.Equal(t, float64(52), tcp.SentUrgOnlyPackets) - assert.Equal(t, float64(53), tcp.SentWindowProbePackets) - assert.Equal(t, float64(54), tcp.SentWindowUpdatePackets) - assert.Equal(t, float64(55), tcp.SentControlPackets) - assert.Equal(t, float64(56), tcp.PacketsReceived) - assert.Equal(t, float64(57), tcp.ReceivedAcks) - assert.Equal(t, float64(58), tcp.AcksBytes) - assert.Equal(t, float64(59), tcp.ReceivedDuplicateAcks) - assert.Equal(t, float64(60), tcp.ReceivedAcksForUnsentData) - assert.Equal(t, float64(61), tcp.PacketsReceivedInSequence) - assert.Equal(t, float64(62), tcp.InSequenceBytes) - assert.Equal(t, float64(63), tcp.ReceivedCompletelyDuplicatePacket) - assert.Equal(t, float64(64), tcp.DuplicateInBytes) - assert.Equal(t, float64(65), tcp.ReceivedOldDuplicatePackets) - assert.Equal(t, float64(66), tcp.ReceivedPacketsWithSomeDupliacteData) - assert.Equal(t, float64(67), tcp.SomeDuplicateInBytes) - assert.Equal(t, float64(68), tcp.ReceivedOutOfOrderPackets) - assert.Equal(t, float64(69), tcp.OutOfOrderInBytes) - assert.Equal(t, float64(70), tcp.ReceivedPacketsOfDataAfterWindow) - assert.Equal(t, float64(71), tcp.Bytes) - assert.Equal(t, float64(72), tcp.ReceivedWindowProbes) - assert.Equal(t, float64(73), tcp.ReceivedWindowUpdatePackets) - assert.Equal(t, float64(74), tcp.PacketsReceivedAfterClose) - assert.Equal(t, float64(75), tcp.ReceivedDiscardedForBadChecksum) - assert.Equal(t, float64(76), tcp.ReceivedDiscardedForBadHeaderOffset) - assert.Equal(t, float64(77), tcp.ReceivedDiscardedBecausePacketTooShort) - assert.Equal(t, float64(78), tcp.ConnectionRequests) - assert.Equal(t, float64(79), tcp.ConnectionAccepts) - assert.Equal(t, float64(80), tcp.BadConnectionAttempts) - assert.Equal(t, float64(81), tcp.ListenQueueOverflows) - assert.Equal(t, float64(82), tcp.BadRstWindow) - assert.Equal(t, float64(83), tcp.ConnectionsEstablished) - assert.Equal(t, float64(84), tcp.ConnectionsClosed) - assert.Equal(t, float64(85), tcp.Drops) - assert.Equal(t, float64(86), tcp.ConnectionsUpdatedRttOnClose) - assert.Equal(t, float64(87), tcp.ConnectionsUpdatedVarianceOnClose) - assert.Equal(t, float64(88), tcp.ConnectionsUpdatedSsthreshOnClose) - assert.Equal(t, float64(89), tcp.EmbryonicConnectionsDropped) - assert.Equal(t, float64(90), tcp.SegmentsUpdatedRtt) - assert.Equal(t, float64(91), tcp.Attempts) - assert.Equal(t, float64(92), tcp.RetransmitTimeouts) - assert.Equal(t, float64(93), tcp.ConnectionsDroppedByRetransmitTimeout) - assert.Equal(t, float64(94), tcp.PersistTimeouts) - assert.Equal(t, float64(95), tcp.ConnectionsDroppedByPersistTimeout) - assert.Equal(t, float64(96), tcp.KeepaliveTimeouts) - assert.Equal(t, float64(97), tcp.KeepaliveProbesSent) - assert.Equal(t, float64(98), tcp.KeepaliveConnectionsDropped) - assert.Equal(t, float64(99), tcp.AckHeaderPredictions) - assert.Equal(t, float64(100), tcp.DataPacketHeaderPredictions) - assert.Equal(t, float64(101), tcp.SyncacheEntriesAdded) - assert.Equal(t, float64(102), tcp.Retransmitted) - assert.Equal(t, float64(103), tcp.Dupsyn) - assert.Equal(t, float64(104), tcp.Dropped) - assert.Equal(t, float64(105), tcp.Completed) - assert.Equal(t, float64(106), tcp.BucketOverflow) - assert.Equal(t, float64(107), tcp.CacheOverflow) - assert.Equal(t, float64(108), tcp.Reset) - assert.Equal(t, float64(109), tcp.Stale) - assert.Equal(t, float64(110), tcp.Aborted) - assert.Equal(t, float64(111), tcp.Badack) - assert.Equal(t, float64(112), tcp.Unreach) - assert.Equal(t, float64(113), tcp.ZoneFailures) - assert.Equal(t, float64(114), tcp.CookiesSent) - assert.Equal(t, float64(115), tcp.CookiesReceived) - assert.Equal(t, float64(116), tcp.SackRecoveryEpisodes) - assert.Equal(t, float64(117), tcp.SegmentRetransmits) - assert.Equal(t, float64(118), tcp.ByteRetransmits) - assert.Equal(t, float64(119), tcp.SackOptionsReceived) - assert.Equal(t, float64(120), tcp.SackOpitionsSent) - assert.Equal(t, float64(121), tcp.SackScoreboardOverflow) - assert.Equal(t, float64(122), tcp.AcksSentInResponseButNotExactRsts) - assert.Equal(t, float64(123), tcp.AcksSentInResponseToSynsOnEstablishedConnections) - assert.Equal(t, float64(124), tcp.RcvPacketsDroppedDueToBadAddress) - assert.Equal(t, float64(125), tcp.OutOfSequenceSegmentDrops) - assert.Equal(t, float64(126), tcp.RstPackets) - assert.Equal(t, float64(127), tcp.IcmpPacketsIgnored) - assert.Equal(t, float64(128), tcp.SendPacketsDropped) - assert.Equal(t, float64(129), tcp.RcvPacketsDropped) - assert.Equal(t, float64(130), tcp.OutgoingSegmentsDropped) - assert.Equal(t, float64(131), tcp.ReceivedSynfinDropped) - assert.Equal(t, float64(132), tcp.ReceivedIpsecDropped) - assert.Equal(t, float64(133), tcp.ReceivedMacDropped) - assert.Equal(t, float64(134), tcp.ReceivedMinttlExceeded) - assert.Equal(t, float64(135), tcp.ListenstateBadflagsDropped) - assert.Equal(t, float64(136), tcp.FinwaitstateBadflagsDropped) - assert.Equal(t, float64(137), tcp.ReceivedDosAttack) - assert.Equal(t, float64(138), tcp.ReceivedBadSynack) - assert.Equal(t, float64(139), tcp.SyncacheZoneFull) - assert.Equal(t, float64(140), tcp.ReceivedRstFirewallfilter) - assert.Equal(t, float64(141), tcp.ReceivedNoackTimewait) - assert.Equal(t, float64(142), tcp.ReceivedNoTimewaitState) - assert.Equal(t, float64(143), tcp.ReceivedRstTimewaitState) - assert.Equal(t, float64(144), tcp.ReceivedTimewaitDrops) - assert.Equal(t, float64(145), tcp.ReceivedBadaddrTimewaitState) - assert.Equal(t, float64(146), tcp.ReceivedAckoffInSynSentrcvd) - assert.Equal(t, float64(147), tcp.ReceivedBadaddrFirewall) - assert.Equal(t, float64(148), tcp.ReceivedNosynSynSent) - assert.Equal(t, float64(149), tcp.ReceivedBadrstSynSent) - assert.Equal(t, float64(150), tcp.ReceivedBadrstListenState) - assert.Equal(t, float64(151), tcp.OptionMaxsegmentLength) - assert.Equal(t, float64(152), tcp.OptionWindowLength) - assert.Equal(t, float64(153), tcp.OptionTimestampLength) - assert.Equal(t, float64(154), tcp.OptionMd5Length) - assert.Equal(t, float64(155), tcp.OptionAuthLength) - assert.Equal(t, float64(156), tcp.OptionSackpermittedLength) - assert.Equal(t, float64(157), tcp.OptionSackLength) - assert.Equal(t, float64(158), tcp.OptionAuthoptionLength) - //assert.Equal(t, "user@router>", got.Cli.Banner) + name: "complete_tcp_statistics", + xmlFile: "testsFiles/TCP/TCPTestDataCase1.xml", + expect: SystemStatistics{ + Statistics: Statistics{ + Tcp: TCP{ + PacketsSent: 4000, + SentDataPackets: 4001, + DataPacketsBytes: 4002, + SentDataPacketsRetransmitted: 4003, + RetransmittedBytes: 4004, + SentDataUnnecessaryRetransmitted: 4005, + SentResendsByMtuDiscovery: 4006, + SentAckOnlyPackets: 4007, + SentPacketsDelayed: 4008, + SentUrgOnlyPackets: 4009, + SentWindowProbePackets: 4010, + SentWindowUpdatePackets: 4011, + SentControlPackets: 4012, + PacketsReceived: 4013, + ReceivedAcks: 4014, + AcksBytes: 4015, + ReceivedDuplicateAcks: 4016, + ReceivedAcksForUnsentData: 4017, + PacketsReceivedInSequence: 4018, + InSequenceBytes: 4019, + ReceivedCompletelyDuplicatePacket: 4020, + DuplicateInBytes: 4021, + ReceivedOldDuplicatePackets: 4022, + ReceivedPacketsWithSomeDupliacteData: 4023, + SomeDuplicateInBytes: 4024, + ReceivedOutOfOrderPackets: 4025, + OutOfOrderInBytes: 4026, + ReceivedPacketsOfDataAfterWindow: 4027, + Bytes: 4028, + ReceivedWindowProbes: 4029, + ReceivedWindowUpdatePackets: 4030, + PacketsReceivedAfterClose: 4031, + ReceivedDiscardedForBadChecksum: 4032, + ReceivedDiscardedForBadHeaderOffset: 4033, + ReceivedDiscardedBecausePacketTooShort: 4034, + ConnectionRequests: 4035, + ConnectionAccepts: 4036, + BadConnectionAttempts: 4037, + ListenQueueOverflows: 4038, + BadRstWindow: 4039, + ConnectionsEstablished: 4040, + ConnectionsClosed: 4041, + Drops: 4042, + ConnectionsUpdatedRttOnClose: 4043, + ConnectionsUpdatedVarianceOnClose: 4044, + ConnectionsUpdatedSsthreshOnClose: 4045, + EmbryonicConnectionsDropped: 4046, + SegmentsUpdatedRtt: 4047, + Attempts: 4048, + RetransmitTimeouts: 4049, + ConnectionsDroppedByRetransmitTimeout: 4050, + PersistTimeouts: 4051, + ConnectionsDroppedByPersistTimeout: 4052, + KeepaliveTimeouts: 4053, + KeepaliveProbesSent: 4054, + KeepaliveConnectionsDropped: 4055, + AckHeaderPredictions: 4056, + DataPacketHeaderPredictions: 4057, + SyncacheEntriesAdded: 4058, + Retransmitted: 4059, + Dupsyn: 4060, + Dropped: 4061, + Completed: 4062, + BucketOverflow: 4063, + CacheOverflow: 4064, + Reset: 4065, + Stale: 4066, + Aborted: 4067, + Badack: 4068, + Unreach: 4069, + ZoneFailures: 4070, + CookiesSent: 4071, + CookiesReceived: 4072, + SackRecoveryEpisodes: 4073, + SegmentRetransmits: 4074, + ByteRetransmits: 4075, + SackOptionsReceived: 4076, + SackOpitionsSent: 4077, + SackScoreboardOverflow: 4078, + AcksSentInResponseButNotExactRsts: 4079, + AcksSentInResponseToSynsOnEstablishedConnections: 4080, + RcvPacketsDroppedDueToBadAddress: 4081, + OutOfSequenceSegmentDrops: 4082, + RstPackets: 4083, + IcmpPacketsIgnored: 4084, + SendPacketsDropped: 4085, + RcvPacketsDropped: 4086, + OutgoingSegmentsDropped: 4087, + ReceivedSynfinDropped: 4088, + ReceivedIpsecDropped: 4089, + ReceivedMacDropped: 4090, + ReceivedMinttlExceeded: 4091, + ListenstateBadflagsDropped: 4092, + FinwaitstateBadflagsDropped: 4093, + ReceivedDosAttack: 4094, + ReceivedBadSynack: 4095, + SyncacheZoneFull: 4096, + ReceivedRstFirewallfilter: 4097, + ReceivedNoackTimewait: 4098, + ReceivedNoTimewaitState: 4099, + ReceivedRstTimewaitState: 4100, + ReceivedTimewaitDrops: 4101, + ReceivedBadaddrTimewaitState: 4102, + ReceivedAckoffInSynSentrcvd: 4103, + ReceivedBadaddrFirewall: 4104, + ReceivedNosynSynSent: 4105, + ReceivedBadrstSynSent: 4106, + ReceivedBadrstListenState: 4107, + OptionMaxsegmentLength: 4108, + OptionWindowLength: 4109, + OptionTimestampLength: 4110, + OptionMd5Length: 4111, + OptionAuthLength: 4112, + OptionSackpermittedLength: 4113, + OptionSackLength: 4114, + OptionAuthoptionLength: 4115, + }, + }, }, }, } - for _, tc := range tests { + for _, tc := range testsTCP { t.Run(tc.name, func(t *testing.T) { - var got SystemStatistics - err := xml.Unmarshal([]byte(tc.xmlInput), &got) + fc, err := os.ReadFile(tc.xmlFile) + if err != nil { + + } + var result SystemStatistics + err = xml.Unmarshal(fc, &result) + if err != nil { + + } + result.Statistics.Tcp.Text = "" + assert.Equal(t, tc.expect.Statistics.Tcp, result.Statistics.Tcp, tc.name) assert.NoError(t, err, "unmarshal should not return error") - tc.expect(t, got) }) } } diff --git a/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml b/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml index 861e6e1a..09b1b2e2 100644 --- a/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml +++ b/pkg/features/systemstatistics/testsFiles/TCP/TCPTestDataCase1.xml @@ -1,123 +1,123 @@ - 1000 - 900 - 123456 - 10 - 2048 - 50 - 51 - 52 - 53 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 63 - 64 - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - 74 - 75 - 76 - 77 - 78 - 79 - 80 - 81 - 82 - 83 - 84 - 85 - 86 - 87 - 88 - 89 - 90 - 91 - 92 - 93 - 94 - 95 - 96 - 97 - 98 - 99 - 100 - 101 - 102 - 103 - 104 - 105 - 106 - 107 - 108 - 109 - 110 - 111 - 112 - 113 - 114 - 115 - 116 - 117 - 118 - 119 - 120 - 121 - 122 - 123 - 124 - 125 - 126 - 127 - 128 - 129 - 130 - - 131 - 132 - 133 - 134 - 135 - 136 - 137 - 138 - 139 - 140 - 141 - 142 - 143 - 144 - 145 - 146 - 147 - 148 - 149 - 150 - - 151 - 152 - 153 - 154 - 155 - 156 - 157 - 158 + 4000 + 4001 + 4002 + 4003 + 4004 + 4005 + 4006 + 4007 + 4008 + 4009 + 4010 + 4011 + 4012 + 4013 + 4014 + 4015 + 4016 + 4017 + 4018 + 4019 + 4020 + 4021 + 4022 + 4023 + 4024 + 4025 + 4026 + 4027 + 4028 + 4029 + 4030 + 4031 + 4032 + 4033 + 4034 + 4035 + 4036 + 4037 + 4038 + 4039 + 4040 + 4041 + 4042 + 4043 + 4044 + 4045 + 4046 + 4047 + 4048 + 4049 + 4050 + 4051 + 4052 + 4053 + 4054 + 4055 + 4056 + 4057 + 4058 + 4059 + 4060 + 4061 + 4062 + 4063 + 4064 + 4065 + 4066 + 4067 + 4068 + 4069 + 4070 + 4071 + 4072 + 4073 + 4074 + 4075 + 4076 + 4077 + 4078 + 4079 + 4080 + 4081 + 4082 + 4083 + 4084 + 4085 + 4086 + 4087 + 4088 + 4089 + 4090 + 4091 + 4092 + 4093 + 4094 + 4095 + 4096 + 4097 + 4098 + 4099 + 4100 + 4101 + 4102 + 4103 + 4104 + 4105 + 4106 + 4107 + 4108 + 4109 + 4110 + 4111 + 4112 + 4113 + 4114 + 4115 user@router> -` \ No newline at end of file + \ No newline at end of file From f3f82b6dfa4e798357239e888f71ee238b495a37 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 10:04:41 +0200 Subject: [PATCH 25/27] added error handling in tests --- pkg/features/systemstatistics/rpc_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index cb974f6c..78eb0e4c 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -2,6 +2,7 @@ package systemstatistics import ( "encoding/xml" + "log" "os" "testing" @@ -77,12 +78,12 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - + log.Fatal(err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - + log.Fatal(err) } result.Statistics.Ip.Text = "" @@ -164,12 +165,12 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - + log.Fatal(err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - + log.Fatal(err) } result.Statistics.Ip6.Text = "" for i, _ := range result.Statistics.Ip6.HeaderType { @@ -216,12 +217,12 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - + log.Fatal(err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - + log.Fatal(err) } result.Statistics.Udp.Text = "" @@ -371,12 +372,12 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - + log.Fatal(err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - + log.Fatal(err) } result.Statistics.Tcp.Text = "" assert.Equal(t, tc.expect.Statistics.Tcp, result.Statistics.Tcp, tc.name) From 2127fefc5eb4312206e5b12c5848b1b249991154 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 10:09:53 +0200 Subject: [PATCH 26/27] some more error handling --- pkg/features/systemstatistics/rpc_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 78eb0e4c..8e7fe52d 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -78,12 +78,12 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - log.Fatal(err) + log.Fatal("failed to read xml file in IPv4 testing due to: ", err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - log.Fatal(err) + log.Fatal("failed to unmarshal xml file in IPv4 testing due to: ", err) } result.Statistics.Ip.Text = "" @@ -165,12 +165,12 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - log.Fatal(err) + log.Fatal("failed to read xml file in IPv6 testing due to: ", err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - log.Fatal(err) + log.Fatal("failed to unmarshal xml file in IPv6 testing due to: ", err) } result.Statistics.Ip6.Text = "" for i, _ := range result.Statistics.Ip6.HeaderType { @@ -217,12 +217,12 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - log.Fatal(err) + log.Fatal("failed to read xml file in UDP testing due to: ", err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - log.Fatal(err) + log.Fatal("failed to unmarshal xml file in UDP testing due to: ", err) } result.Statistics.Udp.Text = "" @@ -372,12 +372,12 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { - log.Fatal(err) + log.Fatal("failed to read xml file in TCP testing due to; ", err) } var result SystemStatistics err = xml.Unmarshal(fc, &result) if err != nil { - log.Fatal(err) + log.Fatal("failed to unmarshal xml file in TCP testing due to: ", err) } result.Statistics.Tcp.Text = "" assert.Equal(t, tc.expect.Statistics.Tcp, result.Statistics.Tcp, tc.name) From b1544c79a722895c2fee699697d280791a5aff37 Mon Sep 17 00:00:00 2001 From: Vincent Vilenchik Date: Thu, 4 Sep 2025 10:29:22 +0200 Subject: [PATCH 27/27] adjusted some struct names --- pkg/features/systemstatistics/rpc_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/features/systemstatistics/rpc_test.go b/pkg/features/systemstatistics/rpc_test.go index 8e7fe52d..bc27046c 100644 --- a/pkg/features/systemstatistics/rpc_test.go +++ b/pkg/features/systemstatistics/rpc_test.go @@ -16,7 +16,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { expect SystemStatistics } - testsIPV4 := []testCase{ + tests := []testCase{ { name: "complete_ipv4_statistics", xmlFile: "testsFiles/IPv4/ipv4TestDataCase1.xml", @@ -74,7 +74,7 @@ func TestStatisticsIPv4Unmarshaling(t *testing.T) { }, } - for _, tc := range testsIPV4 { + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { @@ -100,7 +100,7 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { expect SystemStatistics } - testsIPV6 := []testCase{ + tests := []testCase{ { name: "complete_ipv6_statistics", xmlFile: "testsFiles/IPv6/ipv6TestDataCase1.xml", @@ -161,7 +161,7 @@ func TestStatisticsIPv6Unmarshaling(t *testing.T) { }, } - for _, tc := range testsIPV6 { + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { @@ -190,7 +190,7 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { expect SystemStatistics } - testsUDP := []testCase{ + tests := []testCase{ { name: "complete_udp_statistics", xmlFile: "testsFiles/UDP/UDPTestDataCase1.xml", @@ -213,7 +213,7 @@ func TestStatisticsUDPUnmarshaling(t *testing.T) { }, } - for _, tc := range testsUDP { + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil { @@ -239,7 +239,7 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { expect SystemStatistics } - testsTCP := []testCase{ + tests := []testCase{ { name: "complete_tcp_statistics", xmlFile: "testsFiles/TCP/TCPTestDataCase1.xml", @@ -368,7 +368,7 @@ func TestStatisticsTCPUnmarshaling(t *testing.T) { }, } - for _, tc := range testsTCP { + for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { fc, err := os.ReadFile(tc.xmlFile) if err != nil {