$devvkit learn --librarie glances-guide
Glances Guide
[monitoring][system][web-ui][python]
System Monitoring
Install
pip install glances # or: uv add glances brew install glances sudo apt install glances
Glances is an all-in-one system monitor that shows CPU, memory, disk, network, processes, sensors (temperature/fan), Docker containers, and logged-in users — all in a single TUI screen. It auto-refreshes every 2 seconds.
Run `glances -w` to start the web UI on port 61208 — a full dashboard accessible from any browser. `glances -s` starts an XML-RPC server for remote monitoring; connect with `glances -c <server>` from another machine.
Glances exports to CSV, JSON, or InfluxDB. Use `--export influxdb` to push metrics to InfluxDB + Grafana. The `--process-short-name` flag shortens process names. For lightweight monitoring, use htop; for historical graphs, pair Glances + InfluxDB.
Terminal
Terminal mode— Default TUI dashboard.
glances # Navigation: # 1: CPU / 2: MEM / 3: SWAP / 4: NET / 5: DISK / 6: SENSORS # a: auto-sort / e: export / w: web / q: quit # /: search in process list
Trick: alert config— Set thresholds with alerts.
# ~/.config/glances/glances.conf [alerts] cpu_warning=80 cpu_critical=95 mem_warning=85 mem_critical=95 # Glances will color-code and show alert counts # In web UI: alerts appear as notification badges
Web UI
Web UI— Browser-based dashboard.
glances -w # Web UI on port 61208 glances -w -p 8080 # Custom port glances -w -P mypassword # Password-protected # Open http://localhost:61208 in browser
Remote
Remote monitoring— Server + client.
# On server: glances -s -B 0.0.0.0 -p 61209 # Server mode # On client: glances -c server-ip -p 61209 # Connect to server # With password: glances -s -P secret # then client: glances -c server-ip --password secret
Export
CSV export— Log to CSV.
glances --export csv --export-csv-file /var/log/glances.csv # Columns: timestamp, cpu, mem, net, disk, sensors, process count # Import to Excel or Pandas for analysis
JSON output— One-shot JSON for scripts.
glances --stdout json --disable-checkup | jq '.
# Get specific metrics:
glances --stdout json | jq '.cpu.total'
glances --stdout json | jq '{cpu: .cpu, mem: .mem.percent, net: .network_io}'InfluxDB + Grafana— Time-series export.
glances --export influxdb \ --influxdb-host localhost \ --influxdb-port 8086 \ --influxdb-db glances \ --influxdb-password mypass # Then configure Grafana datasource = InfluxDB # Dashboard: import Glances dashboard ID from grafana.com
Docker
Docker containers— Monitor Docker in Glances.
glances --docker # Show Docker containers in process list # Or run Glances in a container: docker run -d --restart="always" -p 61208:61208 \ -e GLANCES_OPT="-w" \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ --pid host \ nicolargo/glances:latest