From 6c4b29fedc6ae3752f28e257b7eb7c4e08ed6cbd Mon Sep 17 00:00:00 2001 From: remi Date: Mon, 6 Feb 2023 14:11:49 +0100 Subject: [PATCH 01/15] softnet: additionals metrics from softnet_data, https://github.com/prometheus/procfs/pull/473 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: remi Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 38 +++++++++-- collector/fixtures/e2e-output.txt | 38 +++++++++-- collector/softnet_linux.go | 76 +++++++++++++++++++--- 3 files changed, 136 insertions(+), 16 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 69b2bb85d3..46684f86cf 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3030,24 +3030,54 @@ node_softirqs_total{vector="rcu"} 508444 node_softirqs_total{vector="sched"} 622196 node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 +# HELP node_softnet_backlog_len_total Softnet backlog status +# TYPE node_softnet_backlog_len_total counter +node_softnet_backlog_len_total{cpu="0"} 14587 +node_softnet_backlog_len_total{cpu="1"} 0 +node_softnet_backlog_len_total{cpu="2"} 0 +node_softnet_backlog_len_total{cpu="3"} 0 +# HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting +# TYPE node_softnet_cpu_collision_total counter +node_softnet_cpu_collision_total{cpu="0"} 0 +node_softnet_cpu_collision_total{cpu="1"} 0 +node_softnet_cpu_collision_total{cpu="2"} 0 +node_softnet_cpu_collision_total{cpu="3"} 0 # HELP node_softnet_dropped_total Number of dropped packets # TYPE node_softnet_dropped_total counter node_softnet_dropped_total{cpu="0"} 0 node_softnet_dropped_total{cpu="1"} 41 node_softnet_dropped_total{cpu="2"} 0 node_softnet_dropped_total{cpu="3"} 0 +# HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached +# TYPE node_softnet_flow_limit_count_total counter +node_softnet_flow_limit_count_total{cpu="0"} 0 +node_softnet_flow_limit_count_total{cpu="1"} 0 +node_softnet_flow_limit_count_total{cpu="2"} 0 +node_softnet_flow_limit_count_total{cpu="3"} 13 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 node_softnet_processed_total{cpu="1"} 916354 node_softnet_processed_total{cpu="2"} 5.577791e+06 node_softnet_processed_total{cpu="3"} 3.113785e+06 +# HELP node_softnet_received_rps_total Number of times cpu woken up received_rps +# TYPE node_softnet_received_rps_total counter +node_softnet_received_rps_total{cpu="0"} 0 +node_softnet_received_rps_total{cpu="1"} 0 +node_softnet_received_rps_total{cpu="2"} 487 +node_softnet_received_rps_total{cpu="3"} 0 # HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota # TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 1 -node_softnet_times_squeezed_total{cpu="1"} 10 -node_softnet_times_squeezed_total{cpu="2"} 85 -node_softnet_times_squeezed_total{cpu="3"} 50 +node_softnet_times_squeezed_total{cpu="0"} 0 +node_softnet_times_squeezed_total{cpu="1"} 0 +node_softnet_times_squeezed_total{cpu="2"} 0 +node_softnet_times_squeezed_total{cpu="3"} 0 +# HELP node_softnet_width softnet_data's Width +# TYPE node_softnet_width gauge +node_softnet_width{cpu="0"} 13 +node_softnet_width{cpu="1"} 13 +node_softnet_width{cpu="2"} 13 +node_softnet_width{cpu="3"} 13 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 0ffdece0a9..2d8b2349f1 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3052,24 +3052,54 @@ node_softirqs_total{vector="rcu"} 508444 node_softirqs_total{vector="sched"} 622196 node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 +# HELP node_softnet_backlog_len_total Softnet backlog status +# TYPE node_softnet_backlog_len_total counter +node_softnet_backlog_len_total{cpu="0"} 14587 +node_softnet_backlog_len_total{cpu="1"} 0 +node_softnet_backlog_len_total{cpu="2"} 0 +node_softnet_backlog_len_total{cpu="3"} 0 +# HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting +# TYPE node_softnet_cpu_collision_total counter +node_softnet_cpu_collision_total{cpu="0"} 0 +node_softnet_cpu_collision_total{cpu="1"} 0 +node_softnet_cpu_collision_total{cpu="2"} 0 +node_softnet_cpu_collision_total{cpu="3"} 0 # HELP node_softnet_dropped_total Number of dropped packets # TYPE node_softnet_dropped_total counter node_softnet_dropped_total{cpu="0"} 0 node_softnet_dropped_total{cpu="1"} 41 node_softnet_dropped_total{cpu="2"} 0 node_softnet_dropped_total{cpu="3"} 0 +# HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached +# TYPE node_softnet_flow_limit_count_total counter +node_softnet_flow_limit_count_total{cpu="0"} 0 +node_softnet_flow_limit_count_total{cpu="1"} 0 +node_softnet_flow_limit_count_total{cpu="2"} 0 +node_softnet_flow_limit_count_total{cpu="3"} 13 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 node_softnet_processed_total{cpu="1"} 916354 node_softnet_processed_total{cpu="2"} 5.577791e+06 node_softnet_processed_total{cpu="3"} 3.113785e+06 +# HELP node_softnet_received_rps_total Number of times cpu woken up received_rps +# TYPE node_softnet_received_rps_total counter +node_softnet_received_rps_total{cpu="0"} 0 +node_softnet_received_rps_total{cpu="1"} 0 +node_softnet_received_rps_total{cpu="2"} 487 +node_softnet_received_rps_total{cpu="3"} 0 # HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota # TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 1 -node_softnet_times_squeezed_total{cpu="1"} 10 -node_softnet_times_squeezed_total{cpu="2"} 85 -node_softnet_times_squeezed_total{cpu="3"} 50 +node_softnet_times_squeezed_total{cpu="0"} 0 +node_softnet_times_squeezed_total{cpu="1"} 0 +node_softnet_times_squeezed_total{cpu="2"} 0 +node_softnet_times_squeezed_total{cpu="3"} 0 +# HELP node_softnet_width softnet_data's Width +# TYPE node_softnet_width gauge +node_softnet_width{cpu="0"} 13 +node_softnet_width{cpu="1"} 13 +node_softnet_width{cpu="2"} 13 +node_softnet_width{cpu="3"} 13 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index a46b6808be..02200db747 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -26,11 +26,16 @@ import ( ) type softnetCollector struct { - fs procfs.FS - processed *prometheus.Desc - dropped *prometheus.Desc - timeSqueezed *prometheus.Desc - logger log.Logger + fs procfs.FS + processed *prometheus.Desc + dropped *prometheus.Desc + timeSqueezed *prometheus.Desc + cpuCollision *prometheus.Desc + receivedRps *prometheus.Desc + flowLimitCount *prometheus.Desc + softnetBacklogLen *prometheus.Desc + width *prometheus.Desc + logger log.Logger } const ( @@ -61,10 +66,35 @@ func NewSoftnetCollector(logger log.Logger) (Collector, error) { []string{"cpu"}, nil, ), timeSqueezed: prometheus.NewDesc( - prometheus.BuildFQName(namespace, softnetSubsystem, "times_squeezed_total"), + prometheus.BuildFQName(namespace, softnetSubsystem, "time_squeezed_total"), "Number of times processing packets ran out of quota", []string{"cpu"}, nil, ), + cpuCollision: prometheus.NewDesc( + prometheus.BuildFQName(namespace, softnetSubsystem, "cpu_collision_total"), + "Number of collision occur while obtaining device lock while transmitting", + []string{"cpu"}, nil, + ), + receivedRps: prometheus.NewDesc( + prometheus.BuildFQName(namespace, softnetSubsystem, "received_rps_total"), + "Number of times cpu woken up received_rps", + []string{"cpu"}, nil, + ), + flowLimitCount: prometheus.NewDesc( + prometheus.BuildFQName(namespace, softnetSubsystem, "flow_limit_count_total"), + "Number of times flow limit has been reached", + []string{"cpu"}, nil, + ), + softnetBacklogLen: prometheus.NewDesc( + prometheus.BuildFQName(namespace, softnetSubsystem, "backlog_len_total"), + "Softnet backlog status", + []string{"cpu"}, nil, + ), + width: prometheus.NewDesc( + prometheus.BuildFQName(namespace, softnetSubsystem, "width"), + "softnet_data's Width", + []string{"cpu"}, nil, + ), logger: logger, }, nil } @@ -76,8 +106,8 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { return fmt.Errorf("could not get softnet statistics: %w", err) } - for cpuNumber, cpuStats := range stats { - cpu := strconv.Itoa(cpuNumber) + for _, cpuStats := range stats { + cpu := strconv.FormatUint(uint64(cpuStats.Index), 10) ch <- prometheus.MustNewConstMetric( c.processed, @@ -97,6 +127,36 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { float64(cpuStats.TimeSqueezed), cpu, ) + ch <- prometheus.MustNewConstMetric( + c.cpuCollision, + prometheus.CounterValue, + float64(cpuStats.CPUCollision), + cpu, + ) + ch <- prometheus.MustNewConstMetric( + c.receivedRps, + prometheus.CounterValue, + float64(cpuStats.ReceivedRps), + cpu, + ) + ch <- prometheus.MustNewConstMetric( + c.flowLimitCount, + prometheus.CounterValue, + float64(cpuStats.FlowLimitCount), + cpu, + ) + ch <- prometheus.MustNewConstMetric( + c.softnetBacklogLen, + prometheus.CounterValue, + float64(cpuStats.SoftnetBacklogLen), + cpu, + ) + ch <- prometheus.MustNewConstMetric( + c.width, + prometheus.GaugeValue, + float64(cpuStats.Width), + cpu, + ) } return nil From a3c7730a9329bbeb3902df0e3b9ad7111644576b Mon Sep 17 00:00:00 2001 From: remi Date: Mon, 6 Feb 2023 14:15:01 +0100 Subject: [PATCH 02/15] fix fixtures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: remi Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 12 ++++++------ collector/fixtures/e2e-output.txt | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 46684f86cf..dc96c10734 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3066,12 +3066,12 @@ node_softnet_received_rps_total{cpu="0"} 0 node_softnet_received_rps_total{cpu="1"} 0 node_softnet_received_rps_total{cpu="2"} 487 node_softnet_received_rps_total{cpu="3"} 0 -# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 0 -node_softnet_times_squeezed_total{cpu="1"} 0 -node_softnet_times_squeezed_total{cpu="2"} 0 -node_softnet_times_squeezed_total{cpu="3"} 0 +# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_time_squeezed_total counter +node_softnet_time_squeezed_total{cpu="0"} 0 +node_softnet_time_squeezed_total{cpu="1"} 0 +node_softnet_time_squeezed_total{cpu="2"} 0 +node_softnet_time_squeezed_total{cpu="3"} 0 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge node_softnet_width{cpu="0"} 13 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 2d8b2349f1..95078d836b 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3088,12 +3088,12 @@ node_softnet_received_rps_total{cpu="0"} 0 node_softnet_received_rps_total{cpu="1"} 0 node_softnet_received_rps_total{cpu="2"} 487 node_softnet_received_rps_total{cpu="3"} 0 -# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 0 -node_softnet_times_squeezed_total{cpu="1"} 0 -node_softnet_times_squeezed_total{cpu="2"} 0 -node_softnet_times_squeezed_total{cpu="3"} 0 +# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_time_squeezed_total counter +node_softnet_time_squeezed_total{cpu="0"} 0 +node_softnet_time_squeezed_total{cpu="1"} 0 +node_softnet_time_squeezed_total{cpu="2"} 0 +node_softnet_time_squeezed_total{cpu="3"} 0 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge node_softnet_width{cpu="0"} 13 From e124db79c48093d59cd40d356daa19d5cadf7c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Mon, 20 Mar 2023 18:40:16 +0100 Subject: [PATCH 03/15] fix e2e test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-output.txt | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index a8c77c2382..489870e357 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3064,52 +3064,28 @@ node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status # TYPE node_softnet_backlog_len_total counter -node_softnet_backlog_len_total{cpu="0"} 14587 -node_softnet_backlog_len_total{cpu="1"} 0 -node_softnet_backlog_len_total{cpu="2"} 0 -node_softnet_backlog_len_total{cpu="3"} 0 +node_softnet_backlog_len_total{cpu="0"} 0 # HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting # TYPE node_softnet_cpu_collision_total counter node_softnet_cpu_collision_total{cpu="0"} 0 -node_softnet_cpu_collision_total{cpu="1"} 0 -node_softnet_cpu_collision_total{cpu="2"} 0 -node_softnet_cpu_collision_total{cpu="3"} 0 # HELP node_softnet_dropped_total Number of dropped packets # TYPE node_softnet_dropped_total counter node_softnet_dropped_total{cpu="0"} 0 -node_softnet_dropped_total{cpu="1"} 41 -node_softnet_dropped_total{cpu="2"} 0 -node_softnet_dropped_total{cpu="3"} 0 # HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached # TYPE node_softnet_flow_limit_count_total counter node_softnet_flow_limit_count_total{cpu="0"} 0 -node_softnet_flow_limit_count_total{cpu="1"} 0 -node_softnet_flow_limit_count_total{cpu="2"} 0 -node_softnet_flow_limit_count_total{cpu="3"} 13 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 -node_softnet_processed_total{cpu="1"} 916354 -node_softnet_processed_total{cpu="2"} 5.577791e+06 -node_softnet_processed_total{cpu="3"} 3.113785e+06 # HELP node_softnet_received_rps_total Number of times cpu woken up received_rps # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 -node_softnet_received_rps_total{cpu="1"} 0 -node_softnet_received_rps_total{cpu="2"} 487 -node_softnet_received_rps_total{cpu="3"} 0 # HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota # TYPE node_softnet_time_squeezed_total counter -node_softnet_time_squeezed_total{cpu="0"} 0 -node_softnet_time_squeezed_total{cpu="1"} 0 -node_softnet_time_squeezed_total{cpu="2"} 0 -node_softnet_time_squeezed_total{cpu="3"} 0 +node_softnet_time_squeezed_total{cpu="0"} 1 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 13 -node_softnet_width{cpu="1"} 13 -node_softnet_width{cpu="2"} 13 -node_softnet_width{cpu="3"} 13 +node_softnet_width{cpu="0"} 11 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 From b4837203216f967a929235464c630ff688c577cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Mon, 20 Mar 2023 18:42:40 +0100 Subject: [PATCH 04/15] fix tests e2e-64k-page-output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 30 +++------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 741de44ffb..c063417974 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3042,52 +3042,28 @@ node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status # TYPE node_softnet_backlog_len_total counter -node_softnet_backlog_len_total{cpu="0"} 14587 -node_softnet_backlog_len_total{cpu="1"} 0 -node_softnet_backlog_len_total{cpu="2"} 0 -node_softnet_backlog_len_total{cpu="3"} 0 +node_softnet_backlog_len_total{cpu="0"} 0 # HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting # TYPE node_softnet_cpu_collision_total counter node_softnet_cpu_collision_total{cpu="0"} 0 -node_softnet_cpu_collision_total{cpu="1"} 0 -node_softnet_cpu_collision_total{cpu="2"} 0 -node_softnet_cpu_collision_total{cpu="3"} 0 # HELP node_softnet_dropped_total Number of dropped packets # TYPE node_softnet_dropped_total counter node_softnet_dropped_total{cpu="0"} 0 -node_softnet_dropped_total{cpu="1"} 41 -node_softnet_dropped_total{cpu="2"} 0 -node_softnet_dropped_total{cpu="3"} 0 # HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached # TYPE node_softnet_flow_limit_count_total counter node_softnet_flow_limit_count_total{cpu="0"} 0 -node_softnet_flow_limit_count_total{cpu="1"} 0 -node_softnet_flow_limit_count_total{cpu="2"} 0 -node_softnet_flow_limit_count_total{cpu="3"} 13 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 -node_softnet_processed_total{cpu="1"} 916354 -node_softnet_processed_total{cpu="2"} 5.577791e+06 -node_softnet_processed_total{cpu="3"} 3.113785e+06 # HELP node_softnet_received_rps_total Number of times cpu woken up received_rps # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 -node_softnet_received_rps_total{cpu="1"} 0 -node_softnet_received_rps_total{cpu="2"} 487 -node_softnet_received_rps_total{cpu="3"} 0 # HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota # TYPE node_softnet_time_squeezed_total counter -node_softnet_time_squeezed_total{cpu="0"} 0 -node_softnet_time_squeezed_total{cpu="1"} 0 -node_softnet_time_squeezed_total{cpu="2"} 0 -node_softnet_time_squeezed_total{cpu="3"} 0 +node_softnet_time_squeezed_total{cpu="0"} 1 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 13 -node_softnet_width{cpu="1"} 13 -node_softnet_width{cpu="2"} 13 -node_softnet_width{cpu="3"} 13 +node_softnet_width{cpu="0"} 11 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 From 76989332d3ebb1a1dbabb0e9963b9ab8f085de6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 12:03:51 +0200 Subject: [PATCH 05/15] rollback the typo fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 6 +++--- collector/fixtures/e2e-output.txt | 6 +++--- collector/softnet_linux.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index c063417974..a8d127555a 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3058,9 +3058,9 @@ node_softnet_processed_total{cpu="0"} 299641 # HELP node_softnet_received_rps_total Number of times cpu woken up received_rps # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 -# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_time_squeezed_total counter -node_softnet_time_squeezed_total{cpu="0"} 1 +# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_times_squeezed_total counter +node_softnet_times_squeezed_total{cpu="0"} 1 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge node_softnet_width{cpu="0"} 11 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 489870e357..da4e6007cc 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3080,9 +3080,9 @@ node_softnet_processed_total{cpu="0"} 299641 # HELP node_softnet_received_rps_total Number of times cpu woken up received_rps # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 -# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_time_squeezed_total counter -node_softnet_time_squeezed_total{cpu="0"} 1 +# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_times_squeezed_total counter +node_softnet_times_squeezed_total{cpu="0"} 1 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge node_softnet_width{cpu="0"} 11 diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index 02200db747..9cb829082a 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -66,7 +66,7 @@ func NewSoftnetCollector(logger log.Logger) (Collector, error) { []string{"cpu"}, nil, ), timeSqueezed: prometheus.NewDesc( - prometheus.BuildFQName(namespace, softnetSubsystem, "time_squeezed_total"), + prometheus.BuildFQName(namespace, softnetSubsystem, "times_squeezed_total"), "Number of times processing packets ran out of quota", []string{"cpu"}, nil, ), From 83d9cc8d2e404a91d7d33e9e07f748df433eb06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 15:29:59 +0200 Subject: [PATCH 06/15] fix cpuStats.Index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/softnet_linux.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index 9cb829082a..3d931a0ea3 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -106,8 +106,12 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { return fmt.Errorf("could not get softnet statistics: %w", err) } - for _, cpuStats := range stats { - cpu := strconv.FormatUint(uint64(cpuStats.Index), 10) + for cpuNumber, cpuStats := range stats { + if cpuStats.Width >= 13 { + cpu := strconv.FormatUint(uint64(cpuStats.Index), 10) + } else { + cpu := strconv.Itoa(cpuNumber) + } ch <- prometheus.MustNewConstMetric( c.processed, From be8b2d4a0a71240754c963bd74eb803987eb0cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 15:44:37 +0200 Subject: [PATCH 07/15] fix cpuStats.Index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/softnet_linux.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index 3d931a0ea3..f31f3ac8d5 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -101,6 +101,8 @@ func NewSoftnetCollector(logger log.Logger) (Collector, error) { // Update gets parsed softnet statistics using procfs. func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { + var cpu string + stats, err := c.fs.NetSoftnetStat() if err != nil { return fmt.Errorf("could not get softnet statistics: %w", err) @@ -108,9 +110,9 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { for cpuNumber, cpuStats := range stats { if cpuStats.Width >= 13 { - cpu := strconv.FormatUint(uint64(cpuStats.Index), 10) + cpu = strconv.FormatUint(uint64(cpuStats.Index), 10) } else { - cpu := strconv.Itoa(cpuNumber) + cpu = strconv.Itoa(cpuNumber) } ch <- prometheus.MustNewConstMetric( From 2d9c38c5b56bc419f99395a6621ebca4fae8f460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 16:05:24 +0200 Subject: [PATCH 08/15] rollback e2e output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 34 ++++++++++++++++++---- collector/fixtures/e2e-output.txt | 34 ++++++++++++++++++---- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index a8d127555a..741de44ffb 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3042,28 +3042,52 @@ node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status # TYPE node_softnet_backlog_len_total counter -node_softnet_backlog_len_total{cpu="0"} 0 +node_softnet_backlog_len_total{cpu="0"} 14587 +node_softnet_backlog_len_total{cpu="1"} 0 +node_softnet_backlog_len_total{cpu="2"} 0 +node_softnet_backlog_len_total{cpu="3"} 0 # HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting # TYPE node_softnet_cpu_collision_total counter node_softnet_cpu_collision_total{cpu="0"} 0 +node_softnet_cpu_collision_total{cpu="1"} 0 +node_softnet_cpu_collision_total{cpu="2"} 0 +node_softnet_cpu_collision_total{cpu="3"} 0 # HELP node_softnet_dropped_total Number of dropped packets # TYPE node_softnet_dropped_total counter node_softnet_dropped_total{cpu="0"} 0 +node_softnet_dropped_total{cpu="1"} 41 +node_softnet_dropped_total{cpu="2"} 0 +node_softnet_dropped_total{cpu="3"} 0 # HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached # TYPE node_softnet_flow_limit_count_total counter node_softnet_flow_limit_count_total{cpu="0"} 0 +node_softnet_flow_limit_count_total{cpu="1"} 0 +node_softnet_flow_limit_count_total{cpu="2"} 0 +node_softnet_flow_limit_count_total{cpu="3"} 13 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 +node_softnet_processed_total{cpu="1"} 916354 +node_softnet_processed_total{cpu="2"} 5.577791e+06 +node_softnet_processed_total{cpu="3"} 3.113785e+06 # HELP node_softnet_received_rps_total Number of times cpu woken up received_rps # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 -# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 1 +node_softnet_received_rps_total{cpu="1"} 0 +node_softnet_received_rps_total{cpu="2"} 487 +node_softnet_received_rps_total{cpu="3"} 0 +# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_time_squeezed_total counter +node_softnet_time_squeezed_total{cpu="0"} 0 +node_softnet_time_squeezed_total{cpu="1"} 0 +node_softnet_time_squeezed_total{cpu="2"} 0 +node_softnet_time_squeezed_total{cpu="3"} 0 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 11 +node_softnet_width{cpu="0"} 13 +node_softnet_width{cpu="1"} 13 +node_softnet_width{cpu="2"} 13 +node_softnet_width{cpu="3"} 13 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index da4e6007cc..a8c77c2382 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3064,28 +3064,52 @@ node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status # TYPE node_softnet_backlog_len_total counter -node_softnet_backlog_len_total{cpu="0"} 0 +node_softnet_backlog_len_total{cpu="0"} 14587 +node_softnet_backlog_len_total{cpu="1"} 0 +node_softnet_backlog_len_total{cpu="2"} 0 +node_softnet_backlog_len_total{cpu="3"} 0 # HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting # TYPE node_softnet_cpu_collision_total counter node_softnet_cpu_collision_total{cpu="0"} 0 +node_softnet_cpu_collision_total{cpu="1"} 0 +node_softnet_cpu_collision_total{cpu="2"} 0 +node_softnet_cpu_collision_total{cpu="3"} 0 # HELP node_softnet_dropped_total Number of dropped packets # TYPE node_softnet_dropped_total counter node_softnet_dropped_total{cpu="0"} 0 +node_softnet_dropped_total{cpu="1"} 41 +node_softnet_dropped_total{cpu="2"} 0 +node_softnet_dropped_total{cpu="3"} 0 # HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached # TYPE node_softnet_flow_limit_count_total counter node_softnet_flow_limit_count_total{cpu="0"} 0 +node_softnet_flow_limit_count_total{cpu="1"} 0 +node_softnet_flow_limit_count_total{cpu="2"} 0 +node_softnet_flow_limit_count_total{cpu="3"} 13 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 +node_softnet_processed_total{cpu="1"} 916354 +node_softnet_processed_total{cpu="2"} 5.577791e+06 +node_softnet_processed_total{cpu="3"} 3.113785e+06 # HELP node_softnet_received_rps_total Number of times cpu woken up received_rps # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 -# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 1 +node_softnet_received_rps_total{cpu="1"} 0 +node_softnet_received_rps_total{cpu="2"} 487 +node_softnet_received_rps_total{cpu="3"} 0 +# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_time_squeezed_total counter +node_softnet_time_squeezed_total{cpu="0"} 0 +node_softnet_time_squeezed_total{cpu="1"} 0 +node_softnet_time_squeezed_total{cpu="2"} 0 +node_softnet_time_squeezed_total{cpu="3"} 0 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 11 +node_softnet_width{cpu="0"} 13 +node_softnet_width{cpu="1"} 13 +node_softnet_width{cpu="2"} 13 +node_softnet_width{cpu="3"} 13 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 From 3baee6bf7acb306b5fc918b8153bb5c6839089bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 16:06:43 +0200 Subject: [PATCH 09/15] rollback e2e output, rollback typo in e2e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 12 ++++++------ collector/fixtures/e2e-output.txt | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 741de44ffb..0ad5d5c515 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3076,12 +3076,12 @@ node_softnet_received_rps_total{cpu="0"} 0 node_softnet_received_rps_total{cpu="1"} 0 node_softnet_received_rps_total{cpu="2"} 487 node_softnet_received_rps_total{cpu="3"} 0 -# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_time_squeezed_total counter -node_softnet_time_squeezed_total{cpu="0"} 0 -node_softnet_time_squeezed_total{cpu="1"} 0 -node_softnet_time_squeezed_total{cpu="2"} 0 -node_softnet_time_squeezed_total{cpu="3"} 0 +# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_times_squeezed_total counter +node_softnet_times_squeezed_total{cpu="0"} 0 +node_softnet_times_squeezed_total{cpu="1"} 0 +node_softnet_times_squeezed_total{cpu="2"} 0 +node_softnet_times_squeezed_total{cpu="3"} 0 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge node_softnet_width{cpu="0"} 13 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index a8c77c2382..4cc1face52 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3098,12 +3098,12 @@ node_softnet_received_rps_total{cpu="0"} 0 node_softnet_received_rps_total{cpu="1"} 0 node_softnet_received_rps_total{cpu="2"} 487 node_softnet_received_rps_total{cpu="3"} 0 -# HELP node_softnet_time_squeezed_total Number of times processing packets ran out of quota -# TYPE node_softnet_time_squeezed_total counter -node_softnet_time_squeezed_total{cpu="0"} 0 -node_softnet_time_squeezed_total{cpu="1"} 0 -node_softnet_time_squeezed_total{cpu="2"} 0 -node_softnet_time_squeezed_total{cpu="3"} 0 +# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota +# TYPE node_softnet_times_squeezed_total counter +node_softnet_times_squeezed_total{cpu="0"} 0 +node_softnet_times_squeezed_total{cpu="1"} 0 +node_softnet_times_squeezed_total{cpu="2"} 0 +node_softnet_times_squeezed_total{cpu="3"} 0 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge node_softnet_width{cpu="0"} 13 From 21d14346712954be5a24d4fb0999077f3085b873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 16:12:04 +0200 Subject: [PATCH 10/15] rollback e2e output, rollback typo in e2e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 22 +++++++++++----------- collector/fixtures/e2e-output.txt | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 0ad5d5c515..4fa651f0fb 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3042,7 +3042,7 @@ node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status # TYPE node_softnet_backlog_len_total counter -node_softnet_backlog_len_total{cpu="0"} 14587 +node_softnet_backlog_len_total{cpu="0"} 0 node_softnet_backlog_len_total{cpu="1"} 0 node_softnet_backlog_len_total{cpu="2"} 0 node_softnet_backlog_len_total{cpu="3"} 0 @@ -3063,7 +3063,7 @@ node_softnet_dropped_total{cpu="3"} 0 node_softnet_flow_limit_count_total{cpu="0"} 0 node_softnet_flow_limit_count_total{cpu="1"} 0 node_softnet_flow_limit_count_total{cpu="2"} 0 -node_softnet_flow_limit_count_total{cpu="3"} 13 +node_softnet_flow_limit_count_total{cpu="3"} 0 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 @@ -3074,20 +3074,20 @@ node_softnet_processed_total{cpu="3"} 3.113785e+06 # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 node_softnet_received_rps_total{cpu="1"} 0 -node_softnet_received_rps_total{cpu="2"} 487 +node_softnet_received_rps_total{cpu="2"} 0 node_softnet_received_rps_total{cpu="3"} 0 # HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota # TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 0 -node_softnet_times_squeezed_total{cpu="1"} 0 -node_softnet_times_squeezed_total{cpu="2"} 0 -node_softnet_times_squeezed_total{cpu="3"} 0 +node_softnet_times_squeezed_total{cpu="0"} 1 +node_softnet_times_squeezed_total{cpu="1"} 10 +node_softnet_times_squeezed_total{cpu="2"} 85 +node_softnet_times_squeezed_total{cpu="3"} 50 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 13 -node_softnet_width{cpu="1"} 13 -node_softnet_width{cpu="2"} 13 -node_softnet_width{cpu="3"} 13 +node_softnet_width{cpu="0"} 11 +node_softnet_width{cpu="1"} 11 +node_softnet_width{cpu="2"} 11 +node_softnet_width{cpu="3"} 11 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 4cc1face52..95ffc10b42 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3064,7 +3064,7 @@ node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status # TYPE node_softnet_backlog_len_total counter -node_softnet_backlog_len_total{cpu="0"} 14587 +node_softnet_backlog_len_total{cpu="0"} 0 node_softnet_backlog_len_total{cpu="1"} 0 node_softnet_backlog_len_total{cpu="2"} 0 node_softnet_backlog_len_total{cpu="3"} 0 @@ -3085,7 +3085,7 @@ node_softnet_dropped_total{cpu="3"} 0 node_softnet_flow_limit_count_total{cpu="0"} 0 node_softnet_flow_limit_count_total{cpu="1"} 0 node_softnet_flow_limit_count_total{cpu="2"} 0 -node_softnet_flow_limit_count_total{cpu="3"} 13 +node_softnet_flow_limit_count_total{cpu="3"} 0 # HELP node_softnet_processed_total Number of processed packets # TYPE node_softnet_processed_total counter node_softnet_processed_total{cpu="0"} 299641 @@ -3096,20 +3096,20 @@ node_softnet_processed_total{cpu="3"} 3.113785e+06 # TYPE node_softnet_received_rps_total counter node_softnet_received_rps_total{cpu="0"} 0 node_softnet_received_rps_total{cpu="1"} 0 -node_softnet_received_rps_total{cpu="2"} 487 +node_softnet_received_rps_total{cpu="2"} 0 node_softnet_received_rps_total{cpu="3"} 0 # HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota # TYPE node_softnet_times_squeezed_total counter -node_softnet_times_squeezed_total{cpu="0"} 0 -node_softnet_times_squeezed_total{cpu="1"} 0 -node_softnet_times_squeezed_total{cpu="2"} 0 -node_softnet_times_squeezed_total{cpu="3"} 0 +node_softnet_times_squeezed_total{cpu="0"} 1 +node_softnet_times_squeezed_total{cpu="1"} 10 +node_softnet_times_squeezed_total{cpu="2"} 85 +node_softnet_times_squeezed_total{cpu="3"} 50 # HELP node_softnet_width softnet_data's Width # TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 13 -node_softnet_width{cpu="1"} 13 -node_softnet_width{cpu="2"} 13 -node_softnet_width{cpu="3"} 13 +node_softnet_width{cpu="0"} 11 +node_softnet_width{cpu="1"} 11 +node_softnet_width{cpu="2"} 11 +node_softnet_width{cpu="3"} 11 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 From 4498f881aade20b6b58a12cc3ba8182a13e25cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 17:25:25 +0200 Subject: [PATCH 11/15] remove width, softnet backlog must be a gauge not a counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 6 ------ collector/fixtures/e2e-output.txt | 6 ------ collector/softnet_linux.go | 14 +------------- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 4fa651f0fb..ec6db6cf4d 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3082,12 +3082,6 @@ node_softnet_times_squeezed_total{cpu="0"} 1 node_softnet_times_squeezed_total{cpu="1"} 10 node_softnet_times_squeezed_total{cpu="2"} 85 node_softnet_times_squeezed_total{cpu="3"} 50 -# HELP node_softnet_width softnet_data's Width -# TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 11 -node_softnet_width{cpu="1"} 11 -node_softnet_width{cpu="2"} 11 -node_softnet_width{cpu="3"} 11 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 95ffc10b42..3d8cf08763 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3104,12 +3104,6 @@ node_softnet_times_squeezed_total{cpu="0"} 1 node_softnet_times_squeezed_total{cpu="1"} 10 node_softnet_times_squeezed_total{cpu="2"} 85 node_softnet_times_squeezed_total{cpu="3"} 50 -# HELP node_softnet_width softnet_data's Width -# TYPE node_softnet_width gauge -node_softnet_width{cpu="0"} 11 -node_softnet_width{cpu="1"} 11 -node_softnet_width{cpu="2"} 11 -node_softnet_width{cpu="3"} 11 # HELP node_sysctl_fs_file_nr sysctl fs.file-nr # TYPE node_sysctl_fs_file_nr untyped node_sysctl_fs_file_nr{index="0"} 1024 diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index f31f3ac8d5..9be4ffda1a 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -34,7 +34,6 @@ type softnetCollector struct { receivedRps *prometheus.Desc flowLimitCount *prometheus.Desc softnetBacklogLen *prometheus.Desc - width *prometheus.Desc logger log.Logger } @@ -90,11 +89,6 @@ func NewSoftnetCollector(logger log.Logger) (Collector, error) { "Softnet backlog status", []string{"cpu"}, nil, ), - width: prometheus.NewDesc( - prometheus.BuildFQName(namespace, softnetSubsystem, "width"), - "softnet_data's Width", - []string{"cpu"}, nil, - ), logger: logger, }, nil } @@ -153,14 +147,8 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { ) ch <- prometheus.MustNewConstMetric( c.softnetBacklogLen, - prometheus.CounterValue, - float64(cpuStats.SoftnetBacklogLen), - cpu, - ) - ch <- prometheus.MustNewConstMetric( - c.width, prometheus.GaugeValue, - float64(cpuStats.Width), + float64(cpuStats.SoftnetBacklogLen), cpu, ) } From b15361ba91ccc2d7604fc660cf6d58b2833dc1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 17:28:37 +0200 Subject: [PATCH 12/15] remove width, softnet backlog must be a gauge not a counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 2 +- collector/fixtures/e2e-output.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index ec6db6cf4d..1670e7a5ca 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3041,7 +3041,7 @@ node_softirqs_total{vector="sched"} 622196 node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status -# TYPE node_softnet_backlog_len_total counter +# TYPE node_softnet_backlog_len_total gauge node_softnet_backlog_len_total{cpu="0"} 0 node_softnet_backlog_len_total{cpu="1"} 0 node_softnet_backlog_len_total{cpu="2"} 0 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 3d8cf08763..384af6f00c 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3063,7 +3063,7 @@ node_softirqs_total{vector="sched"} 622196 node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 # HELP node_softnet_backlog_len_total Softnet backlog status -# TYPE node_softnet_backlog_len_total counter +# TYPE node_softnet_backlog_len_total gauge node_softnet_backlog_len_total{cpu="0"} 0 node_softnet_backlog_len_total{cpu="1"} 0 node_softnet_backlog_len_total{cpu="2"} 0 From aa5fc6b52e9de20b2c40a1906356cb79accf2bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Thu, 11 May 2023 17:34:54 +0200 Subject: [PATCH 13/15] remove width, softnet backlog must be a gauge not a counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/fixtures/e2e-64k-page-output.txt | 12 ++++++------ collector/fixtures/e2e-output.txt | 12 ++++++------ collector/softnet_linux.go | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index 1670e7a5ca..a88917cacb 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt @@ -3040,12 +3040,12 @@ node_softirqs_total{vector="rcu"} 508444 node_softirqs_total{vector="sched"} 622196 node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 -# HELP node_softnet_backlog_len_total Softnet backlog status -# TYPE node_softnet_backlog_len_total gauge -node_softnet_backlog_len_total{cpu="0"} 0 -node_softnet_backlog_len_total{cpu="1"} 0 -node_softnet_backlog_len_total{cpu="2"} 0 -node_softnet_backlog_len_total{cpu="3"} 0 +# HELP node_softnet_backlog_len Softnet backlog status +# TYPE node_softnet_backlog_len gauge +node_softnet_backlog_len{cpu="0"} 0 +node_softnet_backlog_len{cpu="1"} 0 +node_softnet_backlog_len{cpu="2"} 0 +node_softnet_backlog_len{cpu="3"} 0 # HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting # TYPE node_softnet_cpu_collision_total counter node_softnet_cpu_collision_total{cpu="0"} 0 diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 384af6f00c..4abc3ef1ce 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -3062,12 +3062,12 @@ node_softirqs_total{vector="rcu"} 508444 node_softirqs_total{vector="sched"} 622196 node_softirqs_total{vector="tasklet"} 1.783454e+06 node_softirqs_total{vector="timer"} 1.481983e+06 -# HELP node_softnet_backlog_len_total Softnet backlog status -# TYPE node_softnet_backlog_len_total gauge -node_softnet_backlog_len_total{cpu="0"} 0 -node_softnet_backlog_len_total{cpu="1"} 0 -node_softnet_backlog_len_total{cpu="2"} 0 -node_softnet_backlog_len_total{cpu="3"} 0 +# HELP node_softnet_backlog_len Softnet backlog status +# TYPE node_softnet_backlog_len gauge +node_softnet_backlog_len{cpu="0"} 0 +node_softnet_backlog_len{cpu="1"} 0 +node_softnet_backlog_len{cpu="2"} 0 +node_softnet_backlog_len{cpu="3"} 0 # HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting # TYPE node_softnet_cpu_collision_total counter node_softnet_cpu_collision_total{cpu="0"} 0 diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index 9be4ffda1a..f978f5b5de 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -85,7 +85,7 @@ func NewSoftnetCollector(logger log.Logger) (Collector, error) { []string{"cpu"}, nil, ), softnetBacklogLen: prometheus.NewDesc( - prometheus.BuildFQName(namespace, softnetSubsystem, "backlog_len_total"), + prometheus.BuildFQName(namespace, softnetSubsystem, "backlog_len"), "Softnet backlog status", []string{"cpu"}, nil, ), From 79530dc5613f1582fec9e8075bd1e9f94a7dfae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Mon, 22 May 2023 15:09:55 +0200 Subject: [PATCH 14/15] comment to explain cpuStats.Index usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/softnet_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index f978f5b5de..a6602825b3 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -103,6 +103,10 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { } for cpuNumber, cpuStats := range stats { + // cpuStats.Index in /proc/net/softnet_stat was introduced in Linux 5.14 + // for older kernel we still rely on the line index + // Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 + // https://github.com/prometheus/procfs/pull/517 if cpuStats.Width >= 13 { cpu = strconv.FormatUint(uint64(cpuStats.Index), 10) } else { From 2c03caee6d650998f9a0a6979fd242c03f3e2541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Wed, 24 May 2023 15:48:05 +0200 Subject: [PATCH 15/15] rollback to Index for procfs 0.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Jouannet --- collector/softnet_linux.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/collector/softnet_linux.go b/collector/softnet_linux.go index a6602825b3..42d47780e3 100644 --- a/collector/softnet_linux.go +++ b/collector/softnet_linux.go @@ -102,16 +102,8 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error { return fmt.Errorf("could not get softnet statistics: %w", err) } - for cpuNumber, cpuStats := range stats { - // cpuStats.Index in /proc/net/softnet_stat was introduced in Linux 5.14 - // for older kernel we still rely on the line index - // Linux 5.14 https://elixir.bootlin.com/linux/v5.14/source/net/core/net-procfs.c#L169 - // https://github.com/prometheus/procfs/pull/517 - if cpuStats.Width >= 13 { - cpu = strconv.FormatUint(uint64(cpuStats.Index), 10) - } else { - cpu = strconv.Itoa(cpuNumber) - } + for _, cpuStats := range stats { + cpu = strconv.FormatUint(uint64(cpuStats.Index), 10) ch <- prometheus.MustNewConstMetric( c.processed,