nicolargo/glances · error · HTTPException
Cannot get stats ({str(e)})
Error message
Cannot get stats ({str(e)}) What it means
Raised when getAllAsDict() fails while building the full stats dump, returned as HTTP 404. Any single plugin raising during serialization of the combined stats payload triggers this. The underlying exception message is appended.
Source
Thrown at glances/outputs/glances_restful_api.py:952
# Comment this solve an issue on Home Assistant See #3238
def _api_all(self):
"""Glances API RESTful implementation.
Return the JSON representation of all the plugins
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error
"""
# Update the stat
self.__update_stats()
try:
# Get the RAW value of the stat ID
# TODO in #3211: use getAllExportsAsDict instead but break UI for uptime, processlist, others ?
statval = self.stats.getAllAsDict()
except Exception as e:
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get stats ({str(e)})")
return GlancesJSONResponse(statval)
def _api_all_limits(self):
"""Glances API RESTful implementation.
Return the JSON representation of all the plugins limits
HTTP/200 if OK
HTTP/400 if plugin is not found
HTTP/404 if others error
"""
try:
# Get the RAW value of the stat limits
limits = self.stats.getAllLimitsAsDict()
except Exception as e:
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get limits ({str(e)})")
return GlancesJSONResponse(limits)View on GitHub (pinned to a240d8dfb3)
Solutions
- Poll individual plugin endpoints (GET /api/4/plugins then /api/4/<plugin>) to isolate the failing plugin
- Check server logs for the underlying exception name embedded in the 404 body
- Disable the failing plugin with --disable-plugin <name> as a workaround
- Ensure required dependencies and host file access exist (especially for gpu, sensors plugins)
Defensive patterns
Strategy: fallback
Validate before calling
r = httpx.get(f'{BASE}/api/4/all')
if r.status_code != 200:
# fall back to per-plugin fetch
plugins = httpx.get(f'{BASE}/api/4/plugins').json() Try / catch
try:
stats = httpx.get(f'{BASE}/api/4/all', timeout=10).json()
except httpx.HTTPStatusError as e:
if e.response.status_code == 404:
stats = {p: httpx.get(f'{BASE}/api/4/{p}').json()
for p in httpx.get(f'{BASE}/api/4/plugins').json()}
else:
raise Prevention
- Retry once before falling back — collection errors are often transient
- Isolate failing plugins with per-plugin requests
When it happens
Trigger: GET /api/4/all when any plugin's stats serialization raises — e.g., a plugin accessing a missing sysfs/procfs file, or a GPU/NPU library (pynvml) erroring mid-collection.
Common situations: Containerized or Snap-confined environments where /proc or /sys paths are unreadable, transient errors from hardware-monitoring plugins, or a plugin dependency missing at runtime.
Related errors
- Cannot get help view data ({str(e)})
- Cannot get plugin list ({str(e)})
- Cannot get limits ({str(e)})
- Cannot get views ({str(e)})
- Cannot get plugin {plugin} ({str(e)})
AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27).
Data as JSON: /api/errors/73d959c14d36058a.
Report an issue: GitHub.