Skip to content

Commit 8430129

Browse files
committed
nfsd: ignore unknown metric lines instead of failing
New kernel versions can add lines to /proc/net/rpc/nfsd (for example wdeleg_getattr on Linux 6.6+). Treating an unknown key as a hard error makes ParseServerRPCStats return nothing, so consumers such as node_exporter drop all NFSd metrics for one new field. Skip unknown keys and keep returning the metrics we already understand. Known keys (including wdeleg_getattr) are still parsed as before. Related to prometheus/node_exporter#2799 Signed-off-by: Dean Chen <862469039@qq.com>
1 parent f57ba67 commit 8430129

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

nfs/parse_nfsd.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ func ParseServerRPCStats(r io.Reader) (*ServerRPCStats, error) {
7676
case "wdeleg_getattr":
7777
stats.WdelegGetattr = values[0]
7878
default:
79-
return nil, fmt.Errorf("unknown NFSd metric line %q", metricLine)
79+
// Ignore unknown metric lines. New kernel versions may add stats
80+
// (e.g. wdeleg_getattr on Linux 6.6+); failing the whole parse
81+
// would drop all NFSd metrics from consumers such as node_exporter.
82+
continue
8083
}
8184
if err != nil {
8285
return nil, fmt.Errorf("errors parsing NFSd metric line: %w", err)

nfs/parse_nfsd_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,57 @@ wdeleg_getattr 765432`,
616616
},
617617
WdelegGetattr: 765432,
618618
},
619+
}, {
620+
name: "unknown metric line is ignored",
621+
content: `rc 1 2 3
622+
fh 0 0 0 0 0
623+
io 10 20
624+
th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000
625+
ra 32 0 0 0 0 0 0 0 0 0 0 0
626+
net 1 0 1 0
627+
rpc 1 0 0 0 0
628+
proc2 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
629+
proc3 22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
630+
proc4 2 0 0
631+
proc4ops 40 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
632+
wdeleg_getattr 7
633+
future_kernel_stat 42
634+
`,
635+
stats: &nfs.ServerRPCStats{
636+
ReplyCache: nfs.ReplyCache{
637+
Hits: 1,
638+
Misses: 2,
639+
NoCache: 3,
640+
},
641+
FileHandles: nfs.FileHandles{},
642+
InputOutput: nfs.InputOutput{
643+
Read: 10,
644+
Write: 20,
645+
},
646+
Threads: nfs.Threads{
647+
Threads: 8,
648+
FullCnt: 0,
649+
},
650+
ReadAheadCache: nfs.ReadAheadCache{
651+
CacheSize: 32,
652+
CacheHistogram: []uint64{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
653+
NotFound: 0,
654+
},
655+
Network: nfs.Network{
656+
NetCount: 1,
657+
UDPCount: 0,
658+
TCPCount: 1,
659+
TCPConnect: 0,
660+
},
661+
ServerRPC: nfs.ServerRPC{
662+
RPCCount: 1,
663+
},
664+
V2Stats: nfs.V2Stats{},
665+
V3Stats: nfs.V3Stats{},
666+
ServerV4Stats: nfs.ServerV4Stats{},
667+
V4Ops: nfs.V4Ops{},
668+
WdelegGetattr: 7,
669+
},
619670
},
620671
}
621672

0 commit comments

Comments
 (0)