Correct CPU core counts and report incomplete data size scans
This commit is contained in:
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -94,8 +95,8 @@ func (s *systemStatsSampler) cpu(ctx context.Context, r *protocol.ServerCPUStats
|
||||
if v, e := cpu.InfoWithContext(ctx); e == nil && len(v) > 0 {
|
||||
r.Model = v[0].ModelName
|
||||
}
|
||||
r.LogicalCores, _ = cpu.CountsWithContext(ctx, false)
|
||||
r.PhysicalCores, _ = cpu.CountsWithContext(ctx, true)
|
||||
r.LogicalCores, _ = cpu.CountsWithContext(ctx, true)
|
||||
r.PhysicalCores, _ = cpu.CountsWithContext(ctx, false)
|
||||
if v, e := cpu.PercentWithContext(ctx, 500*time.Millisecond, true); e == nil {
|
||||
r.PerCorePercent = v
|
||||
for _, n := range v {
|
||||
@@ -214,6 +215,7 @@ func boundedSize(ctx context.Context, root string, match func(string) bool) (uin
|
||||
}
|
||||
entries++
|
||||
if entries > maxSizeWalkEntries {
|
||||
walkErr = errors.New("directory size is partial: entry limit reached")
|
||||
return filepath.SkipAll
|
||||
}
|
||||
if d.Type()&os.ModeSymlink != 0 {
|
||||
@@ -225,6 +227,8 @@ func boundedSize(ctx context.Context, root string, match func(string) bool) (uin
|
||||
if !d.IsDir() && (match == nil || match(path)) {
|
||||
if i, e := d.Info(); e == nil && i.Size() > 0 {
|
||||
n += uint64(i.Size())
|
||||
} else if e != nil && walkErr == nil {
|
||||
walkErr = e
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user