aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--collector/fixtures/e2e-output.txt102
-rw-r--r--collector/fixtures/proc/10/mountstats19
l---------collector/fixtures/proc/self1
-rw-r--r--collector/mountstats_linux.go499
-rwxr-xr-xend-to-end-test.sh1
6 files changed, 623 insertions, 0 deletions
diff --git a/README.md b/README.md
index 507851c..c51544d 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ ksmd | Exposes kernel and system statistics from `/sys/kernel/mm/ksm`. | Linux
49logind | Exposes session counts from [logind](http://www.freedesktop.org/wiki/Software/systemd/logind/). | Linux 49logind | Exposes session counts from [logind](http://www.freedesktop.org/wiki/Software/systemd/logind/). | Linux
50megacli | Exposes RAID statistics from MegaCLI. | Linux 50megacli | Exposes RAID statistics from MegaCLI. | Linux
51meminfo_numa | Exposes memory statistics from `/proc/meminfo_numa`. | Linux 51meminfo_numa | Exposes memory statistics from `/proc/meminfo_numa`. | Linux
52mountstats | Exposes filesystem statistics from `/proc/self/mountstats`. Exposes detailed NFS client statistics. | Linux
52nfs | Exposes NFS client statistics from `/proc/net/rpc/nfs`. This is the same information as `nfsstat -c`. | Linux 53nfs | Exposes NFS client statistics from `/proc/net/rpc/nfs`. This is the same information as `nfsstat -c`. | Linux
53ntp | Exposes time drift from an NTP server. | _any_ 54ntp | Exposes time drift from an NTP server. | _any_
54runit | Exposes service status from [runit](http://smarden.org/runit/). | _any_ 55runit | Exposes service status from [runit](http://smarden.org/runit/). | _any_
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt
index baf8f97..c2c8560 100644
--- a/collector/fixtures/e2e-output.txt
+++ b/collector/fixtures/e2e-output.txt
@@ -443,6 +443,11 @@ node_exporter_scrape_duration_seconds{collector="meminfo_numa",result="success",
443node_exporter_scrape_duration_seconds{collector="meminfo_numa",result="success",quantile="0.99"} 0.0017954980000000002 443node_exporter_scrape_duration_seconds{collector="meminfo_numa",result="success",quantile="0.99"} 0.0017954980000000002
444node_exporter_scrape_duration_seconds_sum{collector="meminfo_numa",result="success"} 0.0017954980000000002 444node_exporter_scrape_duration_seconds_sum{collector="meminfo_numa",result="success"} 0.0017954980000000002
445node_exporter_scrape_duration_seconds_count{collector="meminfo_numa",result="success"} 1 445node_exporter_scrape_duration_seconds_count{collector="meminfo_numa",result="success"} 1
446node_exporter_scrape_duration_seconds{collector="mountstats",result="success",quantile="0.5"} 0.000512374
447node_exporter_scrape_duration_seconds{collector="mountstats",result="success",quantile="0.9"} 0.000512374
448node_exporter_scrape_duration_seconds{collector="mountstats",result="success",quantile="0.99"} 0.000512374
449node_exporter_scrape_duration_seconds_sum{collector="mountstats",result="success"} 0.000512374
450node_exporter_scrape_duration_seconds_count{collector="mountstats",result="success"} 1
446node_exporter_scrape_duration_seconds{collector="netdev",result="success",quantile="0.5"} 0.000495389 451node_exporter_scrape_duration_seconds{collector="netdev",result="success",quantile="0.5"} 0.000495389
447node_exporter_scrape_duration_seconds{collector="netdev",result="success",quantile="0.9"} 0.000495389 452node_exporter_scrape_duration_seconds{collector="netdev",result="success",quantile="0.9"} 0.000495389
448node_exporter_scrape_duration_seconds{collector="netdev",result="success",quantile="0.99"} 0.000495389 453node_exporter_scrape_duration_seconds{collector="netdev",result="success",quantile="0.99"} 0.000495389
@@ -1070,6 +1075,103 @@ node_memory_numa_numa_miss_total{node="1"} 5.9858626709e+10
1070# TYPE node_memory_numa_other_node_total counter 1075# TYPE node_memory_numa_other_node_total counter
1071node_memory_numa_other_node_total{node="0"} 1.8179487e+07 1076node_memory_numa_other_node_total{node="0"} 1.8179487e+07
1072node_memory_numa_other_node_total{node="1"} 5.986052692e+10 1077node_memory_numa_other_node_total{node="1"} 5.986052692e+10
1078# HELP node_mountstats_nfs_age_seconds_total The age of the NFS mount in seconds.
1079# TYPE node_mountstats_nfs_age_seconds_total counter
1080node_mountstats_nfs_age_seconds_total{export="192.168.1.1:/srv/test"} 13968
1081# HELP node_mountstats_nfs_direct_read_bytes_total Number of bytes read using the read() syscall in O_DIRECT mode.
1082# TYPE node_mountstats_nfs_direct_read_bytes_total counter
1083node_mountstats_nfs_direct_read_bytes_total{export="192.168.1.1:/srv/test"} 0
1084# HELP node_mountstats_nfs_direct_write_bytes_total Number of bytes written using the write() syscall in O_DIRECT mode.
1085# TYPE node_mountstats_nfs_direct_write_bytes_total counter
1086node_mountstats_nfs_direct_write_bytes_total{export="192.168.1.1:/srv/test"} 0
1087# HELP node_mountstats_nfs_operations_major_timeouts_total Number of times a request has had a major timeout for a given operation.
1088# TYPE node_mountstats_nfs_operations_major_timeouts_total counter
1089node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1090node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="READ"} 0
1091node_mountstats_nfs_operations_major_timeouts_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1092# HELP node_mountstats_nfs_operations_queue_time_seconds_total Duration all requests spent queued for transmission for a given operation before they were sent, in seconds.
1093# TYPE node_mountstats_nfs_operations_queue_time_seconds_total counter
1094node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1095node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ"} 0.006
1096node_mountstats_nfs_operations_queue_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1097# HELP node_mountstats_nfs_operations_received_bytes_total Number of bytes received for a given operation, including RPC headers and payload.
1098# TYPE node_mountstats_nfs_operations_received_bytes_total counter
1099node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1100node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="READ"} 1.210292152e+09
1101node_mountstats_nfs_operations_received_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1102# HELP node_mountstats_nfs_operations_request_time_seconds_total Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds.
1103# TYPE node_mountstats_nfs_operations_request_time_seconds_total counter
1104node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1105node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ"} 79.407
1106node_mountstats_nfs_operations_request_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1107# HELP node_mountstats_nfs_operations_requests_total Number of requests performed for a given operation.
1108# TYPE node_mountstats_nfs_operations_requests_total counter
1109node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1110node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="READ"} 1298
1111node_mountstats_nfs_operations_requests_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1112# HELP node_mountstats_nfs_operations_response_time_seconds_total Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds.
1113# TYPE node_mountstats_nfs_operations_response_time_seconds_total counter
1114node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1115node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="READ"} 79.386
1116node_mountstats_nfs_operations_response_time_seconds_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1117# HELP node_mountstats_nfs_operations_sent_bytes_total Number of bytes sent for a given operation, including RPC headers and payload.
1118# TYPE node_mountstats_nfs_operations_sent_bytes_total counter
1119node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1120node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="READ"} 207680
1121node_mountstats_nfs_operations_sent_bytes_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1122# HELP node_mountstats_nfs_operations_transmissions_total Number of times an actual RPC request has been transmitted for a given operation.
1123# TYPE node_mountstats_nfs_operations_transmissions_total counter
1124node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="NULL"} 0
1125node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="READ"} 1298
1126node_mountstats_nfs_operations_transmissions_total{export="192.168.1.1:/srv/test",operation="WRITE"} 0
1127# HELP node_mountstats_nfs_read_bytes_total Number of bytes read using the read() syscall.
1128# TYPE node_mountstats_nfs_read_bytes_total counter
1129node_mountstats_nfs_read_bytes_total{export="192.168.1.1:/srv/test"} 1.20764023e+09
1130# HELP node_mountstats_nfs_read_pages_total Number of pages read directly via mmap()'d files.
1131# TYPE node_mountstats_nfs_read_pages_total counter
1132node_mountstats_nfs_read_pages_total{export="192.168.1.1:/srv/test"} 295483
1133# HELP node_mountstats_nfs_total_read_bytes_total Number of bytes read from the NFS server, in total.
1134# TYPE node_mountstats_nfs_total_read_bytes_total counter
1135node_mountstats_nfs_total_read_bytes_total{export="192.168.1.1:/srv/test"} 1.210214218e+09
1136# HELP node_mountstats_nfs_total_write_bytes_total Number of bytes written to the NFS server, in total.
1137# TYPE node_mountstats_nfs_total_write_bytes_total counter
1138node_mountstats_nfs_total_write_bytes_total{export="192.168.1.1:/srv/test"} 0
1139# HELP node_mountstats_nfs_transport_backlog_queue_total Total number of items added to the RPC backlog queue.
1140# TYPE node_mountstats_nfs_transport_backlog_queue_total counter
1141node_mountstats_nfs_transport_backlog_queue_total{export="192.168.1.1:/srv/test"} 0
1142# HELP node_mountstats_nfs_transport_bad_transaction_ids_total Number of times the NFS server sent a response with a transaction ID unknown to this client.
1143# TYPE node_mountstats_nfs_transport_bad_transaction_ids_total counter
1144node_mountstats_nfs_transport_bad_transaction_ids_total{export="192.168.1.1:/srv/test"} 0
1145# HELP node_mountstats_nfs_transport_bind_total Number of times the client has had to establish a connection from scratch to the NFS server.
1146# TYPE node_mountstats_nfs_transport_bind_total counter
1147node_mountstats_nfs_transport_bind_total{export="192.168.1.1:/srv/test"} 0
1148# HELP node_mountstats_nfs_transport_connect_total Number of times the client has made a TCP connection to the NFS server.
1149# TYPE node_mountstats_nfs_transport_connect_total counter
1150node_mountstats_nfs_transport_connect_total{export="192.168.1.1:/srv/test"} 1
1151# HELP node_mountstats_nfs_transport_idle_time_seconds Duration since the NFS mount last saw any RPC traffic, in seconds.
1152# TYPE node_mountstats_nfs_transport_idle_time_seconds gauge
1153node_mountstats_nfs_transport_idle_time_seconds{export="192.168.1.1:/srv/test"} 11
1154# HELP node_mountstats_nfs_transport_maximum_rpc_slots Maximum number of simultaneously active RPC requests ever used.
1155# TYPE node_mountstats_nfs_transport_maximum_rpc_slots gauge
1156node_mountstats_nfs_transport_maximum_rpc_slots{export="192.168.1.1:/srv/test"} 24
1157# HELP node_mountstats_nfs_transport_pending_queue_total Total number of items added to the RPC transmission pending queue.
1158# TYPE node_mountstats_nfs_transport_pending_queue_total counter
1159node_mountstats_nfs_transport_pending_queue_total{export="192.168.1.1:/srv/test"} 5726
1160# HELP node_mountstats_nfs_transport_receives_total Number of RPC responses for this mount received from the NFS server.
1161# TYPE node_mountstats_nfs_transport_receives_total counter
1162node_mountstats_nfs_transport_receives_total{export="192.168.1.1:/srv/test"} 6428
1163# HELP node_mountstats_nfs_transport_sending_queue_total Total number of items added to the RPC transmission sending queue.
1164# TYPE node_mountstats_nfs_transport_sending_queue_total counter
1165node_mountstats_nfs_transport_sending_queue_total{export="192.168.1.1:/srv/test"} 26
1166# HELP node_mountstats_nfs_transport_sends_total Number of RPC requests for this mount sent to the NFS server.
1167# TYPE node_mountstats_nfs_transport_sends_total counter
1168node_mountstats_nfs_transport_sends_total{export="192.168.1.1:/srv/test"} 6428
1169# HELP node_mountstats_nfs_write_bytes_total Number of bytes written using the write() syscall.
1170# TYPE node_mountstats_nfs_write_bytes_total counter
1171node_mountstats_nfs_write_bytes_total{export="192.168.1.1:/srv/test"} 0
1172# HELP node_mountstats_nfs_write_pages_total Number of pages written directly via mmap()'d files.
1173# TYPE node_mountstats_nfs_write_pages_total counter
1174node_mountstats_nfs_write_pages_total{export="192.168.1.1:/srv/test"} 0
1073# HELP node_net_bonding_slaves Number of configured slaves per bonding interface. 1175# HELP node_net_bonding_slaves Number of configured slaves per bonding interface.
1074# TYPE node_net_bonding_slaves gauge 1176# TYPE node_net_bonding_slaves gauge
1075node_net_bonding_slaves{master="bond0"} 0 1177node_net_bonding_slaves{master="bond0"} 0
diff --git a/collector/fixtures/proc/10/mountstats b/collector/fixtures/proc/10/mountstats
new file mode 100644
index 0000000..a665c33
--- /dev/null
+++ b/collector/fixtures/proc/10/mountstats
@@ -0,0 +1,19 @@
1device rootfs mounted on / with fstype rootfs
2device sysfs mounted on /sys with fstype sysfs
3device proc mounted on /proc with fstype proc
4device /dev/sda1 mounted on / with fstype ext4
5device 192.168.1.1:/srv/test mounted on /mnt/nfs/test with fstype nfs4 statvers=1.1
6 opts: rw,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=3,acregmax=60,acdirmin=30,acdirmax=60,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.5,local_lock=none
7 age: 13968
8 caps: caps=0xfff7,wtmult=512,dtsize=32768,bsize=0,namlen=255
9 nfsv4: bm0=0xfdffafff,bm1=0xf9be3e,bm2=0x0,acl=0x0,pnfs=not configured
10 sec: flavor=1,pseudoflavor=1
11 events: 52 226 0 0 1 13 398 0 0 331 0 47 0 0 77 0 0 77 0 0 0 0 0 0 0 0 0
12 bytes: 1207640230 0 0 0 1210214218 0 295483 0
13 RPC iostats version: 1.0 p/v: 100003/4 (nfs)
14 xprt: tcp 832 0 1 0 11 6428 6428 0 12154 0 24 26 5726
15 per-op statistics
16 NULL: 0 0 0 0 0 0 0 0
17 READ: 1298 1298 0 207680 1210292152 6 79386 79407
18 WRITE: 0 0 0 0 0 0 0 0
19
diff --git a/collector/fixtures/proc/self b/collector/fixtures/proc/self
new file mode 120000
index 0000000..9a03714
--- /dev/null
+++ b/collector/fixtures/proc/self
@@ -0,0 +1 @@
10 \ No newline at end of file
diff --git a/collector/mountstats_linux.go b/collector/mountstats_linux.go
new file mode 100644
index 0000000..e9360e8
--- /dev/null
+++ b/collector/mountstats_linux.go
@@ -0,0 +1,499 @@
1// Copyright 2016 The Prometheus Authors
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14package collector
15
16import (
17 "fmt"
18
19 "github.com/prometheus/client_golang/prometheus"
20 "github.com/prometheus/procfs"
21)
22
23type mountStatsCollector struct {
24 // General statistics
25 NFSAgeSecondsTotal *prometheus.Desc
26
27 // Byte statistics
28 NFSReadBytesTotal *prometheus.Desc
29 NFSWriteBytesTotal *prometheus.Desc
30 NFSDirectReadBytesTotal *prometheus.Desc
31 NFSDirectWriteBytesTotal *prometheus.Desc
32 NFSTotalReadBytesTotal *prometheus.Desc
33 NFSTotalWriteBytesTotal *prometheus.Desc
34 NFSReadPagesTotal *prometheus.Desc
35 NFSWritePagesTotal *prometheus.Desc
36
37 // Per-operation statistics
38 NFSOperationsRequestsTotal *prometheus.Desc
39 NFSOperationsTransmissionsTotal *prometheus.Desc
40 NFSOperationsMajorTimeoutsTotal *prometheus.Desc
41 NFSOperationsSentBytesTotal *prometheus.Desc
42 NFSOperationsReceivedBytesTotal *prometheus.Desc
43 NFSOperationsQueueTimeSecondsTotal *prometheus.Desc
44 NFSOperationsResponseTimeSecondsTotal *prometheus.Desc
45 NFSOperationsRequestTimeSecondsTotal *prometheus.Desc
46
47 // Transport statistics
48 NFSTransportBindTotal *prometheus.Desc
49 NFSTransportConnectTotal *prometheus.Desc
50 NFSTransportIdleTimeSeconds *prometheus.Desc
51 NFSTransportSendsTotal *prometheus.Desc
52 NFSTransportReceivesTotal *prometheus.Desc
53 NFSTransportBadTransactionIDsTotal *prometheus.Desc
54 NFSTransportBacklogQueueTotal *prometheus.Desc
55 NFSTransportMaximumRPCSlots *prometheus.Desc
56 NFSTransportSendingQueueTotal *prometheus.Desc
57 NFSTransportPendingQueueTotal *prometheus.Desc
58
59 proc procfs.Proc
60}
61
62func init() {
63 Factories["mountstats"] = NewMountStatsCollector
64}
65
66func NewMountStatsCollector() (Collector, error) {
67 fs, err := procfs.NewFS(*procPath)
68 if err != nil {
69 return nil, fmt.Errorf("failed to open procfs: %v", err)
70 }
71
72 proc, err := fs.Self()
73 if err != nil {
74 return nil, fmt.Errorf("failed to open /proc/self: %v", err)
75 }
76
77 const (
78 // For the time being, only NFS statistics are available via this mechanism
79 subsystem = "mountstats_nfs"
80 )
81
82 var (
83 labels = []string{"export"}
84 opLabels = []string{"export", "operation"}
85 )
86
87 return &mountStatsCollector{
88 NFSAgeSecondsTotal: prometheus.NewDesc(
89 prometheus.BuildFQName(Namespace, subsystem, "age_seconds_total"),
90 "The age of the NFS mount in seconds.",
91 labels,
92 nil,
93 ),
94
95 NFSReadBytesTotal: prometheus.NewDesc(
96 prometheus.BuildFQName(Namespace, subsystem, "read_bytes_total"),
97 "Number of bytes read using the read() syscall.",
98 labels,
99 nil,
100 ),
101
102 NFSWriteBytesTotal: prometheus.NewDesc(
103 prometheus.BuildFQName(Namespace, subsystem, "write_bytes_total"),
104 "Number of bytes written using the write() syscall.",
105 labels,
106 nil,
107 ),
108
109 NFSDirectReadBytesTotal: prometheus.NewDesc(
110 prometheus.BuildFQName(Namespace, subsystem, "direct_read_bytes_total"),
111 "Number of bytes read using the read() syscall in O_DIRECT mode.",
112 labels,
113 nil,
114 ),
115
116 NFSDirectWriteBytesTotal: prometheus.NewDesc(
117 prometheus.BuildFQName(Namespace, subsystem, "direct_write_bytes_total"),
118 "Number of bytes written using the write() syscall in O_DIRECT mode.",
119 labels,
120 nil,
121 ),
122
123 NFSTotalReadBytesTotal: prometheus.NewDesc(
124 prometheus.BuildFQName(Namespace, subsystem, "total_read_bytes_total"),
125 "Number of bytes read from the NFS server, in total.",
126 labels,
127 nil,
128 ),
129
130 NFSTotalWriteBytesTotal: prometheus.NewDesc(
131 prometheus.BuildFQName(Namespace, subsystem, "total_write_bytes_total"),
132 "Number of bytes written to the NFS server, in total.",
133 labels,
134 nil,
135 ),
136
137 NFSReadPagesTotal: prometheus.NewDesc(
138 prometheus.BuildFQName(Namespace, subsystem, "read_pages_total"),
139 "Number of pages read directly via mmap()'d files.",
140 labels,
141 nil,
142 ),
143
144 NFSWritePagesTotal: prometheus.NewDesc(
145 prometheus.BuildFQName(Namespace, subsystem, "write_pages_total"),
146 "Number of pages written directly via mmap()'d files.",
147 labels,
148 nil,
149 ),
150
151 NFSTransportBindTotal: prometheus.NewDesc(
152 prometheus.BuildFQName(Namespace, subsystem, "transport_bind_total"),
153 "Number of times the client has had to establish a connection from scratch to the NFS server.",
154 labels,
155 nil,
156 ),
157
158 NFSTransportConnectTotal: prometheus.NewDesc(
159 prometheus.BuildFQName(Namespace, subsystem, "transport_connect_total"),
160 "Number of times the client has made a TCP connection to the NFS server.",
161 labels,
162 nil,
163 ),
164
165 NFSTransportIdleTimeSeconds: prometheus.NewDesc(
166 prometheus.BuildFQName(Namespace, subsystem, "transport_idle_time_seconds"),
167 "Duration since the NFS mount last saw any RPC traffic, in seconds.",
168 labels,
169 nil,
170 ),
171
172 NFSTransportSendsTotal: prometheus.NewDesc(
173 prometheus.BuildFQName(Namespace, subsystem, "transport_sends_total"),
174 "Number of RPC requests for this mount sent to the NFS server.",
175 labels,
176 nil,
177 ),
178
179 NFSTransportReceivesTotal: prometheus.NewDesc(
180 prometheus.BuildFQName(Namespace, subsystem, "transport_receives_total"),
181 "Number of RPC responses for this mount received from the NFS server.",
182 labels,
183 nil,
184 ),
185
186 NFSTransportBadTransactionIDsTotal: prometheus.NewDesc(
187 prometheus.BuildFQName(Namespace, subsystem, "transport_bad_transaction_ids_total"),
188 "Number of times the NFS server sent a response with a transaction ID unknown to this client.",
189 labels,
190 nil,
191 ),
192
193 NFSTransportBacklogQueueTotal: prometheus.NewDesc(
194 prometheus.BuildFQName(Namespace, subsystem, "transport_backlog_queue_total"),
195 "Total number of items added to the RPC backlog queue.",
196 labels,
197 nil,
198 ),
199
200 NFSTransportMaximumRPCSlots: prometheus.NewDesc(
201 prometheus.BuildFQName(Namespace, subsystem, "transport_maximum_rpc_slots"),
202 "Maximum number of simultaneously active RPC requests ever used.",
203 labels,
204 nil,
205 ),
206
207 NFSTransportSendingQueueTotal: prometheus.NewDesc(
208 prometheus.BuildFQName(Namespace, subsystem, "transport_sending_queue_total"),
209 "Total number of items added to the RPC transmission sending queue.",
210 labels,
211 nil,
212 ),
213
214 NFSTransportPendingQueueTotal: prometheus.NewDesc(
215 prometheus.BuildFQName(Namespace, subsystem, "transport_pending_queue_total"),
216 "Total number of items added to the RPC transmission pending queue.",
217 labels,
218 nil,
219 ),
220
221 NFSOperationsRequestsTotal: prometheus.NewDesc(
222 prometheus.BuildFQName(Namespace, subsystem, "operations_requests_total"),
223 "Number of requests performed for a given operation.",
224 opLabels,
225 nil,
226 ),
227
228 NFSOperationsTransmissionsTotal: prometheus.NewDesc(
229 prometheus.BuildFQName(Namespace, subsystem, "operations_transmissions_total"),
230 "Number of times an actual RPC request has been transmitted for a given operation.",
231 opLabels,
232 nil,
233 ),
234
235 NFSOperationsMajorTimeoutsTotal: prometheus.NewDesc(
236 prometheus.BuildFQName(Namespace, subsystem, "operations_major_timeouts_total"),
237 "Number of times a request has had a major timeout for a given operation.",
238 opLabels,
239 nil,
240 ),
241
242 NFSOperationsSentBytesTotal: prometheus.NewDesc(
243 prometheus.BuildFQName(Namespace, subsystem, "operations_sent_bytes_total"),
244 "Number of bytes sent for a given operation, including RPC headers and payload.",
245 opLabels,
246 nil,
247 ),
248
249 NFSOperationsReceivedBytesTotal: prometheus.NewDesc(
250 prometheus.BuildFQName(Namespace, subsystem, "operations_received_bytes_total"),
251 "Number of bytes received for a given operation, including RPC headers and payload.",
252 opLabels,
253 nil,
254 ),
255
256 NFSOperationsQueueTimeSecondsTotal: prometheus.NewDesc(
257 prometheus.BuildFQName(Namespace, subsystem, "operations_queue_time_seconds_total"),
258 "Duration all requests spent queued for transmission for a given operation before they were sent, in seconds.",
259 opLabels,
260 nil,
261 ),
262
263 NFSOperationsResponseTimeSecondsTotal: prometheus.NewDesc(
264 prometheus.BuildFQName(Namespace, subsystem, "operations_response_time_seconds_total"),
265 "Duration all requests took to get a reply back after a request for a given operation was transmitted, in seconds.",
266 opLabels,
267 nil,
268 ),
269
270 NFSOperationsRequestTimeSecondsTotal: prometheus.NewDesc(
271 prometheus.BuildFQName(Namespace, subsystem, "operations_request_time_seconds_total"),
272 "Duration all requests took from when a request was enqueued to when it was completely handled for a given operation, in seconds.",
273 opLabels,
274 nil,
275 ),
276
277 proc: proc,
278 }, nil
279}
280
281func (c *mountStatsCollector) Update(ch chan<- prometheus.Metric) error {
282 mounts, err := c.proc.MountStats()
283 if err != nil {
284 return fmt.Errorf("failed to parse mountstats: %v", err)
285 }
286
287 for _, m := range mounts {
288 // For the time being, only NFS statistics are available via this mechanism
289 stats, ok := m.Stats.(*procfs.MountStatsNFS)
290 if !ok {
291 continue
292 }
293
294 c.updateNFSStats(ch, m.Device, stats)
295 }
296
297 return nil
298}
299
300func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export string, s *procfs.MountStatsNFS) {
301 ch <- prometheus.MustNewConstMetric(
302 c.NFSAgeSecondsTotal,
303 prometheus.CounterValue,
304 s.Age.Seconds(),
305 export,
306 )
307
308 ch <- prometheus.MustNewConstMetric(
309 c.NFSReadBytesTotal,
310 prometheus.CounterValue,
311 float64(s.Bytes.Read),
312 export,
313 )
314
315 ch <- prometheus.MustNewConstMetric(
316 c.NFSWriteBytesTotal,
317 prometheus.CounterValue,
318 float64(s.Bytes.Write),
319 export,
320 )
321
322 ch <- prometheus.MustNewConstMetric(
323 c.NFSDirectReadBytesTotal,
324 prometheus.CounterValue,
325 float64(s.Bytes.DirectRead),
326 export,
327 )
328
329 ch <- prometheus.MustNewConstMetric(
330 c.NFSDirectWriteBytesTotal,
331 prometheus.CounterValue,
332 float64(s.Bytes.DirectWrite),
333 export,
334 )
335
336 ch <- prometheus.MustNewConstMetric(
337 c.NFSTotalReadBytesTotal,
338 prometheus.CounterValue,
339 float64(s.Bytes.ReadTotal),
340 export,
341 )
342
343 ch <- prometheus.MustNewConstMetric(
344 c.NFSTotalWriteBytesTotal,
345 prometheus.CounterValue,
346 float64(s.Bytes.WriteTotal),
347 export,
348 )
349
350 ch <- prometheus.MustNewConstMetric(
351 c.NFSReadPagesTotal,
352 prometheus.CounterValue,
353 float64(s.Bytes.ReadPages),
354 export,
355 )
356
357 ch <- prometheus.MustNewConstMetric(
358 c.NFSWritePagesTotal,
359 prometheus.CounterValue,
360 float64(s.Bytes.WritePages),
361 export,
362 )
363
364 ch <- prometheus.MustNewConstMetric(
365 c.NFSTransportBindTotal,
366 prometheus.CounterValue,
367 float64(s.Transport.Bind),
368 export,
369 )
370
371 ch <- prometheus.MustNewConstMetric(
372 c.NFSTransportConnectTotal,
373 prometheus.CounterValue,
374 float64(s.Transport.Connect),
375 export,
376 )
377
378 ch <- prometheus.MustNewConstMetric(
379 c.NFSTransportIdleTimeSeconds,
380 prometheus.GaugeValue,
381 s.Transport.IdleTime.Seconds(),
382 export,
383 )
384
385 ch <- prometheus.MustNewConstMetric(
386 c.NFSTransportSendsTotal,
387 prometheus.CounterValue,
388 float64(s.Transport.Sends),
389 export,
390 )
391
392 ch <- prometheus.MustNewConstMetric(
393 c.NFSTransportReceivesTotal,
394 prometheus.CounterValue,
395 float64(s.Transport.Receives),
396 export,
397 )
398
399 ch <- prometheus.MustNewConstMetric(
400 c.NFSTransportBadTransactionIDsTotal,
401 prometheus.CounterValue,
402 float64(s.Transport.BadTransactionIDs),
403 export,
404 )
405
406 ch <- prometheus.MustNewConstMetric(
407 c.NFSTransportBacklogQueueTotal,
408 prometheus.CounterValue,
409 float64(s.Transport.CumulativeBacklog),
410 export,
411 )
412
413 ch <- prometheus.MustNewConstMetric(
414 c.NFSTransportMaximumRPCSlots,
415 prometheus.GaugeValue,
416 float64(s.Transport.MaximumRPCSlotsUsed),
417 export,
418 )
419
420 ch <- prometheus.MustNewConstMetric(
421 c.NFSTransportSendingQueueTotal,
422 prometheus.CounterValue,
423 float64(s.Transport.CumulativeSendingQueue),
424 export,
425 )
426
427 ch <- prometheus.MustNewConstMetric(
428 c.NFSTransportPendingQueueTotal,
429 prometheus.CounterValue,
430 float64(s.Transport.CumulativePendingQueue),
431 export,
432 )
433
434 for _, op := range s.Operations {
435 ch <- prometheus.MustNewConstMetric(
436 c.NFSOperationsRequestsTotal,
437 prometheus.CounterValue,
438 float64(op.Requests),
439 export,
440 op.Operation,
441 )
442
443 ch <- prometheus.MustNewConstMetric(
444 c.NFSOperationsTransmissionsTotal,
445 prometheus.CounterValue,
446 float64(op.Transmissions),
447 export,
448 op.Operation,
449 )
450
451 ch <- prometheus.MustNewConstMetric(
452 c.NFSOperationsMajorTimeoutsTotal,
453 prometheus.CounterValue,
454 float64(op.MajorTimeouts),
455 export,
456 op.Operation,
457 )
458
459 ch <- prometheus.MustNewConstMetric(
460 c.NFSOperationsSentBytesTotal,
461 prometheus.CounterValue,
462 float64(op.BytesSent),
463 export,
464 op.Operation,
465 )
466
467 ch <- prometheus.MustNewConstMetric(
468 c.NFSOperationsReceivedBytesTotal,
469 prometheus.CounterValue,
470 float64(op.BytesReceived),
471 export,
472 op.Operation,
473 )
474
475 ch <- prometheus.MustNewConstMetric(
476 c.NFSOperationsQueueTimeSecondsTotal,
477 prometheus.CounterValue,
478 op.CumulativeQueueTime.Seconds(),
479 export,
480 op.Operation,
481 )
482
483 ch <- prometheus.MustNewConstMetric(
484 c.NFSOperationsResponseTimeSecondsTotal,
485 prometheus.CounterValue,
486 op.CumulativeTotalResponseTime.Seconds(),
487 export,
488 op.Operation,
489 )
490
491 ch <- prometheus.MustNewConstMetric(
492 c.NFSOperationsRequestTimeSecondsTotal,
493 prometheus.CounterValue,
494 op.CumulativeTotalRequestTime.Seconds(),
495 export,
496 op.Operation,
497 )
498 }
499}
diff --git a/end-to-end-test.sh b/end-to-end-test.sh
index ce6351e..8efd36b 100755
--- a/end-to-end-test.sh
+++ b/end-to-end-test.sh
@@ -13,6 +13,7 @@ collectors=$(cat << COLLECTORS
13 mdadm 13 mdadm
14 meminfo 14 meminfo
15 meminfo_numa 15 meminfo_numa
16 mountstats
16 netdev 17 netdev
17 netstat 18 netstat
18 nfs 19 nfs