nicolargo/glances · error · HTTPException
Unknown PID process
Error message
Unknown PID process {pid} What it means
HTTP 404 raised by PUT /api/4/processes/{pid}/extended (set extended process) when glances_processes.get_stats(int(pid)) returns a falsy value, meaning no stats are currently cached for that PID. The process may have exited between listing and selection, or it is not visible to Glances' process collector.
Solutions
- Retry shortly — the process cache refreshes on the stats update cycle, newly spawned PIDs appear then
- Verify with GET /api/4/processes that the PID is in the current list before extending it
- Check --enable-process-extended is supported and no process filter (name/user regex) excludes the target
- If monitoring containers, query the PID from the same PID namespace as glances
Example fix
# before PUT /api/4/processes/4242/extended # after (confirm existence first) GET /api/4/processes | jq '.[] | select(.pid==4242)' PUT /api/4/processes/4242/extended
Defensive patterns
Strategy: validation
Validate before calling
live = {p['pid'] for p in requests.get(f'{base}/api/4/processes').json()}
if pid not in live:
raise LookupError(f'PID {pid} not visible to glances') Type guard
def pid_exists(pid: int) -> bool:
return any(p['pid'] == pid for p in requests.get(f'{base}/api/4/processes').json()) Try / catch
try:
r = requests.put(f'{base}/api/4/processes/{pid}/extended')
r.raise_for_status()
except requests.HTTPError as e:
if e.response.status_code == 404:
# process gone: stop tracking
tracked.discard(pid)
else:
raise Prevention
- Check the process list snapshot before acting on a PID
- Treat 404 as terminal for a PID, not retryable
- Run glances in the same PID namespace as target processes
When it happens
Trigger: PUT /api/4/processes/1234/extended where PID 1234 is dead, not yet in the process cache (stats update every refresh interval), hidden by process filtering, or inside another PID namespace (container).
Common situations: Web UI race: user clicks a process that exits before the request; monitoring containerized workloads from the host (or vice versa); strict process filtering excluding the PID.
Related errors
- Cannot get args item
- Cannot get args ( )
- Cannot get config section
- Cannot get config ( )
- Cannot get help view data
AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27).
Data as JSON: /api/errors/d9d91bcd6499dce6.
Report an issue: GitHub.
Appendix: source
Thrown at glances/outputs/glances_restful_api.py:1429
try:
args_json = self._sanitize_args()[item]
except Exception as e:
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get args item ({str(e)})")
return GlancesJSONResponse(args_json)
def _api_set_extended_processes(self, pid: str):
"""Glances API RESTful implementation.
Set the extended process stats for the given PID
HTTP/200 if OK
HTTP/400 if PID is not found
HTTP/404 if others error
"""
process_stats = glances_processes.get_stats(int(pid))
if not process_stats:
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Unknown PID process {pid}")
glances_processes.extended_process = process_stats
return GlancesJSONResponse(True)
def _api_disable_extended_processes(self):
"""Glances API RESTful implementation.
Disable extended process stats
HTTP/200 if OK
HTTP/400 if PID is not found
HTTP/404 if others error
"""
glances_processes.extended_process = None
return GlancesJSONResponse(True)
def _api_get_extended_processes(self):View on GitHub (pinned to a240d8dfb3)