{"record":{"id":"76320dac25e5e967","repo":"glanceapp/glance","slug":"getting-swap-memory-info-v","errorCode":null,"errorMessage":"getting swap memory info: %v","messagePattern":"getting swap memory info: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/sysinfo/sysinfo.go","lineNumber":198,"sourceCode":"\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))\n\t} else {\n\t\taddErr(fmt.Errorf(\"getting swap memory info: %v\", err))\n\t}\n\n\t// currently disabled on Windows because it requires elevated privilidges, otherwise\n\t// keeps returning a single sensor with key \"ACPI\\\\ThermalZone\\\\TZ00_0\" which\n\t// doesn't seem to be the CPU sensor or correspond to anything useful when\n\t// compared against the temperatures Libre Hardware Monitor reports.\n\t// Also disabled on the bsd's because it's not implemented by go-psutil for them\n\tif runtime.GOOS != \"windows\" && runtime.GOOS != \"openbsd\" && runtime.GOOS != \"netbsd\" && runtime.GOOS != \"freebsd\" {\n\t\tsensorReadings, err := sensors.SensorsTemperatures()\n\t\t_, errIsWarning := err.(*sensors.Warnings)\n\t\tif err == nil || errIsWarning {\n\t\t\tif req.CPUTempSensor != \"\" {\n\t\t\t\tfor i := range sensorReadings {\n\t\t\t\t\tif sensorReadings[i].SensorKey == req.CPUTempSensor {\n\t\t\t\t\t\tinfo.CPU.TemperatureIsAvailable = true\n\t\t\t\t\t\tinfo.CPU.TemperatureC = uint8(sensorReadings[i].Temperature)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/pkg/sysinfo/sysinfo.go#L180-L216","documentation":"Error \"getting swap memory info: %v\" thrown in glanceapp/glance.","triggerScenarios":"Occurs when the system cannot read swap memory information from /proc/meminfo or the sysinfo syscall fails, typically on minimal containers or restricted environments.","commonSituations":"Running inside a container without /proc mounted, on a host with swap disabled reporting inconsistencies, or on an OS where swap metrics are unavailable.","solutions":["Ensure the system exposes swap memory information readable by the process (check /proc/swaps and /proc/meminfo permissions).","If the host has no swap configured, this error is expected; ignore it or disable swap collection.","On containers or restricted environments, run with sufficient privileges or mount /proc so gopsutil can read swap stats."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}