Skip to content

Commit 5237827

Browse files
committed
Report NFS Transport per port.
Signed-off-by: Peter Štibraný <[email protected]>
1 parent dd6d587 commit 5237827

File tree

1 file changed

+76
-71
lines changed

1 file changed

+76
-71
lines changed

collector/mountstats_linux.go

Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package collector
1818

1919
import (
2020
"fmt"
21+
"strconv"
2122

2223
"github.com/go-kit/log"
2324
"github.com/go-kit/log/level"
@@ -129,6 +130,7 @@ func NewMountStatsCollector(logger log.Logger) (Collector, error) {
129130

130131
var (
131132
labels = []string{"export", "protocol", "mountaddr"}
133+
trLabels = []string{"export", "protocol", "mountaddr", "port"}
132134
opLabels = []string{"export", "protocol", "mountaddr", "operation"}
133135
)
134136

@@ -199,70 +201,70 @@ func NewMountStatsCollector(logger log.Logger) (Collector, error) {
199201
NFSTransportBindTotal: prometheus.NewDesc(
200202
prometheus.BuildFQName(namespace, subsystem, "transport_bind_total"),
201203
"Number of times the client has had to establish a connection from scratch to the NFS server.",
202-
labels,
204+
trLabels,
203205
nil,
204206
),
205207

206208
NFSTransportConnectTotal: prometheus.NewDesc(
207209
prometheus.BuildFQName(namespace, subsystem, "transport_connect_total"),
208210
"Number of times the client has made a TCP connection to the NFS server.",
209-
labels,
211+
trLabels,
210212
nil,
211213
),
212214

213215
NFSTransportIdleTimeSeconds: prometheus.NewDesc(
214216
prometheus.BuildFQName(namespace, subsystem, "transport_idle_time_seconds"),
215217
"Duration since the NFS mount last saw any RPC traffic, in seconds.",
216-
labels,
218+
trLabels,
217219
nil,
218220
),
219221

220222
NFSTransportSendsTotal: prometheus.NewDesc(
221223
prometheus.BuildFQName(namespace, subsystem, "transport_sends_total"),
222224
"Number of RPC requests for this mount sent to the NFS server.",
223-
labels,
225+
trLabels,
224226
nil,
225227
),
226228

227229
NFSTransportReceivesTotal: prometheus.NewDesc(
228230
prometheus.BuildFQName(namespace, subsystem, "transport_receives_total"),
229231
"Number of RPC responses for this mount received from the NFS server.",
230-
labels,
232+
trLabels,
231233
nil,
232234
),
233235

234236
NFSTransportBadTransactionIDsTotal: prometheus.NewDesc(
235237
prometheus.BuildFQName(namespace, subsystem, "transport_bad_transaction_ids_total"),
236238
"Number of times the NFS server sent a response with a transaction ID unknown to this client.",
237-
labels,
239+
trLabels,
238240
nil,
239241
),
240242

241243
NFSTransportBacklogQueueTotal: prometheus.NewDesc(
242244
prometheus.BuildFQName(namespace, subsystem, "transport_backlog_queue_total"),
243245
"Total number of items added to the RPC backlog queue.",
244-
labels,
246+
trLabels,
245247
nil,
246248
),
247249

248250
NFSTransportMaximumRPCSlots: prometheus.NewDesc(
249251
prometheus.BuildFQName(namespace, subsystem, "transport_maximum_rpc_slots"),
250252
"Maximum number of simultaneously active RPC requests ever used.",
251-
labels,
253+
trLabels,
252254
nil,
253255
),
254256

255257
NFSTransportSendingQueueTotal: prometheus.NewDesc(
256258
prometheus.BuildFQName(namespace, subsystem, "transport_sending_queue_total"),
257259
"Total number of items added to the RPC transmission sending queue.",
258-
labels,
260+
trLabels,
259261
nil,
260262
),
261263

262264
NFSTransportPendingQueueTotal: prometheus.NewDesc(
263265
prometheus.BuildFQName(namespace, subsystem, "transport_pending_queue_total"),
264266
"Total number of items added to the RPC transmission pending queue.",
265-
labels,
267+
trLabels,
266268
nil,
267269
),
268270

@@ -626,76 +628,79 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, s *pro
626628
labelValues...,
627629
)
628630

629-
tr := lastTransportOrEmpty(s.Transport)
630-
ch <- prometheus.MustNewConstMetric(
631-
c.NFSTransportBindTotal,
632-
prometheus.CounterValue,
633-
float64(tr.Bind),
634-
labelValues...,
635-
)
631+
for _, tr := range s.Transport {
632+
trLabelValues := []string{export, protocol, mountAddress, strconv.FormatUint(tr.Port, 10)}
636633

637-
ch <- prometheus.MustNewConstMetric(
638-
c.NFSTransportConnectTotal,
639-
prometheus.CounterValue,
640-
float64(tr.Connect),
641-
labelValues...,
642-
)
634+
ch <- prometheus.MustNewConstMetric(
635+
c.NFSTransportBindTotal,
636+
prometheus.CounterValue,
637+
float64(tr.Bind),
638+
trLabelValues...,
639+
)
643640

644-
ch <- prometheus.MustNewConstMetric(
645-
c.NFSTransportIdleTimeSeconds,
646-
prometheus.GaugeValue,
647-
float64(tr.IdleTimeSeconds%float64Mantissa),
648-
labelValues...,
649-
)
641+
ch <- prometheus.MustNewConstMetric(
642+
c.NFSTransportConnectTotal,
643+
prometheus.CounterValue,
644+
float64(tr.Connect),
645+
trLabelValues...,
646+
)
650647

651-
ch <- prometheus.MustNewConstMetric(
652-
c.NFSTransportSendsTotal,
653-
prometheus.CounterValue,
654-
float64(tr.Sends),
655-
labelValues...,
656-
)
648+
ch <- prometheus.MustNewConstMetric(
649+
c.NFSTransportIdleTimeSeconds,
650+
prometheus.GaugeValue,
651+
float64(tr.IdleTimeSeconds%float64Mantissa),
652+
trLabelValues...,
653+
)
657654

658-
ch <- prometheus.MustNewConstMetric(
659-
c.NFSTransportReceivesTotal,
660-
prometheus.CounterValue,
661-
float64(tr.Receives),
662-
labelValues...,
663-
)
655+
ch <- prometheus.MustNewConstMetric(
656+
c.NFSTransportSendsTotal,
657+
prometheus.CounterValue,
658+
float64(tr.Sends),
659+
trLabelValues...,
660+
)
664661

665-
ch <- prometheus.MustNewConstMetric(
666-
c.NFSTransportBadTransactionIDsTotal,
667-
prometheus.CounterValue,
668-
float64(tr.BadTransactionIDs),
669-
labelValues...,
670-
)
662+
ch <- prometheus.MustNewConstMetric(
663+
c.NFSTransportReceivesTotal,
664+
prometheus.CounterValue,
665+
float64(tr.Receives),
666+
trLabelValues...,
667+
)
671668

672-
ch <- prometheus.MustNewConstMetric(
673-
c.NFSTransportBacklogQueueTotal,
674-
prometheus.CounterValue,
675-
float64(tr.CumulativeBacklog),
676-
labelValues...,
677-
)
669+
ch <- prometheus.MustNewConstMetric(
670+
c.NFSTransportBadTransactionIDsTotal,
671+
prometheus.CounterValue,
672+
float64(tr.BadTransactionIDs),
673+
trLabelValues...,
674+
)
678675

679-
ch <- prometheus.MustNewConstMetric(
680-
c.NFSTransportMaximumRPCSlots,
681-
prometheus.GaugeValue,
682-
float64(tr.MaximumRPCSlotsUsed),
683-
labelValues...,
684-
)
676+
ch <- prometheus.MustNewConstMetric(
677+
c.NFSTransportBacklogQueueTotal,
678+
prometheus.CounterValue,
679+
float64(tr.CumulativeBacklog),
680+
trLabelValues...,
681+
)
685682

686-
ch <- prometheus.MustNewConstMetric(
687-
c.NFSTransportSendingQueueTotal,
688-
prometheus.CounterValue,
689-
float64(tr.CumulativeSendingQueue),
690-
labelValues...,
691-
)
683+
ch <- prometheus.MustNewConstMetric(
684+
c.NFSTransportMaximumRPCSlots,
685+
prometheus.GaugeValue,
686+
float64(tr.MaximumRPCSlotsUsed),
687+
trLabelValues...,
688+
)
692689

693-
ch <- prometheus.MustNewConstMetric(
694-
c.NFSTransportPendingQueueTotal,
695-
prometheus.CounterValue,
696-
float64(tr.CumulativePendingQueue),
697-
labelValues...,
698-
)
690+
ch <- prometheus.MustNewConstMetric(
691+
c.NFSTransportSendingQueueTotal,
692+
prometheus.CounterValue,
693+
float64(tr.CumulativeSendingQueue),
694+
trLabelValues...,
695+
)
696+
697+
ch <- prometheus.MustNewConstMetric(
698+
c.NFSTransportPendingQueueTotal,
699+
prometheus.CounterValue,
700+
float64(tr.CumulativePendingQueue),
701+
trLabelValues...,
702+
)
703+
}
699704

700705
for _, op := range s.Operations {
701706
opLabelValues := []string{export, protocol, mountAddress, op.Operation}

0 commit comments

Comments
 (0)