{"record":{"id":"8aeba8c341907673","repo":"glanceapp/glance","slug":"getting-core-count-v","errorCode":null,"errorMessage":"getting core count: %v","messagePattern":"getting core count: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/sysinfo/sysinfo.go","lineNumber":178,"sourceCode":"\t\tloadAvg, err := load.Avg()\n\t\tif err == nil {\n\t\t\tinfo.CPU.LoadIsAvailable = true\n\t\t\tif runtime.GOOS == \"windows\" {\n\t\t\t\t// The numbers returned here seem unreliable on Windows. Even with the CPU pegged\n\t\t\t\t// at close to 50% for multiple minutes, load1 is sometimes way under or way over\n\t\t\t\t// with no clear pattern. Dividing by core count gives numbers that are way too\n\t\t\t\t// low so that's likely not necessary as it is with unix.\n\t\t\t\tinfo.CPU.Load1Percent = uint8(math.Min(loadAvg.Load1*100, 100))\n\t\t\t\tinfo.CPU.Load15Percent = uint8(math.Min(loadAvg.Load15*100, 100))\n\t\t\t} else {\n\t\t\t\tinfo.CPU.Load1Percent = uint8(math.Min((loadAvg.Load1/float64(coreCount))*100, 100))\n\t\t\t\tinfo.CPU.Load15Percent = uint8(math.Min((loadAvg.Load15/float64(coreCount))*100, 100))\n\t\t\t}\n\t\t} else {\n\t\t\taddErr(fmt.Errorf(\"getting load avg: %v\", err))\n\t\t}\n\t} else {\n\t\taddErr(fmt.Errorf(\"getting core count: %v\", err))\n\t}\n\n\tmemory, err := mem.VirtualMemory()\n\tif err == nil {\n\t\tinfo.Memory.IsAvailable = true\n\t\tinfo.Memory.TotalMB = memory.Total / 1024 / 1024\n\t\tinfo.Memory.UsedMB = memory.Used / 1024 / 1024\n\t\tinfo.Memory.UsedPercent = uint8(math.Min(memory.UsedPercent, 100))\n\t} else {\n\t\taddErr(fmt.Errorf(\"getting memory info: %v\", err))\n\t}\n\n\tswapMemory, err := mem.SwapMemory()\n\tif err == nil {\n\t\tinfo.Memory.SwapIsAvailable = true\n\t\tinfo.Memory.SwapTotalMB = swapMemory.Total / 1024 / 1024\n\t\tinfo.Memory.SwapUsedMB = swapMemory.Used / 1024 / 1024\n\t\tinfo.Memory.SwapUsedPercent = uint8(math.Min(swapMemory.UsedPercent, 100))","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/pkg/sysinfo/sysinfo.go#L160-L196","documentation":"Non-fatal: cpu.Counts(true) failed, so neither core count nor load averages are collected (load normalization needs the count); recorded via addErr and the rest of sysinfo proceeds. The CPU usage percentage path may still work via other sources.","triggerScenarios":"Logical CPU enumeration failing: unable to read /proc/cpuinfo or sysfs CPU entries on Linux, or the equivalent OS API erroring on restricted virtualized hosts.","commonSituations":"Minimal containers lacking /proc/cpuinfo or /sys/devices/system/cpu; heavily sandboxed runtimes (gVisor) limiting CPU topology queries; rare driver-level virtualization quirks.","solutions":["Verify /proc/cpuinfo and /sys/devices/system/cpu are readable inside the container","Relax the sandbox or mount host proc/sys as needed for accurate counts","Accept degraded metrics if only load bars are missing — the error is aggregated with the rest"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"func isCoreCountErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"getting core count\")\n}","tryCatchPattern":"info, err := sysinfo.Get()\nif isCoreCountErr(err) {\n    // core count and load are both unavailable; fall back to unnormalized display\n    slog.Warn(\"cpu count unavailable\", \"err\", err)\n}","preventionTips":["Ensure /proc/cpuinfo and /sys/devices/system/cpu are visible to the process","Treat the aggregated sysinfo error as advisory — check each section's IsAvailable flag"],"tags":["sysinfo","cpu","container","proc"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}