{"record":{"id":"793f14579b1cf16c","repo":"glanceapp/glance","slug":"getting-load-avg-v","errorCode":null,"errorMessage":"getting load avg: %v","messagePattern":"getting load avg: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/sysinfo/sysinfo.go","lineNumber":175,"sourceCode":"\n\tcoreCount, err := cpu.Counts(true)\n\tif err == nil {\n\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","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/pkg/sysinfo/sysinfo.go#L157-L193","documentation":"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.","triggerScenarios":"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.","commonSituations":"Docker with masked/readonly /proc, gVisor/Kata sandboxes, or unusual kernels; widget shows CPU/memory but load bars are empty.","solutions":["Ensure /proc is mounted and readable in the container (load.Avg reads /proc/loadavg on Linux)","If the environment genuinely lacks loadavg (some sandboxes), accept degraded output — the error is aggregated, not fatal","Run Glance with host PID namespace / proper proc mount if accurate host load is required"],"exampleFix":"# docker-compose.yml\n# before\nservices:\n  glance:\n    volumes:\n      - ./config:/app/config\n\n# after\nservices:\n  glance:\n    volumes:\n      - ./config:/app/config\n      - /proc:/host/proc:ro  # or run with --pid=host per deployment docs","handlingStrategy":"fallback","validationCode":null,"typeGuard":"func isLoadAvgErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"getting load avg\")\n}","tryCatchPattern":"info, err := sysinfo.Get()\nif isLoadAvgErr(err) {\n    // hide load bars, keep CPU/memory panels\n    renderServerStats(info, hideLoad=true)\n}","preventionTips":["Mount /proc readably in containers so load.Avg can read /proc/loadavg","Gate load display on info.CPU.LoadIsAvailable rather than on error presence"],"tags":["sysinfo","load-average","container","proc"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}