func readNFSClientStats()

in image/resources/knfsd-agent/nfs.go [55:168]


func readNFSClientStats(fs nfs.FS, proc procfs.Proc, nfsRoot string) (*client.NFSClientStats, error) {
	s, err := fs.ClientRPCStats()
	if err != nil {
		return nil, err
	}

	// IO stats not are included in /proc/net/rpc/nfs (unlike nfsd server
	// stats). Instead we'll need to read these from /proc/self/mountstats
	// and aggregate the total read/write byte counters.
	io, err := readNFSClientIOTotal(proc, nfsRoot)
	if err != nil {
		return nil, err
	}

	return &client.NFSClientStats{
		IO: io,
		Network: client.NFSNetwork{
			TotalPackets:   s.Network.NetCount,
			UDPPackets:     s.Network.UDPCount,
			TCPPackets:     s.Network.TCPCount,
			TCPConnections: s.Network.TCPConnect,
		},
		RPC: client.NFSClientRPC{
			Count:           s.ClientRPC.RPCCount,
			AuthRefreshes:   s.ClientRPC.AuthRefreshes,
			Retransmissions: s.ClientRPC.Retransmissions,
		},
		Proc3: client.NFSProc3{
			Null:        s.V3Stats.Null,
			GetAttr:     s.V3Stats.GetAttr,
			SetAttr:     s.V3Stats.SetAttr,
			Lookup:      s.V3Stats.Lookup,
			Access:      s.V3Stats.Access,
			ReadLink:    s.V3Stats.ReadLink,
			Read:        s.V3Stats.Read,
			Write:       s.V3Stats.Write,
			Create:      s.V3Stats.Create,
			MkDir:       s.V3Stats.MkDir,
			SymLink:     s.V3Stats.SymLink,
			MkNod:       s.V3Stats.MkNod,
			Remove:      s.V3Stats.Remove,
			RmDir:       s.V3Stats.RmDir,
			Rename:      s.V3Stats.Rename,
			Link:        s.V3Stats.Link,
			ReadDir:     s.V3Stats.ReadDir,
			ReadDirPlus: s.V3Stats.ReadDirPlus,
			FsStat:      s.V3Stats.FsStat,
			FsInfo:      s.V3Stats.FsInfo,
			PathConf:    s.V3Stats.PathConf,
			Commit:      s.V3Stats.Commit,
		},
		Proc4: client.NFSClientProc4{
			Null:               s.ClientV4Stats.Null,
			Read:               s.ClientV4Stats.Read,
			Write:              s.ClientV4Stats.Write,
			Commit:             s.ClientV4Stats.Commit,
			Open:               s.ClientV4Stats.Open,
			OpenConfirm:        s.ClientV4Stats.OpenConfirm,
			OpenNoattr:         s.ClientV4Stats.OpenNoattr,
			OpenDowngrade:      s.ClientV4Stats.OpenDowngrade,
			Close:              s.ClientV4Stats.Close,
			Setattr:            s.ClientV4Stats.Setattr,
			FsInfo:             s.ClientV4Stats.FsInfo,
			Renew:              s.ClientV4Stats.Renew,
			SetClientID:        s.ClientV4Stats.SetClientID,
			SetClientIDConfirm: s.ClientV4Stats.SetClientIDConfirm,
			Lock:               s.ClientV4Stats.Lock,
			Lockt:              s.ClientV4Stats.Lockt,
			Locku:              s.ClientV4Stats.Locku,
			Access:             s.ClientV4Stats.Access,
			Getattr:            s.ClientV4Stats.Getattr,
			Lookup:             s.ClientV4Stats.Lookup,
			LookupRoot:         s.ClientV4Stats.LookupRoot,
			Remove:             s.ClientV4Stats.Remove,
			Rename:             s.ClientV4Stats.Rename,
			Link:               s.ClientV4Stats.Link,
			Symlink:            s.ClientV4Stats.Symlink,
			Create:             s.ClientV4Stats.Create,
			Pathconf:           s.ClientV4Stats.Pathconf,
			StatFs:             s.ClientV4Stats.StatFs,
			ReadLink:           s.ClientV4Stats.ReadLink,
			ReadDir:            s.ClientV4Stats.ReadDir,
			ServerCaps:         s.ClientV4Stats.ServerCaps,
			DelegReturn:        s.ClientV4Stats.DelegReturn,
			GetACL:             s.ClientV4Stats.GetACL,
			SetACL:             s.ClientV4Stats.SetACL,
			FsLocations:        s.ClientV4Stats.FsLocations,
			ReleaseLockowner:   s.ClientV4Stats.ReleaseLockowner,
			Secinfo:            s.ClientV4Stats.Secinfo,
			FsidPresent:        s.ClientV4Stats.FsidPresent,
			ExchangeID:         s.ClientV4Stats.ExchangeID,
			CreateSession:      s.ClientV4Stats.CreateSession,
			DestroySession:     s.ClientV4Stats.DestroySession,
			Sequence:           s.ClientV4Stats.Sequence,
			GetLeaseTime:       s.ClientV4Stats.GetLeaseTime,
			ReclaimComplete:    s.ClientV4Stats.ReclaimComplete,
			LayoutGet:          s.ClientV4Stats.LayoutGet,
			GetDeviceInfo:      s.ClientV4Stats.GetDeviceInfo,
			LayoutCommit:       s.ClientV4Stats.LayoutCommit,
			LayoutReturn:       s.ClientV4Stats.LayoutReturn,
			SecinfoNoName:      s.ClientV4Stats.SecinfoNoName,
			TestStateID:        s.ClientV4Stats.TestStateID,
			FreeStateID:        s.ClientV4Stats.FreeStateID,
			GetDeviceList:      s.ClientV4Stats.GetDeviceList,
			BindConnToSession:  s.ClientV4Stats.BindConnToSession,
			DestroyClientID:    s.ClientV4Stats.DestroyClientID,
			Seek:               s.ClientV4Stats.Seek,
			Allocate:           s.ClientV4Stats.Allocate,
			DeAllocate:         s.ClientV4Stats.DeAllocate,
			LayoutStats:        s.ClientV4Stats.LayoutStats,
			Clone:              s.ClientV4Stats.Clone,
		},
	}, nil
}