The Complete Production SOP: How to Deploy and Run Glances & htop Cross-Platform Real-Time Process Monitoring in Autonomous AI Agents
Step-by-step SOP to install and run Glances & htop Process Monitoring in Codex, Claude Code, and Cursor. Includes verified prompts, sandbox rules, and API checks.
Technical Overview & Architectural Context
Autonomous coding agents frequently misdiagnose system resource bottlenecks, hung child processes, and memory leaks because standard LLM toolchains rely on non-interactive or truncated shell output like 'ps aux' or 'top -b'. When an agent executes naive polling commands, it risks missing transient CPU spikes, thread contention, or I/O wait storms. Furthermore, interactive terminal programs often block agent subshells indefinitely if spawned without headless parameters or non-interactive pipe controls. The htop-glances-process-inspector skill provides deterministic boundaries for process inspection and hardware sensor diagnostics. By standardizing htop keyboard sequence equivalents (such as tree view hierarchical tracing and precise POSIX kill signals) alongside Glances headless client-server configurations and REST API endpoint consumption (e.g., /api/3/cpu), the skill ensures agents retrieve structured, machine-parseable telemetry without hanging subshells or exhausting LLM context windows.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into your agent runtime.
Autonomous agents search standard paths (~/.agents/skills or .cursor/skills) to register declarative capabilities. We mount the SKILL.md specification so that the agent matches triggers like 'run glances terminal' and 'glances rest api export' without hallucinating arbitrary CLI options.
mkdir -p ~/.agents/skills/htop-glances-process-inspector && curl -fsSL https://askills.dev/api/skills/htop-glances-process-inspector/raw -o ~/.agents/skills/htop-glances-process-inspector/SKILL.md---
name: "htop-glances-process-inspector"
description: "Inspect system processes, hardware sensors, and resource hogs using Glances and htop."
metadata:
author: "Nicolas Hennion"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "run glances terminal"
- "htop tree view process"
- "glances rest api export"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# Glances & htop Cross-Platform Real-Time Process Monitoring
Operates modern system inspectors: htop customizations (tree view, CPU affinity, kill signals), and Glances client-server monitoring over REST API and terminal curses mode.Specify output filtering with 'glances --stdout cpu,mem' or curl single JSON endpoints to prevent curses terminal escape sequences from saturating token limits.
Running interactive 'htop' directly within an automated agent bash session will cause the process to hang waiting for TTY inputs. Always instruct the agent to query via non-interactive switches or the Glances REST API.
Environment Configuration & Daemon Initialization
Install the required monitoring utilities and launch the Glances background REST listener.
To allow the agent to extract deterministic process metrics programmatically without requiring elevated interactive TTY sessions, configure a local Glances daemon bound to localhost and ensure htop is accessible in user PATH.
python3 -m pip install --quiet glances[all] && glances -w -B 127.0.0.1 -p 61208 --daemonBind Glances strictly to 127.0.0.1 instead of 0.0.0.0 to prevent unauthorized local network exposure during agent debugging sessions.
Ensure no orphaned instances of glances are already occupying port 61208 before spawning the daemon.
Intent Matching & Trigger Invocation
Verify deterministic activation using tested natural language prompts matching the SKILL.md trigger schema.
Provide high-intent user prompts that invoke the frontmatter triggers ('glances rest api export', 'htop tree view process'). The agent runtime maps these requests directly to the SOP execution flow rather than raw trial-and-error shell calls.
Combine 'glances rest api export' with specific metrics (e.g., 'mem', 'processlist') to restrict JSON output payload sizes.
Avoid ambiguous prompts like 'check my computer status' which might trigger unconstrained operating system inspection commands.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks and validate REST response payload integrity.
Before completing monitoring tasks, verify that the agent consumed valid JSON output from the Glances API and mapped process IDs accurately without deadlocking or leaving zombie processes.
curl -sf http://127.0.0.1:61208/api/3/cpu | jq . && curl -sf http://127.0.0.1:61208/api/3/mem | jq .Check exit code 0 on the curl verification pipe to guarantee the agent correctly handled upstream REST payloads.
Glances API version 3 returns float values for CPU utilization; ensure downstream parsers handle precision floats rather than strict integers.
Real-World Scenario: Diagnosing a Memory-Leaking Background Worker via Glances API
“glances rest api export: query the local glances daemon to find the top 3 processes consuming the most resident memory, inspect their parent process IDs in tree view format, and alert if memory exceeds 80%.”
Runtime Troubleshooting & Failure Modes
Root Cause: The Glances background daemon is not running, or failed to start due to missing bottle/aiohttp dependencies required for web mode.
pip install --upgrade 'glances[web]' && glances -w -B 127.0.0.1 -p 61208 --daemonRoot Cause: The agent execution subshell lacks a pseudo-terminal (pty) or TERM environment variable definition when attempting to invoke curses-based htop.
export TERM=xterm-256color && htop -b -n 1 | head -n 30Frequently Asked Questions (Glances & htop Cross-Platform Real-Time Process Monitoring SOP)
Q:Can I use Glances & htop Cross-Platform Real-Time Process Monitoring across Codex, Claude Code, and Cursor simultaneously?
Yes. The SKILL.md specification is platform-agnostic and universally loaded across Codex Desktop, Claude Code CLI, Cursor, and Windsurf agent configurations.
Q:How does Glances & htop Cross-Platform Real-Time Process Monitoring prevent context window overflow during long agent sessions?
It instructs the agent to avoid dumping continuous curses TTY streams. By utilizing single-shot REST API queries (e.g., /api/3/processlist) or batch mode ('htop -b -n 1'), raw terminal control sequences are stripped, preserving context window tokens.
Q:Does this skill require escalated root or container permissions?
No. The skill evaluates standard user processes and non-privileged hardware counters. Root access is only needed if an agent is explicitly tasked with modifying CPU affinity or killing processes owned by root.
Ready to equip your autonomous agent with Glances & htop Cross-Platform Real-Time Process Monitoring?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.