diff --git a/mountstats.go b/mountstats.go index 9d8af6db..86fd57a6 100644 --- a/mountstats.go +++ b/mountstats.go @@ -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. @@ -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 diff --git a/mountstats_test.go b/mountstats_test.go index 43903e9e..d4856b5c 100644 --- a/mountstats_test.go +++ b/mountstats_test.go @@ -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, // + }, }, }, }}, @@ -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, // + }, }, }, }}, @@ -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, + }, }, }, }}, @@ -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, + }, }, }, }}, @@ -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, + }, }, }, }, @@ -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, + }, }, }, }},