Refactor NFS client collector (#816)
* Update vendor github.com/prometheus/procfs/... * Refactor NFS collector Use new procfs library to parse NFS client stats. * Ignore nfs proc file not existing. * Refactor with reflection to walk the structs.
This commit is contained in:
parent
52c031890e
commit
01bd99fb1a
5 changed files with 202 additions and 156 deletions
13
vendor/github.com/prometheus/procfs/nfs/parse.go
generated
vendored
13
vendor/github.com/prometheus/procfs/nfs/parse.go
generated
vendored
|
|
@ -178,8 +178,17 @@ func parseV3Stats(v []uint64) (V3Stats, error) {
|
|||
|
||||
func parseClientV4Stats(v []uint64) (ClientV4Stats, error) {
|
||||
values := int(v[0])
|
||||
if len(v[1:]) != values || values < 59 {
|
||||
return ClientV4Stats{}, fmt.Errorf("invalid V4Stats line %q", v)
|
||||
if len(v[1:]) != values {
|
||||
return ClientV4Stats{}, fmt.Errorf("invalid ClientV4Stats line %q", v)
|
||||
}
|
||||
|
||||
// This function currently supports mapping 59 NFS v4 client stats. Older
|
||||
// kernels may emit fewer stats, so we must detect this and pad out the
|
||||
// values to match the expected slice size.
|
||||
if values < 59 {
|
||||
newValues := make([]uint64, 60)
|
||||
copy(newValues, v)
|
||||
v = newValues
|
||||
}
|
||||
|
||||
return ClientV4Stats{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue