glanceapp/glance · warning

getting load avg: %v

Error message

getting load avg: %v

What it means

Non-fatal: load.Avg() (gopsutil load-average read) failed after the core count succeeded, recorded with addErr; CPU load percentages stay unavailable while the rest of sysinfo continues. On Unix this reads /proc/loadavg or sysctl vm.loadavg, so it fails when those sources are inaccessible.

Source

Thrown at pkg/sysinfo/sysinfo.go:175

	coreCount, err := cpu.Counts(true)
	if err == nil {
		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

View on GitHub (pinned to 91324e8de7)

Solutions

  1. Ensure /proc is mounted and readable in the container (load.Avg reads /proc/loadavg on Linux)
  2. If the environment genuinely lacks loadavg (some sandboxes), accept degraded output — the error is aggregated, not fatal
  3. Run Glance with host PID namespace / proper proc mount if accurate host load is required

Example fix

# docker-compose.yml
# before
services:
  glance:
    volumes:
      - ./config:/app/config

# after
services:
  glance:
    volumes:
      - ./config:/app/config
      - /proc:/host/proc:ro  # or run with --pid=host per deployment docs
Defensive patterns

Strategy: fallback

Type guard

func isLoadAvgErr(err error) bool {
	return err != nil && strings.Contains(err.Error(), "getting load avg")
}

Try / catch

info, err := sysinfo.Get()
if isLoadAvgErr(err) {
    // hide load bars, keep CPU/memory panels
    renderServerStats(info, hideLoad=true)
}

Prevention

When it happens

Trigger: Running inside a container without /proc mounted readably, a restricted sandbox, or an OS where the loadavg source is absent/locked; Windows loads take a different code path but the read can still fail.

Common situations: Docker with masked/readonly /proc, gVisor/Kata sandboxes, or unusual kernels; widget shows CPU/memory but load bars are empty.

Related errors


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