From 93c76bd328f8f2f814d0ccd6b93b293465c5bd40 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Fri, 26 Jan 2018 15:43:03 +0100 Subject: [PATCH 01/12] Add NFS Server metrics collector. --- collector/fixtures/e2e-output.txt | 10 +++ collector/fixtures/proc/net/rpc/nfsd | 11 ++++ collector/nfsd_linux.go | 91 ++++++++++++++++++++++++++++ end-to-end-test.sh | 1 + 4 files changed, 113 insertions(+) create mode 100644 collector/fixtures/proc/net/rpc/nfsd create mode 100644 collector/nfsd_linux.go diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 1ca5508683..96d8976c00 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2576,6 +2576,15 @@ node_nfs_rpc_operations 1.218785755e+09 # HELP node_nfs_rpc_retransmissions Number of RPC transmissions performed. # TYPE node_nfs_rpc_retransmissions counter node_nfs_rpc_retransmissions 374636 +# HELP node_nfsd_reply_cache_hits_total NFSd Reply Cache client did not receive a reply and decided to re-transmit its request and the reply was cached. (bad). +# TYPE node_nfsd_reply_cache_hits_total counter +node_nfsd_reply_cache_hits_total 0 +# HELP node_nfsd_reply_cache_misses_total NFSd Reply Cache an operation that requires caching (idempotent). +# TYPE node_nfsd_reply_cache_misses_total counter +node_nfsd_reply_cache_misses_total 6 +# HELP node_nfsd_reply_cache_nocache_total NFSd Reply Cache non-idempotent operations (rename/delete/…). +# TYPE node_nfsd_reply_cache_nocache_total counter +node_nfsd_reply_cache_nocache_total 18622 # HELP node_procs_blocked Number of processes blocked waiting for I/O to complete. # TYPE node_procs_blocked gauge node_procs_blocked 0 @@ -2630,6 +2639,7 @@ node_scrape_collector_success{collector="mountstats"} 1 node_scrape_collector_success{collector="netdev"} 1 node_scrape_collector_success{collector="netstat"} 1 node_scrape_collector_success{collector="nfs"} 1 +node_scrape_collector_success{collector="nfsd"} 1 node_scrape_collector_success{collector="qdisc"} 1 node_scrape_collector_success{collector="sockstat"} 1 node_scrape_collector_success{collector="stat"} 1 diff --git a/collector/fixtures/proc/net/rpc/nfsd b/collector/fixtures/proc/net/rpc/nfsd new file mode 100644 index 0000000000..4e8565f41b --- /dev/null +++ b/collector/fixtures/proc/net/rpc/nfsd @@ -0,0 +1,11 @@ +rc 0 6 18622 +fh 0 0 0 0 0 +io 157286400 0 +th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 +ra 32 0 0 0 0 0 0 0 0 0 0 0 +net 18628 0 18628 6 +rpc 18628 0 0 0 0 +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 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go new file mode 100644 index 0000000000..2c1c348e87 --- /dev/null +++ b/collector/nfsd_linux.go @@ -0,0 +1,91 @@ +// Copyright 2018 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package collector + +import ( + "fmt" + + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/procfs" + "github.com/prometheus/procfs/nfs" +) + +// A nfsdCollector is a Collector which gathers metrics from /proc/net/rpc/nfsd. +// See: https://www.svennd.be/nfsd-stats-explained-procnetrpcnfsd/ +type nfsdCollector struct { + fs procfs.FS +} + +func init() { + registerCollector("nfsd", defaultEnabled, NewNFSdCollector) +} + +const ( + nfsdSubsystem = "nfsd" +) + +// NewNFSdCollector returns a new Collector exposing /proc/net/rpc/nfsd statistics. +func NewNFSdCollector() (Collector, error) { + fs, err := procfs.NewFS(*procPath) + if err != nil { + return nil, fmt.Errorf("failed to open procfs: %v", err) + } + + return &nfsdCollector{ + fs: fs, + }, nil +} + +// Update implements Collector. +func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { + stats, err := c.fs.NFSdServerRPCStats() + if err != nil { + return fmt.Errorf("failed to retrieve nfsd stats: %v", err) + } + + c.updateNFSdReplyCacheStats(ch, &stats.ReplyCache) + + return nil +} + +// updateNFSdReplyCacheStats collects statistics for /proc/net/rpc/nfsd. +func (c *nfsdCollector) updateNFSdReplyCacheStats(ch chan<- prometheus.Metric, s *nfs.ReplyCache) { + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "reply_cache_hits_total"), + "NFSd Reply Cache client did not receive a reply and decided to re-transmit its request and the reply was cached. (bad).", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.Hits)) + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "reply_cache_misses_total"), + "NFSd Reply Cache an operation that requires caching (idempotent).", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.Misses)) + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "reply_cache_nocache_total"), + "NFSd Reply Cache non-idempotent operations (rename/delete/…).", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.NoCache)) +} diff --git a/end-to-end-test.sh b/end-to-end-test.sh index da84a91a83..29fc5862cf 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -26,6 +26,7 @@ enabled_collectors=$(cat << COLLECTORS netdev netstat nfs + nfsd qdisc sockstat stat From 272be98f92628683ed2480e9dbd14c1b75515a27 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sat, 27 Jan 2018 11:15:20 +0100 Subject: [PATCH 02/12] Add File Handles metrics. --- collector/fixtures/e2e-output.txt | 3 +++ collector/nfsd_linux.go | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 96d8976c00..a14401c253 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2576,6 +2576,9 @@ node_nfs_rpc_operations 1.218785755e+09 # HELP node_nfs_rpc_retransmissions Number of RPC transmissions performed. # TYPE node_nfs_rpc_retransmissions counter node_nfs_rpc_retransmissions 374636 +# HELP node_nfsd_file_handles_stale_total NFSd stale file handles +# TYPE node_nfsd_file_handles_stale_total counter +node_nfsd_file_handles_stale_total 0 # HELP node_nfsd_reply_cache_hits_total NFSd Reply Cache client did not receive a reply and decided to re-transmit its request and the reply was cached. (bad). # TYPE node_nfsd_reply_cache_hits_total counter node_nfsd_reply_cache_hits_total 0 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 2c1c348e87..0e0f7ef861 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -55,11 +55,12 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { } c.updateNFSdReplyCacheStats(ch, &stats.ReplyCache) + c.updateNFSdFileHandlesStats(ch, &stats.FileHandles) return nil } -// updateNFSdReplyCacheStats collects statistics for /proc/net/rpc/nfsd. +// updateNFSdReplyCacheStats collects statistics for the reply cache. func (c *nfsdCollector) updateNFSdReplyCacheStats(ch chan<- prometheus.Metric, s *nfs.ReplyCache) { ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( @@ -89,3 +90,17 @@ func (c *nfsdCollector) updateNFSdReplyCacheStats(ch chan<- prometheus.Metric, s prometheus.CounterValue, float64(s.NoCache)) } + +// updateNFSdFileHandlesStats collects statistics for the file handles. +func (c *nfsdCollector) updateNFSdFileHandlesStats(ch chan<- prometheus.Metric, s *nfs.FileHandles) { + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "file_handles_stale_total"), + "NFSd stale file handles", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.Stale)) + // NOTE: Other FileHandles entries are unused in the kernel. +} From 86b46acd7f6e562d25de14420ae4c96260b352ae Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 29 Jan 2018 22:19:51 +0100 Subject: [PATCH 03/12] Add nfsd IO stats. --- collector/fixtures/e2e-output.txt | 6 ++++++ collector/fixtures/proc/net/rpc/nfsd | 2 +- collector/nfsd_linux.go | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index a14401c253..baf9873c9f 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2576,6 +2576,12 @@ node_nfs_rpc_operations 1.218785755e+09 # HELP node_nfs_rpc_retransmissions Number of RPC transmissions performed. # TYPE node_nfs_rpc_retransmissions counter node_nfs_rpc_retransmissions 374636 +# HELP node_nfsd_disk_bytes_read_total NFSd bytes read +# TYPE node_nfsd_disk_bytes_read_total counter +node_nfsd_disk_bytes_read_total 1.572864e+08 +# HELP node_nfsd_disk_bytes_written_total NFSd bytes written +# TYPE node_nfsd_disk_bytes_written_total counter +node_nfsd_disk_bytes_written_total 72864 # HELP node_nfsd_file_handles_stale_total NFSd stale file handles # TYPE node_nfsd_file_handles_stale_total counter node_nfsd_file_handles_stale_total 0 diff --git a/collector/fixtures/proc/net/rpc/nfsd b/collector/fixtures/proc/net/rpc/nfsd index 4e8565f41b..d393638314 100644 --- a/collector/fixtures/proc/net/rpc/nfsd +++ b/collector/fixtures/proc/net/rpc/nfsd @@ -1,6 +1,6 @@ rc 0 6 18622 fh 0 0 0 0 0 -io 157286400 0 +io 157286400 72864 th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ra 32 0 0 0 0 0 0 0 0 0 0 0 net 18628 0 18628 6 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 0e0f7ef861..49de605c6e 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -56,6 +56,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdReplyCacheStats(ch, &stats.ReplyCache) c.updateNFSdFileHandlesStats(ch, &stats.FileHandles) + c.updateNFSdInputOutputStats(ch, &stats.InputOutput) return nil } @@ -104,3 +105,25 @@ func (c *nfsdCollector) updateNFSdFileHandlesStats(ch chan<- prometheus.Metric, float64(s.Stale)) // NOTE: Other FileHandles entries are unused in the kernel. } + +// updateNFSdInputOutputStats collects statistics for the bytes in/out. +func (c *nfsdCollector) updateNFSdInputOutputStats(ch chan<- prometheus.Metric, s *nfs.InputOutput) { + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "disk_bytes_read_total"), + "NFSd bytes read", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.Read)) + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "disk_bytes_written_total"), + "NFSd bytes written", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.Write)) +} From 56dcbdcd98194474d8646c564eb56001890a9fb0 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 29 Jan 2018 22:24:51 +0100 Subject: [PATCH 04/12] Add metrics for NFSd threads. --- collector/fixtures/e2e-output.txt | 3 +++ collector/nfsd_linux.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index baf9873c9f..e60ae1d075 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2594,6 +2594,9 @@ node_nfsd_reply_cache_misses_total 6 # HELP node_nfsd_reply_cache_nocache_total NFSd Reply Cache non-idempotent operations (rename/delete/…). # TYPE node_nfsd_reply_cache_nocache_total counter node_nfsd_reply_cache_nocache_total 18622 +# HELP node_nfsd_server_threads NFSd how many kernel threads are running +# TYPE node_nfsd_server_threads gauge +node_nfsd_server_threads 8 # HELP node_procs_blocked Number of processes blocked waiting for I/O to complete. # TYPE node_procs_blocked gauge node_procs_blocked 0 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 49de605c6e..2024f32819 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -57,6 +57,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdReplyCacheStats(ch, &stats.ReplyCache) c.updateNFSdFileHandlesStats(ch, &stats.FileHandles) c.updateNFSdInputOutputStats(ch, &stats.InputOutput) + c.updateNFSdThreadsStats(ch, &stats.Threads) return nil } @@ -127,3 +128,16 @@ func (c *nfsdCollector) updateNFSdInputOutputStats(ch chan<- prometheus.Metric, prometheus.CounterValue, float64(s.Write)) } + +// updateNFSdThreadsStats collects statistics for kernel server threads. +func (c *nfsdCollector) updateNFSdThreadsStats(ch chan<- prometheus.Metric, s *nfs.Threads) { + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "server_threads"), + "NFSd how many kernel threads are running", + nil, + nil, + ), + prometheus.GaugeValue, + float64(s.Threads)) +} From f3c3baf26aa3ae2b4946f213755346feac681652 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 29 Jan 2018 22:33:25 +0100 Subject: [PATCH 05/12] Add metrics for NFSd read ahead cache. --- collector/fixtures/e2e-output.txt | 6 ++++++ collector/nfsd_linux.go | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index e60ae1d075..ddd63ca4a3 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2585,6 +2585,12 @@ node_nfsd_disk_bytes_written_total 72864 # HELP node_nfsd_file_handles_stale_total NFSd stale file handles # TYPE node_nfsd_file_handles_stale_total counter node_nfsd_file_handles_stale_total 0 +# HELP node_nfsd_read_ahead_cache_not_found_total NFSd how large the read ahead cache in blocks +# TYPE node_nfsd_read_ahead_cache_not_found_total counter +node_nfsd_read_ahead_cache_not_found_total 0 +# HELP node_nfsd_read_ahead_cache_size_blocks NFSd how large the read ahead cache in blocks +# TYPE node_nfsd_read_ahead_cache_size_blocks gauge +node_nfsd_read_ahead_cache_size_blocks 32 # HELP node_nfsd_reply_cache_hits_total NFSd Reply Cache client did not receive a reply and decided to re-transmit its request and the reply was cached. (bad). # TYPE node_nfsd_reply_cache_hits_total counter node_nfsd_reply_cache_hits_total 0 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 2024f32819..9841cfefac 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -58,6 +58,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdFileHandlesStats(ch, &stats.FileHandles) c.updateNFSdInputOutputStats(ch, &stats.InputOutput) c.updateNFSdThreadsStats(ch, &stats.Threads) + c.updateNFSdReadAheadCacheStats(ch, &stats.ReadAheadCache) return nil } @@ -141,3 +142,25 @@ func (c *nfsdCollector) updateNFSdThreadsStats(ch chan<- prometheus.Metric, s *n prometheus.GaugeValue, float64(s.Threads)) } + +// updateNFSdReadAheadCacheStats collects statistics for the read ahead cache. +func (c *nfsdCollector) updateNFSdReadAheadCacheStats(ch chan<- prometheus.Metric, s *nfs.ReadAheadCache) { + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "read_ahead_cache_size_blocks"), + "NFSd how large the read ahead cache in blocks", + nil, + nil, + ), + prometheus.GaugeValue, + float64(s.CacheSize)) + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "read_ahead_cache_not_found_total"), + "NFSd how large the read ahead cache in blocks", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.NotFound)) +} From eb21f717d4aa5cc2a96c0076dc814237f53e144e Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 29 Jan 2018 23:02:25 +0100 Subject: [PATCH 06/12] Add NFSd network traffic counters. --- collector/fixtures/e2e-output.txt | 7 +++++++ collector/fixtures/proc/net/rpc/nfsd | 2 +- collector/nfsd_linux.go | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index ddd63ca4a3..33454447b0 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2576,6 +2576,9 @@ node_nfs_rpc_operations 1.218785755e+09 # HELP node_nfs_rpc_retransmissions Number of RPC transmissions performed. # TYPE node_nfs_rpc_retransmissions counter node_nfs_rpc_retransmissions 374636 +# HELP node_nfsd_connections_total NFSd how many TCP connections have been made +# TYPE node_nfsd_connections_total counter +node_nfsd_connections_total 1 # HELP node_nfsd_disk_bytes_read_total NFSd bytes read # TYPE node_nfsd_disk_bytes_read_total counter node_nfsd_disk_bytes_read_total 1.572864e+08 @@ -2585,6 +2588,10 @@ node_nfsd_disk_bytes_written_total 72864 # HELP node_nfsd_file_handles_stale_total NFSd stale file handles # TYPE node_nfsd_file_handles_stale_total counter node_nfsd_file_handles_stale_total 0 +# HELP node_nfsd_packets_total NFSd how many network packets have been sent/recieved +# TYPE node_nfsd_packets_total counter +node_nfsd_packets_total{proto="tcp"} 917 +node_nfsd_packets_total{proto="udp"} 55 # HELP node_nfsd_read_ahead_cache_not_found_total NFSd how large the read ahead cache in blocks # TYPE node_nfsd_read_ahead_cache_not_found_total counter node_nfsd_read_ahead_cache_not_found_total 0 diff --git a/collector/fixtures/proc/net/rpc/nfsd b/collector/fixtures/proc/net/rpc/nfsd index d393638314..73a0c468be 100644 --- a/collector/fixtures/proc/net/rpc/nfsd +++ b/collector/fixtures/proc/net/rpc/nfsd @@ -3,7 +3,7 @@ fh 0 0 0 0 0 io 157286400 72864 th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ra 32 0 0 0 0 0 0 0 0 0 0 0 -net 18628 0 18628 6 +net 972 55 917 1 rpc 18628 0 0 0 0 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 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 9841cfefac..c745d06ffa 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -59,6 +59,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdInputOutputStats(ch, &stats.InputOutput) c.updateNFSdThreadsStats(ch, &stats.Threads) c.updateNFSdReadAheadCacheStats(ch, &stats.ReadAheadCache) + c.updateNFSdNetworkStats(ch, &stats.Network) return nil } @@ -164,3 +165,30 @@ func (c *nfsdCollector) updateNFSdReadAheadCacheStats(ch chan<- prometheus.Metri prometheus.CounterValue, float64(s.NotFound)) } + +// updateNFSdNetworkStats collects statistics for network packets/connections. +func (c *nfsdCollector) updateNFSdNetworkStats(ch chan<- prometheus.Metric, s *nfs.Network) { + packetDesc := prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "packets_total"), + "NFSd how many network packets have been sent/recieved", + []string{"proto"}, + nil, + ) + ch <- prometheus.MustNewConstMetric( + packetDesc, + prometheus.CounterValue, + float64(s.UDPCount), "udp") + ch <- prometheus.MustNewConstMetric( + packetDesc, + prometheus.CounterValue, + float64(s.TCPCount), "tcp") + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "connections_total"), + "NFSd how many TCP connections have been made", + nil, + nil, + ), + prometheus.CounterValue, + float64(s.TCPConnect)) +} From 94760075244ba4a39c27806684fd14e2f91b5a80 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 30 Jan 2018 12:11:45 +0100 Subject: [PATCH 07/12] Add RPC metrics. --- collector/fixtures/e2e-output.txt | 8 +++++++ collector/fixtures/proc/net/rpc/nfsd | 2 +- collector/nfsd_linux.go | 32 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 33454447b0..74063d1ef9 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2607,6 +2607,14 @@ node_nfsd_reply_cache_misses_total 6 # HELP node_nfsd_reply_cache_nocache_total NFSd Reply Cache non-idempotent operations (rename/delete/…). # TYPE node_nfsd_reply_cache_nocache_total counter node_nfsd_reply_cache_nocache_total 18622 +# HELP node_nfsd_rpc_errors_total NFSd RPC errors +# TYPE node_nfsd_rpc_errors_total counter +node_nfsd_rpc_errors_total{error="auth"} 2 +node_nfsd_rpc_errors_total{error="cInt"} 0 +node_nfsd_rpc_errors_total{error="fmt"} 1 +# HELP node_nfsd_server_rpcs_total NFSd how many RPCs +# TYPE node_nfsd_server_rpcs_total gauge +node_nfsd_server_rpcs_total 18628 # HELP node_nfsd_server_threads NFSd how many kernel threads are running # TYPE node_nfsd_server_threads gauge node_nfsd_server_threads 8 diff --git a/collector/fixtures/proc/net/rpc/nfsd b/collector/fixtures/proc/net/rpc/nfsd index 73a0c468be..754f19d9d5 100644 --- a/collector/fixtures/proc/net/rpc/nfsd +++ b/collector/fixtures/proc/net/rpc/nfsd @@ -4,7 +4,7 @@ io 157286400 72864 th 8 0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 ra 32 0 0 0 0 0 0 0 0 0 0 0 net 972 55 917 1 -rpc 18628 0 0 0 0 +rpc 18628 3 1 2 0 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 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index c745d06ffa..1ddce49717 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -60,6 +60,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdThreadsStats(ch, &stats.Threads) c.updateNFSdReadAheadCacheStats(ch, &stats.ReadAheadCache) c.updateNFSdNetworkStats(ch, &stats.Network) + c.updateNFSdServerRPCStats(ch, &stats.ServerRPC) return nil } @@ -192,3 +193,34 @@ func (c *nfsdCollector) updateNFSdNetworkStats(ch chan<- prometheus.Metric, s *n prometheus.CounterValue, float64(s.TCPConnect)) } + +// updateNFSdServerRPCStats collects statistics for kernel server RPCs. +func (c *nfsdCollector) updateNFSdServerRPCStats(ch chan<- prometheus.Metric, s *nfs.ServerRPC) { + badRPCDesc := prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "rpc_errors_total"), + "NFSd RPC errors", + []string{"error"}, + nil, + ) + ch <- prometheus.MustNewConstMetric( + badRPCDesc, + prometheus.CounterValue, + float64(s.BadFmt), "fmt") + ch <- prometheus.MustNewConstMetric( + badRPCDesc, + prometheus.CounterValue, + float64(s.BadAuth), "auth") + ch <- prometheus.MustNewConstMetric( + badRPCDesc, + prometheus.CounterValue, + float64(s.BadcInt), "cInt") + ch <- prometheus.MustNewConstMetric( + prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "server_rpcs_total"), + "NFSd how many RPCs", + nil, + nil, + ), + prometheus.GaugeValue, + float64(s.RPCCount)) +} From 46619641536ed30d18da81b90754a315e2405df1 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 30 Jan 2018 12:26:26 +0100 Subject: [PATCH 08/12] Add V2 requests metrics. --- collector/fixtures/e2e-output.txt | 19 ++++++++++++ collector/nfsd_linux.go | 48 ++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 74063d1ef9..3927dc9657 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2607,6 +2607,25 @@ node_nfsd_reply_cache_misses_total 6 # HELP node_nfsd_reply_cache_nocache_total NFSd Reply Cache non-idempotent operations (rename/delete/…). # TYPE node_nfsd_reply_cache_nocache_total counter node_nfsd_reply_cache_nocache_total 18622 +# HELP node_nfsd_requests_total Number NFSd Requests by method and protocol. +# TYPE node_nfsd_requests_total counter +node_nfsd_requests_total{method="Create",proto="v2"} 0 +node_nfsd_requests_total{method="FsStat",proto="v2"} 2 +node_nfsd_requests_total{method="GetAttr",proto="v2"} 69 +node_nfsd_requests_total{method="Link",proto="v2"} 0 +node_nfsd_requests_total{method="Lookup",proto="v2"} 4410 +node_nfsd_requests_total{method="MkDir",proto="v2"} 0 +node_nfsd_requests_total{method="Read",proto="v2"} 0 +node_nfsd_requests_total{method="ReadDir",proto="v2"} 99 +node_nfsd_requests_total{method="ReadLink",proto="v2"} 0 +node_nfsd_requests_total{method="Remove",proto="v2"} 0 +node_nfsd_requests_total{method="Rename",proto="v2"} 0 +node_nfsd_requests_total{method="RmDir",proto="v2"} 0 +node_nfsd_requests_total{method="Root",proto="v2"} 0 +node_nfsd_requests_total{method="SetAttr",proto="v2"} 0 +node_nfsd_requests_total{method="SymLink",proto="v2"} 0 +node_nfsd_requests_total{method="WrCache",proto="v2"} 0 +node_nfsd_requests_total{method="Write",proto="v2"} 0 # HELP node_nfsd_rpc_errors_total NFSd RPC errors # TYPE node_nfsd_rpc_errors_total counter node_nfsd_rpc_errors_total{error="auth"} 2 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 1ddce49717..db9dc6410e 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -24,7 +24,8 @@ import ( // A nfsdCollector is a Collector which gathers metrics from /proc/net/rpc/nfsd. // See: https://www.svennd.be/nfsd-stats-explained-procnetrpcnfsd/ type nfsdCollector struct { - fs procfs.FS + fs procfs.FS + requestsDesc *prometheus.Desc } func init() { @@ -44,6 +45,11 @@ func NewNFSdCollector() (Collector, error) { return &nfsdCollector{ fs: fs, + requestsDesc: prometheus.NewDesc( + prometheus.BuildFQName(namespace, nfsdSubsystem, "requests_total"), + "Number NFSd Requests by method and protocol.", + []string{"proto", "method"}, nil, + ), }, nil } @@ -61,6 +67,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdReadAheadCacheStats(ch, &stats.ReadAheadCache) c.updateNFSdNetworkStats(ch, &stats.Network) c.updateNFSdServerRPCStats(ch, &stats.ServerRPC) + c.updateNFSdRequestsv2Stats(ch, &stats.V2Stats) return nil } @@ -224,3 +231,42 @@ func (c *nfsdCollector) updateNFSdServerRPCStats(ch chan<- prometheus.Metric, s prometheus.GaugeValue, float64(s.RPCCount)) } + +// updateNFSdRequestsv2Stats collects statistics for NFSv2 requests. +func (c *nfsdCollector) updateNFSdRequestsv2Stats(ch chan<- prometheus.Metric, s *nfs.V2Stats) { + const proto = "v2" + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.GetAttr), proto, "GetAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SetAttr), proto, "SetAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Root), proto, "Root") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Lookup), proto, "Lookup") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadLink), proto, "ReadLink") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Read), proto, "Read") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.WrCache), proto, "WrCache") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Write), proto, "Write") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Create), proto, "Create") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Remove), proto, "Remove") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Rename), proto, "Rename") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Link), proto, "Link") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SymLink), proto, "SymLink") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.MkDir), proto, "MkDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.RmDir), proto, "RmDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadDir), proto, "ReadDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.FsStat), proto, "FsStat") +} From 134ad433769203673c3b5af349565a7fbfb629c7 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 30 Jan 2018 12:32:18 +0100 Subject: [PATCH 09/12] Add NFSv3 metrics. --- collector/fixtures/e2e-output.txt | 21 ++++++++++++++ collector/nfsd_linux.go | 48 +++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 3927dc9657..f8f92ebce8 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2609,23 +2609,44 @@ node_nfsd_reply_cache_misses_total 6 node_nfsd_reply_cache_nocache_total 18622 # HELP node_nfsd_requests_total Number NFSd Requests by method and protocol. # TYPE node_nfsd_requests_total counter +node_nfsd_requests_total{method="Access",proto="v3"} 111 +node_nfsd_requests_total{method="Commit",proto="v3"} 0 node_nfsd_requests_total{method="Create",proto="v2"} 0 +node_nfsd_requests_total{method="Create",proto="v3"} 0 +node_nfsd_requests_total{method="FsInfo",proto="v3"} 2 node_nfsd_requests_total{method="FsStat",proto="v2"} 2 +node_nfsd_requests_total{method="FsStat",proto="v3"} 0 node_nfsd_requests_total{method="GetAttr",proto="v2"} 69 +node_nfsd_requests_total{method="GetAttr",proto="v3"} 112 node_nfsd_requests_total{method="Link",proto="v2"} 0 +node_nfsd_requests_total{method="Link",proto="v3"} 0 node_nfsd_requests_total{method="Lookup",proto="v2"} 4410 +node_nfsd_requests_total{method="Lookup",proto="v3"} 2719 node_nfsd_requests_total{method="MkDir",proto="v2"} 0 +node_nfsd_requests_total{method="MkDir",proto="v3"} 0 +node_nfsd_requests_total{method="MkNod",proto="v3"} 0 +node_nfsd_requests_total{method="PathConf",proto="v3"} 1 node_nfsd_requests_total{method="Read",proto="v2"} 0 +node_nfsd_requests_total{method="Read",proto="v3"} 0 node_nfsd_requests_total{method="ReadDir",proto="v2"} 99 +node_nfsd_requests_total{method="ReadDir",proto="v3"} 27 +node_nfsd_requests_total{method="ReadDirPlus",proto="v3"} 216 node_nfsd_requests_total{method="ReadLink",proto="v2"} 0 +node_nfsd_requests_total{method="ReadLink",proto="v3"} 0 node_nfsd_requests_total{method="Remove",proto="v2"} 0 +node_nfsd_requests_total{method="Remove",proto="v3"} 0 node_nfsd_requests_total{method="Rename",proto="v2"} 0 +node_nfsd_requests_total{method="Rename",proto="v3"} 0 node_nfsd_requests_total{method="RmDir",proto="v2"} 0 +node_nfsd_requests_total{method="RmDir",proto="v3"} 0 node_nfsd_requests_total{method="Root",proto="v2"} 0 node_nfsd_requests_total{method="SetAttr",proto="v2"} 0 +node_nfsd_requests_total{method="SetAttr",proto="v3"} 0 node_nfsd_requests_total{method="SymLink",proto="v2"} 0 +node_nfsd_requests_total{method="SymLink",proto="v3"} 0 node_nfsd_requests_total{method="WrCache",proto="v2"} 0 node_nfsd_requests_total{method="Write",proto="v2"} 0 +node_nfsd_requests_total{method="Write",proto="v3"} 0 # HELP node_nfsd_rpc_errors_total NFSd RPC errors # TYPE node_nfsd_rpc_errors_total counter node_nfsd_rpc_errors_total{error="auth"} 2 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index db9dc6410e..60d3b16614 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -68,6 +68,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdNetworkStats(ch, &stats.Network) c.updateNFSdServerRPCStats(ch, &stats.ServerRPC) c.updateNFSdRequestsv2Stats(ch, &stats.V2Stats) + c.updateNFSdRequestsv3Stats(ch, &stats.V3Stats) return nil } @@ -270,3 +271,50 @@ func (c *nfsdCollector) updateNFSdRequestsv2Stats(ch chan<- prometheus.Metric, s ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, float64(s.FsStat), proto, "FsStat") } + +// updateNFSdRequestsv3Stats collects statistics for NFSv3 requests. +func (c *nfsdCollector) updateNFSdRequestsv3Stats(ch chan<- prometheus.Metric, s *nfs.V3Stats) { + const proto = "v3" + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.GetAttr), proto, "GetAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SetAttr), proto, "SetAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Lookup), proto, "Lookup") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Access), proto, "Access") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadLink), proto, "ReadLink") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Read), proto, "Read") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Write), proto, "Write") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Create), proto, "Create") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.MkDir), proto, "MkDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SymLink), proto, "SymLink") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.MkNod), proto, "MkNod") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Remove), proto, "Remove") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.RmDir), proto, "RmDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Rename), proto, "Rename") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Link), proto, "Link") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadDir), proto, "ReadDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadDirPlus), proto, "ReadDirPlus") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.FsStat), proto, "FsStat") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.FsInfo), proto, "FsInfo") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.PathConf), proto, "PathConf") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Commit), proto, "Commit") +} From 7e11ac64bc458665726622127eb38e567c16c29c Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 30 Jan 2018 12:40:15 +0100 Subject: [PATCH 10/12] Add NFSv4 metrics. --- collector/fixtures/e2e-output.txt | 33 ++++++++++++++ collector/nfsd_linux.go | 72 +++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index f8f92ebce8..8cf38909d3 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2610,43 +2610,76 @@ node_nfsd_reply_cache_nocache_total 18622 # HELP node_nfsd_requests_total Number NFSd Requests by method and protocol. # TYPE node_nfsd_requests_total counter node_nfsd_requests_total{method="Access",proto="v3"} 111 +node_nfsd_requests_total{method="Access",proto="v4"} 1098 +node_nfsd_requests_total{method="Close",proto="v4"} 2 node_nfsd_requests_total{method="Commit",proto="v3"} 0 +node_nfsd_requests_total{method="Commit",proto="v4"} 0 node_nfsd_requests_total{method="Create",proto="v2"} 0 node_nfsd_requests_total{method="Create",proto="v3"} 0 +node_nfsd_requests_total{method="Create",proto="v4"} 0 +node_nfsd_requests_total{method="DelegPurge",proto="v4"} 0 +node_nfsd_requests_total{method="DelegReturn",proto="v4"} 0 node_nfsd_requests_total{method="FsInfo",proto="v3"} 2 node_nfsd_requests_total{method="FsStat",proto="v2"} 2 node_nfsd_requests_total{method="FsStat",proto="v3"} 0 node_nfsd_requests_total{method="GetAttr",proto="v2"} 69 node_nfsd_requests_total{method="GetAttr",proto="v3"} 112 +node_nfsd_requests_total{method="GetAttr",proto="v4"} 8179 +node_nfsd_requests_total{method="GetFH",proto="v4"} 5896 node_nfsd_requests_total{method="Link",proto="v2"} 0 node_nfsd_requests_total{method="Link",proto="v3"} 0 +node_nfsd_requests_total{method="Link",proto="v4"} 0 +node_nfsd_requests_total{method="Lock",proto="v4"} 0 +node_nfsd_requests_total{method="Lockt",proto="v4"} 0 +node_nfsd_requests_total{method="Locku",proto="v4"} 0 node_nfsd_requests_total{method="Lookup",proto="v2"} 4410 node_nfsd_requests_total{method="Lookup",proto="v3"} 2719 +node_nfsd_requests_total{method="Lookup",proto="v4"} 5900 +node_nfsd_requests_total{method="LookupRoot",proto="v4"} 0 node_nfsd_requests_total{method="MkDir",proto="v2"} 0 node_nfsd_requests_total{method="MkDir",proto="v3"} 0 node_nfsd_requests_total{method="MkNod",proto="v3"} 0 +node_nfsd_requests_total{method="Nverify",proto="v4"} 0 +node_nfsd_requests_total{method="Open",proto="v4"} 2 +node_nfsd_requests_total{method="OpenAttr",proto="v4"} 0 +node_nfsd_requests_total{method="OpenConfirm",proto="v4"} 2 +node_nfsd_requests_total{method="OpenDgrd",proto="v4"} 0 node_nfsd_requests_total{method="PathConf",proto="v3"} 1 +node_nfsd_requests_total{method="PutFH",proto="v4"} 9609 node_nfsd_requests_total{method="Read",proto="v2"} 0 node_nfsd_requests_total{method="Read",proto="v3"} 0 +node_nfsd_requests_total{method="Read",proto="v4"} 150 node_nfsd_requests_total{method="ReadDir",proto="v2"} 99 node_nfsd_requests_total{method="ReadDir",proto="v3"} 27 +node_nfsd_requests_total{method="ReadDir",proto="v4"} 1272 node_nfsd_requests_total{method="ReadDirPlus",proto="v3"} 216 node_nfsd_requests_total{method="ReadLink",proto="v2"} 0 node_nfsd_requests_total{method="ReadLink",proto="v3"} 0 +node_nfsd_requests_total{method="ReadLink",proto="v4"} 0 +node_nfsd_requests_total{method="RelLockOwner",proto="v4"} 0 node_nfsd_requests_total{method="Remove",proto="v2"} 0 node_nfsd_requests_total{method="Remove",proto="v3"} 0 +node_nfsd_requests_total{method="Remove",proto="v4"} 0 node_nfsd_requests_total{method="Rename",proto="v2"} 0 node_nfsd_requests_total{method="Rename",proto="v3"} 0 +node_nfsd_requests_total{method="Rename",proto="v4"} 0 +node_nfsd_requests_total{method="Renew",proto="v4"} 1236 +node_nfsd_requests_total{method="RestoreFH",proto="v4"} 0 node_nfsd_requests_total{method="RmDir",proto="v2"} 0 node_nfsd_requests_total{method="RmDir",proto="v3"} 0 node_nfsd_requests_total{method="Root",proto="v2"} 0 +node_nfsd_requests_total{method="SaveFH",proto="v4"} 0 +node_nfsd_requests_total{method="SecInfo",proto="v4"} 0 node_nfsd_requests_total{method="SetAttr",proto="v2"} 0 node_nfsd_requests_total{method="SetAttr",proto="v3"} 0 +node_nfsd_requests_total{method="SetAttr",proto="v4"} 0 node_nfsd_requests_total{method="SymLink",proto="v2"} 0 node_nfsd_requests_total{method="SymLink",proto="v3"} 0 +node_nfsd_requests_total{method="Verify",proto="v4"} 3 node_nfsd_requests_total{method="WrCache",proto="v2"} 0 node_nfsd_requests_total{method="Write",proto="v2"} 0 node_nfsd_requests_total{method="Write",proto="v3"} 0 +node_nfsd_requests_total{method="Write",proto="v4"} 3 # HELP node_nfsd_rpc_errors_total NFSd RPC errors # TYPE node_nfsd_rpc_errors_total counter node_nfsd_rpc_errors_total{error="auth"} 2 diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 60d3b16614..0fd1fc85d1 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -69,6 +69,7 @@ func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error { c.updateNFSdServerRPCStats(ch, &stats.ServerRPC) c.updateNFSdRequestsv2Stats(ch, &stats.V2Stats) c.updateNFSdRequestsv3Stats(ch, &stats.V3Stats) + c.updateNFSdRequestsv4Stats(ch, &stats.V4Ops) return nil } @@ -318,3 +319,74 @@ func (c *nfsdCollector) updateNFSdRequestsv3Stats(ch chan<- prometheus.Metric, s ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, float64(s.Commit), proto, "Commit") } + +// updateNFSdRequestsv4Stats collects statistics for NFSv4 requests. +func (c *nfsdCollector) updateNFSdRequestsv4Stats(ch chan<- prometheus.Metric, s *nfs.V4Ops) { + const proto = "v4" + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Access), proto, "Access") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Close), proto, "Close") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Commit), proto, "Commit") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Create), proto, "Create") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.DelegPurge), proto, "DelegPurge") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.DelegReturn), proto, "DelegReturn") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.GetAttr), proto, "GetAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.GetFH), proto, "GetFH") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Link), proto, "Link") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Lock), proto, "Lock") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Lockt), proto, "Lockt") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Locku), proto, "Locku") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Lookup), proto, "Lookup") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.LookupRoot), proto, "LookupRoot") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Nverify), proto, "Nverify") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Open), proto, "Open") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.OpenAttr), proto, "OpenAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.OpenConfirm), proto, "OpenConfirm") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.OpenDgrd), proto, "OpenDgrd") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.PutFH), proto, "PutFH") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Read), proto, "Read") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadDir), proto, "ReadDir") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.ReadLink), proto, "ReadLink") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Remove), proto, "Remove") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Rename), proto, "Rename") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Renew), proto, "Renew") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.RestoreFH), proto, "RestoreFH") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SaveFH), proto, "SaveFH") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SecInfo), proto, "SecInfo") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.SetAttr), proto, "SetAttr") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Verify), proto, "Verify") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.Write), proto, "Write") + ch <- prometheus.MustNewConstMetric(c.requestsDesc, prometheus.CounterValue, + float64(s.RelLockOwner), proto, "RelLockOwner") +} From 859f2bc882edbc3b847a67ead0e439c5094d25b7 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Tue, 30 Jan 2018 12:46:34 +0100 Subject: [PATCH 11/12] Update reply cache comment. --- collector/fixtures/e2e-output.txt | 2 +- collector/nfsd_linux.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 8cf38909d3..16958e1953 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2598,7 +2598,7 @@ node_nfsd_read_ahead_cache_not_found_total 0 # HELP node_nfsd_read_ahead_cache_size_blocks NFSd how large the read ahead cache in blocks # TYPE node_nfsd_read_ahead_cache_size_blocks gauge node_nfsd_read_ahead_cache_size_blocks 32 -# HELP node_nfsd_reply_cache_hits_total NFSd Reply Cache client did not receive a reply and decided to re-transmit its request and the reply was cached. (bad). +# HELP node_nfsd_reply_cache_hits_total Total number of NFSd Reply Cache hits (client lost server response). # TYPE node_nfsd_reply_cache_hits_total counter node_nfsd_reply_cache_hits_total 0 # HELP node_nfsd_reply_cache_misses_total NFSd Reply Cache an operation that requires caching (idempotent). diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 0fd1fc85d1..0dbff541f0 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -79,7 +79,7 @@ func (c *nfsdCollector) updateNFSdReplyCacheStats(ch chan<- prometheus.Metric, s ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "reply_cache_hits_total"), - "NFSd Reply Cache client did not receive a reply and decided to re-transmit its request and the reply was cached. (bad).", + "Total number of NFSd Reply Cache hits (client lost server response).", nil, nil, ), From 6a0884438e6d06f53529510d4418bd2f7884a63e Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Fri, 9 Feb 2018 11:45:50 +0100 Subject: [PATCH 12/12] Update help text. --- collector/fixtures/e2e-output.txt | 26 +++++++++++++------------- collector/nfsd_linux.go | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 16958e1953..16b33f35ae 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -2576,38 +2576,38 @@ node_nfs_rpc_operations 1.218785755e+09 # HELP node_nfs_rpc_retransmissions Number of RPC transmissions performed. # TYPE node_nfs_rpc_retransmissions counter node_nfs_rpc_retransmissions 374636 -# HELP node_nfsd_connections_total NFSd how many TCP connections have been made +# HELP node_nfsd_connections_total Total number of NFSd TCP connections. # TYPE node_nfsd_connections_total counter node_nfsd_connections_total 1 -# HELP node_nfsd_disk_bytes_read_total NFSd bytes read +# HELP node_nfsd_disk_bytes_read_total Total NFSd bytes read. # TYPE node_nfsd_disk_bytes_read_total counter node_nfsd_disk_bytes_read_total 1.572864e+08 -# HELP node_nfsd_disk_bytes_written_total NFSd bytes written +# HELP node_nfsd_disk_bytes_written_total Total NFSd bytes written. # TYPE node_nfsd_disk_bytes_written_total counter node_nfsd_disk_bytes_written_total 72864 -# HELP node_nfsd_file_handles_stale_total NFSd stale file handles +# HELP node_nfsd_file_handles_stale_total Total number of NFSd stale file handles # TYPE node_nfsd_file_handles_stale_total counter node_nfsd_file_handles_stale_total 0 -# HELP node_nfsd_packets_total NFSd how many network packets have been sent/recieved +# HELP node_nfsd_packets_total Total NFSd network packets (sent+recieved) by protocol type. # TYPE node_nfsd_packets_total counter node_nfsd_packets_total{proto="tcp"} 917 node_nfsd_packets_total{proto="udp"} 55 -# HELP node_nfsd_read_ahead_cache_not_found_total NFSd how large the read ahead cache in blocks +# HELP node_nfsd_read_ahead_cache_not_found_total Total number of NFSd read ahead cache not found. # TYPE node_nfsd_read_ahead_cache_not_found_total counter node_nfsd_read_ahead_cache_not_found_total 0 -# HELP node_nfsd_read_ahead_cache_size_blocks NFSd how large the read ahead cache in blocks +# HELP node_nfsd_read_ahead_cache_size_blocks How large the read ahead cache is in blocks. # TYPE node_nfsd_read_ahead_cache_size_blocks gauge node_nfsd_read_ahead_cache_size_blocks 32 # HELP node_nfsd_reply_cache_hits_total Total number of NFSd Reply Cache hits (client lost server response). # TYPE node_nfsd_reply_cache_hits_total counter node_nfsd_reply_cache_hits_total 0 -# HELP node_nfsd_reply_cache_misses_total NFSd Reply Cache an operation that requires caching (idempotent). +# HELP node_nfsd_reply_cache_misses_total Total number of NFSd Reply Cache an operation that requires caching (idempotent). # TYPE node_nfsd_reply_cache_misses_total counter node_nfsd_reply_cache_misses_total 6 -# HELP node_nfsd_reply_cache_nocache_total NFSd Reply Cache non-idempotent operations (rename/delete/…). +# HELP node_nfsd_reply_cache_nocache_total Total number of NFSd Reply Cache non-idempotent operations (rename/delete/…). # TYPE node_nfsd_reply_cache_nocache_total counter node_nfsd_reply_cache_nocache_total 18622 -# HELP node_nfsd_requests_total Number NFSd Requests by method and protocol. +# HELP node_nfsd_requests_total Total number NFSd Requests by method and protocol. # TYPE node_nfsd_requests_total counter node_nfsd_requests_total{method="Access",proto="v3"} 111 node_nfsd_requests_total{method="Access",proto="v4"} 1098 @@ -2680,15 +2680,15 @@ node_nfsd_requests_total{method="WrCache",proto="v2"} 0 node_nfsd_requests_total{method="Write",proto="v2"} 0 node_nfsd_requests_total{method="Write",proto="v3"} 0 node_nfsd_requests_total{method="Write",proto="v4"} 3 -# HELP node_nfsd_rpc_errors_total NFSd RPC errors +# HELP node_nfsd_rpc_errors_total Total number of NFSd RPC errors by error type. # TYPE node_nfsd_rpc_errors_total counter node_nfsd_rpc_errors_total{error="auth"} 2 node_nfsd_rpc_errors_total{error="cInt"} 0 node_nfsd_rpc_errors_total{error="fmt"} 1 -# HELP node_nfsd_server_rpcs_total NFSd how many RPCs +# HELP node_nfsd_server_rpcs_total Total number of NFSd RPCs. # TYPE node_nfsd_server_rpcs_total gauge node_nfsd_server_rpcs_total 18628 -# HELP node_nfsd_server_threads NFSd how many kernel threads are running +# HELP node_nfsd_server_threads Total number of NFSd kernel threads that are running. # TYPE node_nfsd_server_threads gauge node_nfsd_server_threads 8 # HELP node_procs_blocked Number of processes blocked waiting for I/O to complete. diff --git a/collector/nfsd_linux.go b/collector/nfsd_linux.go index 0dbff541f0..1de614afbe 100644 --- a/collector/nfsd_linux.go +++ b/collector/nfsd_linux.go @@ -47,7 +47,7 @@ func NewNFSdCollector() (Collector, error) { fs: fs, requestsDesc: prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "requests_total"), - "Number NFSd Requests by method and protocol.", + "Total number NFSd Requests by method and protocol.", []string{"proto", "method"}, nil, ), }, nil @@ -88,7 +88,7 @@ func (c *nfsdCollector) updateNFSdReplyCacheStats(ch chan<- prometheus.Metric, s ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "reply_cache_misses_total"), - "NFSd Reply Cache an operation that requires caching (idempotent).", + "Total number of NFSd Reply Cache an operation that requires caching (idempotent).", nil, nil, ), @@ -97,7 +97,7 @@ func (c *nfsdCollector) updateNFSdReplyCacheStats(ch chan<- prometheus.Metric, s ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "reply_cache_nocache_total"), - "NFSd Reply Cache non-idempotent operations (rename/delete/…).", + "Total number of NFSd Reply Cache non-idempotent operations (rename/delete/…).", nil, nil, ), @@ -110,7 +110,7 @@ func (c *nfsdCollector) updateNFSdFileHandlesStats(ch chan<- prometheus.Metric, ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "file_handles_stale_total"), - "NFSd stale file handles", + "Total number of NFSd stale file handles", nil, nil, ), @@ -124,7 +124,7 @@ func (c *nfsdCollector) updateNFSdInputOutputStats(ch chan<- prometheus.Metric, ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "disk_bytes_read_total"), - "NFSd bytes read", + "Total NFSd bytes read.", nil, nil, ), @@ -133,7 +133,7 @@ func (c *nfsdCollector) updateNFSdInputOutputStats(ch chan<- prometheus.Metric, ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "disk_bytes_written_total"), - "NFSd bytes written", + "Total NFSd bytes written.", nil, nil, ), @@ -146,7 +146,7 @@ func (c *nfsdCollector) updateNFSdThreadsStats(ch chan<- prometheus.Metric, s *n ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "server_threads"), - "NFSd how many kernel threads are running", + "Total number of NFSd kernel threads that are running.", nil, nil, ), @@ -159,7 +159,7 @@ func (c *nfsdCollector) updateNFSdReadAheadCacheStats(ch chan<- prometheus.Metri ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "read_ahead_cache_size_blocks"), - "NFSd how large the read ahead cache in blocks", + "How large the read ahead cache is in blocks.", nil, nil, ), @@ -168,7 +168,7 @@ func (c *nfsdCollector) updateNFSdReadAheadCacheStats(ch chan<- prometheus.Metri ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "read_ahead_cache_not_found_total"), - "NFSd how large the read ahead cache in blocks", + "Total number of NFSd read ahead cache not found.", nil, nil, ), @@ -180,7 +180,7 @@ func (c *nfsdCollector) updateNFSdReadAheadCacheStats(ch chan<- prometheus.Metri func (c *nfsdCollector) updateNFSdNetworkStats(ch chan<- prometheus.Metric, s *nfs.Network) { packetDesc := prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "packets_total"), - "NFSd how many network packets have been sent/recieved", + "Total NFSd network packets (sent+recieved) by protocol type.", []string{"proto"}, nil, ) @@ -195,7 +195,7 @@ func (c *nfsdCollector) updateNFSdNetworkStats(ch chan<- prometheus.Metric, s *n ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "connections_total"), - "NFSd how many TCP connections have been made", + "Total number of NFSd TCP connections.", nil, nil, ), @@ -207,7 +207,7 @@ func (c *nfsdCollector) updateNFSdNetworkStats(ch chan<- prometheus.Metric, s *n func (c *nfsdCollector) updateNFSdServerRPCStats(ch chan<- prometheus.Metric, s *nfs.ServerRPC) { badRPCDesc := prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "rpc_errors_total"), - "NFSd RPC errors", + "Total number of NFSd RPC errors by error type.", []string{"error"}, nil, ) @@ -226,7 +226,7 @@ func (c *nfsdCollector) updateNFSdServerRPCStats(ch chan<- prometheus.Metric, s ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( prometheus.BuildFQName(namespace, nfsdSubsystem, "server_rpcs_total"), - "NFSd how many RPCs", + "Total number of NFSd RPCs.", nil, nil, ),