aboutsummaryrefslogtreecommitdiff
path: root/collector/nfs_linux.go
diff options
context:
space:
mode:
authorBen Kochie <superq@gmail.com>2018-02-21 07:25:41 +0100
committerGitHub <noreply@github.com>2018-02-21 07:25:41 +0100
commite0d54a509cd60a7cb3c226edd771f9d9f63a8127 (patch)
tree16c19de3ec0c43257908c5718ed4d22bf9f4c65b /collector/nfs_linux.go
parent6fc06e82888ef2afd8ae6570d93d8a56d3898db9 (diff)
downloadprometheus_node_collector-e0d54a509cd60a7cb3c226edd771f9d9f63a8127.tar.bz2
prometheus_node_collector-e0d54a509cd60a7cb3c226edd771f9d9f63a8127.tar.xz
prometheus_node_collector-e0d54a509cd60a7cb3c226edd771f9d9f63a8127.zip
Cleanup NFS metrics (#834)
* Cleanup NFS metrics * Update `nfs` metric names to match `nfsd`. * Remove uneeded `tcp` label from TCP connections metric. * Remove uneeded `v` on `nfsd` metrics. * Enable all `nfs` v4 client metrics. * Remove `nfs` metric name overrides. * Add ppc64le fixture. * Fix typo.
Diffstat (limited to 'collector/nfs_linux.go')
-rw-r--r--collector/nfs_linux.go71
1 files changed, 13 insertions, 58 deletions
diff --git a/collector/nfs_linux.go b/collector/nfs_linux.go
index 9f6cf29..074a8c2 100644
--- a/collector/nfs_linux.go
+++ b/collector/nfs_linux.go
@@ -17,7 +17,6 @@ import (
17 "fmt" 17 "fmt"
18 "os" 18 "os"
19 "reflect" 19 "reflect"
20 "strings"
21 20
22 "github.com/prometheus/client_golang/prometheus" 21 "github.com/prometheus/client_golang/prometheus"
23 "github.com/prometheus/common/log" 22 "github.com/prometheus/common/log"
@@ -53,20 +52,20 @@ func NewNfsCollector() (Collector, error) {
53 return &nfsCollector{ 52 return &nfsCollector{
54 fs: fs, 53 fs: fs,
55 nfsNetReadsDesc: prometheus.NewDesc( 54 nfsNetReadsDesc: prometheus.NewDesc(
56 prometheus.BuildFQName(namespace, nfsSubsystem, "net_reads_total"), 55 prometheus.BuildFQName(namespace, nfsSubsystem, "packets_total"),
57 "Number of reads at the network layer.", 56 "Total NFSd network packets (sent+received) by protocol type.",
58 []string{"protocol"}, 57 []string{"protocol"},
59 nil, 58 nil,
60 ), 59 ),
61 nfsNetConnectionsDesc: prometheus.NewDesc( 60 nfsNetConnectionsDesc: prometheus.NewDesc(
62 prometheus.BuildFQName(namespace, nfsSubsystem, "net_connections_total"), 61 prometheus.BuildFQName(namespace, nfsSubsystem, "connections_total"),
63 "Number of connections at the network layer.", 62 "Total number of NFSd TCP connections.",
64 []string{"protocol"}, 63 nil,
65 nil, 64 nil,
66 ), 65 ),
67 nfsRPCOperationsDesc: prometheus.NewDesc( 66 nfsRPCOperationsDesc: prometheus.NewDesc(
68 prometheus.BuildFQName(namespace, nfsSubsystem, "rpc_operations_total"), 67 prometheus.BuildFQName(namespace, nfsSubsystem, "rpcs_total"),
69 "Number of RPCs performed.", 68 "Total number of RPCs performed.",
70 nil, 69 nil,
71 nil, 70 nil,
72 ), 71 ),
@@ -83,9 +82,9 @@ func NewNfsCollector() (Collector, error) {
83 nil, 82 nil,
84 ), 83 ),
85 nfsProceduresDesc: prometheus.NewDesc( 84 nfsProceduresDesc: prometheus.NewDesc(
86 prometheus.BuildFQName(namespace, "nfs", "procedures_total"), 85 prometheus.BuildFQName(namespace, nfsSubsystem, "requests_total"),
87 "Number of NFS procedures invoked.", 86 "Number of NFS procedures invoked.",
88 []string{"version", "procedure"}, 87 []string{"proto", "method"},
89 nil, 88 nil,
90 ), 89 ),
91 }, nil 90 }, nil
@@ -117,7 +116,7 @@ func (c *nfsCollector) updateNFSNetworkStats(ch chan<- prometheus.Metric, s *nfs
117 ch <- prometheus.MustNewConstMetric(c.nfsNetReadsDesc, prometheus.CounterValue, 116 ch <- prometheus.MustNewConstMetric(c.nfsNetReadsDesc, prometheus.CounterValue,
118 float64(s.TCPCount), "tcp") 117 float64(s.TCPCount), "tcp")
119 ch <- prometheus.MustNewConstMetric(c.nfsNetConnectionsDesc, prometheus.CounterValue, 118 ch <- prometheus.MustNewConstMetric(c.nfsNetConnectionsDesc, prometheus.CounterValue,
120 float64(s.TCPConnect), "tcp") 119 float64(s.TCPConnect))
121} 120}
122 121
123// updateNFSClientRPCStats collects statistics for kernel server RPCs. 122// updateNFSClientRPCStats collects statistics for kernel server RPCs.
@@ -137,17 +136,9 @@ func (c *nfsCollector) updateNFSRequestsv2Stats(ch chan<- prometheus.Metric, s *
137 v := reflect.ValueOf(s).Elem() 136 v := reflect.ValueOf(s).Elem()
138 for i := 0; i < v.NumField(); i++ { 137 for i := 0; i < v.NumField(); i++ {
139 field := v.Field(i) 138 field := v.Field(i)
140 name := strings.ToLower(v.Type().Field(i).Name)
141
142 switch name {
143 case "wrcache":
144 name = "writecache"
145 case "fsstat":
146 name = "statfs"
147 }
148 139
149 ch <- prometheus.MustNewConstMetric(c.nfsProceduresDesc, prometheus.CounterValue, 140 ch <- prometheus.MustNewConstMetric(c.nfsProceduresDesc, prometheus.CounterValue,
150 float64(field.Uint()), proto, name) 141 float64(field.Uint()), proto, v.Type().Field(i).Name)
151 } 142 }
152} 143}
153 144
@@ -158,10 +149,9 @@ func (c *nfsCollector) updateNFSRequestsv3Stats(ch chan<- prometheus.Metric, s *
158 v := reflect.ValueOf(s).Elem() 149 v := reflect.ValueOf(s).Elem()
159 for i := 0; i < v.NumField(); i++ { 150 for i := 0; i < v.NumField(); i++ {
160 field := v.Field(i) 151 field := v.Field(i)
161 name := strings.ToLower(v.Type().Field(i).Name)
162 152
163 ch <- prometheus.MustNewConstMetric(c.nfsProceduresDesc, prometheus.CounterValue, 153 ch <- prometheus.MustNewConstMetric(c.nfsProceduresDesc, prometheus.CounterValue,
164 float64(field.Uint()), proto, name) 154 float64(field.Uint()), proto, v.Type().Field(i).Name)
165 } 155 }
166} 156}
167 157
@@ -172,43 +162,8 @@ func (c *nfsCollector) updateNFSRequestsv4Stats(ch chan<- prometheus.Metric, s *
172 v := reflect.ValueOf(s).Elem() 162 v := reflect.ValueOf(s).Elem()
173 for i := 0; i < v.NumField(); i++ { 163 for i := 0; i < v.NumField(); i++ {
174 field := v.Field(i) 164 field := v.Field(i)
175 name := strings.ToLower(v.Type().Field(i).Name)
176
177 switch name {
178 case "openconfirm":
179 name = "open_confirm"
180 case "opendowngrade":
181 name = "open_downgrade"
182 case "opennoattr":
183 name = "open_noattr"
184 case "setclientidconfirm":
185 name = "setclientid_confirm"
186 case "lookuproot":
187 name = "lookup_root"
188 case "servercaps":
189 name = "server_caps"
190 case "fslocations":
191 name = "fs_locations"
192 case "releaselockowner":
193 name = "release_lockowner"
194 case "fsidpresent":
195 name = "fsid_present"
196 case "exchangeid":
197 name = "exchange_id"
198 case "createsession":
199 name = "create_session"
200 case "destroysession":
201 name = "destroy_session"
202 case "getleasetime":
203 name = "get_lease_time"
204 case "reclaimcomplete":
205 name = "reclaim_complete"
206 // TODO: Enable these metrics
207 case "secinfononame", "teststateid", "freestateid", "getdevicelist", "bindconntosession", "destroyclientid", "seek", "allocate", "deallocate", "layoutstats", "clone":
208 continue
209 }
210 165
211 ch <- prometheus.MustNewConstMetric(c.nfsProceduresDesc, prometheus.CounterValue, 166 ch <- prometheus.MustNewConstMetric(c.nfsProceduresDesc, prometheus.CounterValue,
212 float64(field.Uint()), proto, name) 167 float64(field.Uint()), proto, v.Type().Field(i).Name)
213 } 168 }
214} 169}