MCPcopy
hub / github.com/syncthing/syncthing / reportData

Method reportData

lib/ur/usage_report.go:81–340  ·  view source on GitHub ↗
(ctx context.Context, urVersion int, preview bool)

Source from the content-addressed store, hash-verified

79}
80
81func (s *Service) reportData(ctx context.Context, urVersion int, preview bool) (*contract.Report, error) {
82 opts := s.cfg.Options()
83 defaultFolder := s.cfg.DefaultFolder()
84
85 var totFiles, maxFiles int
86 var totBytes, maxBytes int64
87 for folderID := range s.cfg.Folders() {
88 global, err := s.model.GlobalSize(folderID)
89 if err != nil {
90 return nil, err
91 }
92 totFiles += global.Files
93 totBytes += global.Bytes
94 if global.Files > maxFiles {
95 maxFiles = global.Files
96 }
97 if global.Bytes > maxBytes {
98 maxBytes = global.Bytes
99 }
100 }
101
102 var mem runtime.MemStats
103 runtime.ReadMemStats(&mem)
104
105 report := contract.New()
106
107 report.URVersion = urVersion
108 report.UniqueID = opts.URUniqueID
109 report.Version = build.Version
110 report.LongVersion = build.LongVersion
111 report.Platform = runtime.GOOS + "-" + runtime.GOARCH
112 report.NumFolders = len(s.cfg.Folders())
113 report.NumDevices = len(s.cfg.Devices())
114 report.TotFiles = totFiles
115 report.FolderMaxFiles = maxFiles
116 report.TotMiB = int(totBytes / 1024 / 1024)
117 report.FolderMaxMiB = int(maxBytes / 1024 / 1024)
118 report.MemoryUsageMiB = int((mem.Sys - mem.HeapReleased) / 1024 / 1024)
119 report.SHA256Perf = CpuBench(ctx, 5, 125*time.Millisecond)
120 report.HashPerf = report.SHA256Perf
121 report.MemorySize = int(memorySize() / 1024 / 1024)
122 report.NumCPU = runtime.NumCPU()
123
124 if proc, err := process.NewProcess(int32(os.Getpid())); err == nil {
125 if mem, err := proc.MemoryInfo(); err == nil {
126 report.ProcessRSSMiB = int(mem.RSS / 1024 / 1024)
127 }
128 }
129
130 for _, cfg := range s.cfg.Folders() {
131 report.RescanIntvs = append(report.RescanIntvs, cfg.RescanIntervalS)
132
133 switch cfg.Type {
134 case config.FolderTypeSendOnly:
135 report.FolderUses.SendOnly++
136 case config.FolderTypeSendReceive:
137 report.FolderUses.SendReceive++
138 case config.FolderTypeReceiveOnly:

Callers 2

ReportDataMethod · 0.95
ReportDataPreviewMethod · 0.95

Calls 15

UptimeSMethod · 0.95
NewFunction · 0.92
CpuBenchFunction · 0.85
SortMethod · 0.80
ListenAddressesMethod · 0.80
AutoUpgradeEnabledMethod · 0.80
ModTimeWindowMethod · 0.80
UseTLSMethod · 0.80
ClearForVersionMethod · 0.80
memorySizeFunction · 0.70
OptionsMethod · 0.65
DefaultFolderMethod · 0.65

Tested by

no test coverage detected