Skip to content

Commit

Permalink
bugfix: Allow multiple xprt fields for NFS stats
Browse files Browse the repository at this point in the history
Allow parsing multiple `xprt` fields present in the same NFS transport
stats data.

Fixes: prometheus#450
Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
  • Loading branch information
rexagod committed Mar 22, 2024
1 parent f7c2619 commit 6edba40
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 106 deletions.
4 changes: 2 additions & 2 deletions mountstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type MountStatsNFS struct {
// Statistics broken down by filesystem operation.
Operations []NFSOperationStats
// Statistics about the NFS RPC transport.
Transport NFSTransportStats
Transport []NFSTransportStats
}

// mountStats implements MountStats.
Expand Down Expand Up @@ -434,7 +434,7 @@ func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, e
return nil, err
}

stats.Transport = *tstats
stats.Transport = append(stats.Transport, *tstats)
}

// When encountering "per-operation statistics", we must break this
Expand Down
220 changes: 116 additions & 104 deletions mountstats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,23 @@ func TestMountStats(t *testing.T) {
Type: "nfs",
Stats: &MountStatsNFS{
StatVersion: "1.0",
Transport: NFSTransportStats{
Protocol: "tcp",
Port: 1,
Bind: 2,
Connect: 3,
ConnectIdleTime: 4,
IdleTimeSeconds: 5,
Sends: 6,
Receives: 7,
BadTransactionIDs: 8,
CumulativeActiveRequests: 9,
CumulativeBacklog: 10,
MaximumRPCSlotsUsed: 0, // these three are not
CumulativeSendingQueue: 0, // present in statvers=1.0
CumulativePendingQueue: 0, //
Transport: []NFSTransportStats{
{
Protocol: "tcp",
Port: 1,
Bind: 2,
Connect: 3,
ConnectIdleTime: 4,
IdleTimeSeconds: 5,
Sends: 6,
Receives: 7,
BadTransactionIDs: 8,
CumulativeActiveRequests: 9,
CumulativeBacklog: 10,
MaximumRPCSlotsUsed: 0, // these three are not
CumulativeSendingQueue: 0, // present in statvers=1.0
CumulativePendingQueue: 0, //
},
},
},
}},
Expand All @@ -144,21 +146,23 @@ func TestMountStats(t *testing.T) {
Type: "nfs",
Stats: &MountStatsNFS{
StatVersion: "1.0",
Transport: NFSTransportStats{
Protocol: "udp",
Port: 1,
Bind: 2,
Connect: 0,
ConnectIdleTime: 0,
IdleTimeSeconds: 0,
Sends: 3,
Receives: 4,
BadTransactionIDs: 5,
CumulativeActiveRequests: 6,
CumulativeBacklog: 7,
MaximumRPCSlotsUsed: 0, // these three are not
CumulativeSendingQueue: 0, // present in statvers=1.0
CumulativePendingQueue: 0, //
Transport: []NFSTransportStats{
{
Protocol: "udp",
Port: 1,
Bind: 2,
Connect: 0,
ConnectIdleTime: 0,
IdleTimeSeconds: 0,
Sends: 3,
Receives: 4,
BadTransactionIDs: 5,
CumulativeActiveRequests: 6,
CumulativeBacklog: 7,
MaximumRPCSlotsUsed: 0, // these three are not
CumulativeSendingQueue: 0, // present in statvers=1.0
CumulativePendingQueue: 0, //
},
},
},
}},
Expand All @@ -172,21 +176,23 @@ func TestMountStats(t *testing.T) {
Type: "nfs",
Stats: &MountStatsNFS{
StatVersion: "1.1",
Transport: NFSTransportStats{
Protocol: "tcp",
Port: 1,
Bind: 2,
Connect: 3,
ConnectIdleTime: 4,
IdleTimeSeconds: 5,
Sends: 6,
Receives: 7,
BadTransactionIDs: 8,
CumulativeActiveRequests: 9,
CumulativeBacklog: 10,
MaximumRPCSlotsUsed: 11,
CumulativeSendingQueue: 12,
CumulativePendingQueue: 13,
Transport: []NFSTransportStats{
{
Protocol: "tcp",
Port: 1,
Bind: 2,
Connect: 3,
ConnectIdleTime: 4,
IdleTimeSeconds: 5,
Sends: 6,
Receives: 7,
BadTransactionIDs: 8,
CumulativeActiveRequests: 9,
CumulativeBacklog: 10,
MaximumRPCSlotsUsed: 11,
CumulativeSendingQueue: 12,
CumulativePendingQueue: 13,
},
},
},
}},
Expand All @@ -200,21 +206,23 @@ func TestMountStats(t *testing.T) {
Type: "nfs",
Stats: &MountStatsNFS{
StatVersion: "1.1",
Transport: NFSTransportStats{
Protocol: "udp",
Port: 1,
Bind: 2,
Connect: 0, // these three are not
ConnectIdleTime: 0, // present for UDP
IdleTimeSeconds: 0, //
Sends: 3,
Receives: 4,
BadTransactionIDs: 5,
CumulativeActiveRequests: 6,
CumulativeBacklog: 7,
MaximumRPCSlotsUsed: 8,
CumulativeSendingQueue: 9,
CumulativePendingQueue: 10,
Transport: []NFSTransportStats{
{
Protocol: "udp",
Port: 1,
Bind: 2,
Connect: 0, // these three are not
ConnectIdleTime: 0, // present for UDP
IdleTimeSeconds: 0, //
Sends: 3,
Receives: 4,
BadTransactionIDs: 5,
CumulativeActiveRequests: 6,
CumulativeBacklog: 7,
MaximumRPCSlotsUsed: 8,
CumulativeSendingQueue: 9,
CumulativePendingQueue: 10,
},
},
},
}},
Expand Down Expand Up @@ -356,17 +364,19 @@ func TestMountStats(t *testing.T) {
AverageRTTMilliseconds: 0.5695744656983355,
},
},
Transport: NFSTransportStats{
Protocol: "tcp",
Port: 832,
Connect: 1,
IdleTimeSeconds: 11,
Sends: 6428,
Receives: 6428,
CumulativeActiveRequests: 12154,
MaximumRPCSlotsUsed: 24,
CumulativeSendingQueue: 26,
CumulativePendingQueue: 5726,
Transport: []NFSTransportStats{
{
Protocol: "tcp",
Port: 832,
Connect: 1,
IdleTimeSeconds: 11,
Sends: 6428,
Receives: 6428,
CumulativeActiveRequests: 12154,
MaximumRPCSlotsUsed: 24,
CumulativeSendingQueue: 26,
CumulativePendingQueue: 5726,
},
},
},
},
Expand Down Expand Up @@ -431,39 +441,41 @@ func TestMountStats(t *testing.T) {
Errors: 0,
},
},
Transport: NFSTransportStats{
Protocol: "rdma",
Port: 0,
Bind: 0,
Connect: 5808,
ConnectIdleTime: 62,
IdleTimeSeconds: 0,
Sends: 494490723,
Receives: 494490687,
BadTransactionIDs: 36,
CumulativeActiveRequests: 10032963746,
CumulativeBacklog: 1282789,
MaximumRPCSlotsUsed: 0,
CumulativeSendingQueue: 0,
CumulativePendingQueue: 0,
ReadChunkCount: 107150285,
WriteChunkCount: 1226637531,
ReplyChunkCount: 2673889,
TotalRdmaRequest: 135120843409861,
PullupCopyCount: 135119397156505,
HardwayRegisterCount: 266368832,
FailedMarshalCount: 75716996,
BadReplyCount: 0,
MrsRecovered: 7853,
MrsOrphaned: 0,
MrsAllocated: 0,
EmptySendctxQ: 0,
TotalRdmaReply: 0,
FixupCopyCount: 119328,
ReplyWaitsForSend: 1336431717,
LocalInvNeeded: 0,
NomsgCallCount: 96,
BcallCount: 0,
Transport: []NFSTransportStats{
{
Protocol: "rdma",
Port: 0,
Bind: 0,
Connect: 5808,
ConnectIdleTime: 62,
IdleTimeSeconds: 0,
Sends: 494490723,
Receives: 494490687,
BadTransactionIDs: 36,
CumulativeActiveRequests: 10032963746,
CumulativeBacklog: 1282789,
MaximumRPCSlotsUsed: 0,
CumulativeSendingQueue: 0,
CumulativePendingQueue: 0,
ReadChunkCount: 107150285,
WriteChunkCount: 1226637531,
ReplyChunkCount: 2673889,
TotalRdmaRequest: 135120843409861,
PullupCopyCount: 135119397156505,
HardwayRegisterCount: 266368832,
FailedMarshalCount: 75716996,
BadReplyCount: 0,
MrsRecovered: 7853,
MrsOrphaned: 0,
MrsAllocated: 0,
EmptySendctxQ: 0,
TotalRdmaReply: 0,
FixupCopyCount: 119328,
ReplyWaitsForSend: 1336431717,
LocalInvNeeded: 0,
NomsgCallCount: 96,
BcallCount: 0,
},
},
},
}},
Expand Down

0 comments on commit 6edba40

Please sign in to comment.