From 69c1e58d368b5d4822f8f072340736b7a4baeefa Mon Sep 17 00:00:00 2001 From: Tobias Klausmann Date: Fri, 22 Sep 2023 15:23:42 +0200 Subject: [PATCH] NFSd: handle new wdeleg_getattr attribute in /proc/net/rpc/nfsd This attribute was introduced it v6.6-rc1. The relevant changes in procfs were merged here: https://github.com/prometheus/procfs/pull/574 and are part of procfs v0.11.2 I have also figured out that the stat should be part of the v4 ops counters struct, but that will need changes to both procfs and this code. Since people are already using 6.6-rc1, I think it's better to get the code out there --- even if they don't care about wdeleg_getattr, currently they get _no_ nfsd stats with 6.6-rc1. I will make two follow-up PRs to clean this up in the next releases of procfs and node-exporter. Signed-off-by: Tobias Klausmann --- collector/fixtures/e2e-output.txt | 1 + collector/fixtures/proc/net/rpc/nfsd | 1 + collector/nfsd_linux.go | 2 ++ go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 63a1bab774..217e0c1f5b 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2763,6 +2763,7 @@ node_nfsd_requests_total{method="SetAttr",proto="4"} 0 node_nfsd_requests_total{method="SymLink",proto="2"} 0 node_nfsd_requests_total{method="SymLink",proto="3"} 0 node_nfsd_requests_total{method="Verify",proto="4"} 3 +node_nfsd_requests_total{method="WdelegGetattr",proto="4"} 15 node_nfsd_requests_total{method="WrCache",proto="2"} 0 node_nfsd_requests_total{method="Write",proto="2"} 0 node_nfsd_requests_total{method="Write",proto="3"} 0 diff --git a/collector/fixtures/proc/net/rpc/nfsd b/collector/fixtures/proc/net/rpc/nfsd index 754f19d9d5..6a092bfd30 100644 --- a/collector/fixtures/proc/net/rpc/nfsd +++ b/collector/fixtures/proc/net/rpc/nfsd @@ -9,3 +9,4 @@ proc2 18 2 69 0 0 4410 0 0 0 0 0 0 0 0 0 0 0 99 2 proc3 22 2 112 0 2719 111 0 0 0 0 0 0 0 0 0 0 0 27 216 0 2 1 0 proc4 2 2 10853 proc4ops 72 0 0 0 1098 2 0 0 0 0 8179 5896 0 0 0 0 5900 0 0 2 0 2 0 9609 0 2 150 1272 0 0 0 1236 0 0 0 0 3 3 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 +wdeleg_getattr 15 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index faa6c960b3..0927b89537 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -82,6 +82,8 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdRequestsv2Stats(ch, &stats.V2Stats) c.updateNFSdRequestsv3Stats(ch, &stats.V3Stats) c.updateNFSdRequestsv4Stats(ch, &stats.V4Ops) + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(stats.WdelegGetattr), "4", "WdelegGetattr") return nil } diff --git a/go.mod b/go.mod index 107f11c97e..8b1df8841a 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/prometheus/client_model v0.4.0 github.com/prometheus/common v0.44.0 github.com/prometheus/exporter-toolkit v0.10.0 - github.com/prometheus/procfs v0.11.1 + github.com/prometheus/procfs v0.12.0 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/sys v0.12.0 diff --git a/go.sum b/go.sum index f1ea4e190f..c3f9d3779b 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,8 @@ github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdO github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/exporter-toolkit v0.10.0 h1:yOAzZTi4M22ZzVxD+fhy1URTuNRj/36uQJJ5S8IPza8= github.com/prometheus/exporter-toolkit v0.10.0/go.mod h1:+sVFzuvV5JDyw+Ih6p3zFxZNVnKQa3x5qPmDSiPu4ZY= -github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= -github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0= github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs=