glanceapp/glance · warning

getting core count: %v

Error message

getting core count: %v

What it means

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.

Source

Thrown at pkg/sysinfo/sysinfo.go:178

		loadAvg, err := load.Avg()
		if err == nil {
			info.CPU.LoadIsAvailable = true
			if runtime.GOOS == "windows" {
				// The numbers returned here seem unreliable on Windows. Even with the CPU pegged
				// at close to 50% for multiple minutes, load1 is sometimes way under or way over
				// with no clear pattern. Dividing by core count gives numbers that are way too
				// low so that's likely not necessary as it is with unix.
				info.CPU.Load1Percent = uint8(math.Min(loadAvg.Load1*100, 100))
				info.CPU.Load15Percent = uint8(math.Min(loadAvg.Load15*100, 100))
			} else {
				info.CPU.Load1Percent = uint8(math.Min((loadAvg.Load1/float64(coreCount))*100, 100))
				info.CPU.Load15Percent = uint8(math.Min((loadAvg.Load15/float64(coreCount))*100, 100))
			}
		} else {
			addErr(fmt.Errorf("getting load avg: %v", err))
		}
	} else {
		addErr(fmt.Errorf("getting core count: %v", err))
	}

	memory, err := mem.VirtualMemory()
	if err == nil {
		info.Memory.IsAvailable = true
		info.Memory.TotalMB = memory.Total / 1024 / 1024
		info.Memory.UsedMB = memory.Used / 1024 / 1024
		info.Memory.UsedPercent = uint8(math.Min(memory.UsedPercent, 100))
	} else {
		addErr(fmt.Errorf("getting memory info: %v", err))
	}

	swapMemory, err := mem.SwapMemory()
	if err == nil {
		info.Memory.SwapIsAvailable = true
		info.Memory.SwapTotalMB = swapMemory.Total / 1024 / 1024
		info.Memory.SwapUsedMB = swapMemory.Used / 1024 / 1024
		info.Memory.SwapUsedPercent = uint8(math.Min(swapMemory.UsedPercent, 100))

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Verify /proc/cpuinfo and /sys/devices/system/cpu are readable inside the container
  2. Relax the sandbox or mount host proc/sys as needed for accurate counts
  3. Accept degraded metrics if only load bars are missing — the error is aggregated with the rest
Defensive patterns

Strategy: fallback

Type guard

func isCoreCountErr(err error) bool {
	return err != nil && strings.Contains(err.Error(), "getting core count")
}

Try / catch

info, err := sysinfo.Get()
if isCoreCountErr(err) {
    // core count and load are both unavailable; fall back to unnormalized display
    slog.Warn("cpu count unavailable", "err", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: Minimal containers lacking /proc/cpuinfo or /sys/devices/system/cpu; heavily sandboxed runtimes (gVisor) limiting CPU topology queries; rare driver-level virtualization quirks.

Related errors


AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15). Data as JSON: /api/errors/8aeba8c341907673. Report an issue: GitHub.