Glances: Lightweight System Monitoring for Your Self-Hosted Server
You are SSH'd into your server and something feels slow. Is it the CPU? Memory pressure? A runaway Docker container eating all your I/O? You could run top, then free -h, then df -h, then docker stats, then iotop — or you could open one tool that shows everything at once.
Photo by Jack Blueberry on Unsplash
Glances is a cross-platform system monitoring tool written in Python that displays your entire system's health in a single terminal screen or web interface. CPU usage, memory, swap, disk I/O, network throughput, running processes, Docker containers, and more — all updating in real time, color-coded by severity.
It is the htop you wish existed: broader in scope, available as a web UI, and with an API you can hook into Grafana or Home Assistant.
Why Glances Over htop, btop, or Netdata?
The monitoring tool landscape is crowded. Here is where Glances fits:
| Feature | Glances | htop | btop | Netdata |
|---|---|---|---|---|
| CPU/Memory/Disk | Yes | Yes | Yes | Yes |
| Network I/O | Yes | No | Yes | Yes |
| Docker containers | Yes | No | No | Yes |
| Disk I/O per process | Yes | No | No | Yes |
| Web UI | Yes | No | No | Yes |
| REST API | Yes | No | No | Yes |
| Alerts/thresholds | Yes | No | No | Yes |
| Resource footprint | ~50 MB RAM | ~5 MB RAM | ~10 MB RAM | ~200 MB RAM |
| Historical data | Via export | No | No | Built-in |
| Configuration | YAML file | Interactive | Interactive | Web UI |
| Sensors (temp) | Yes | No | Yes | Yes |
Glances occupies the middle ground. It is far more capable than htop or btop (web UI, API, Docker monitoring, alerting) but far lighter than Netdata or a full Prometheus+Grafana stack. If you want a quick, always-available overview of your server without deploying an entire observability platform, Glances is the right choice.
Installing Glances
Option 1: Docker (Recommended)
The Docker deployment gives you the web interface and API with zero system dependencies:
# docker-compose.yml
version: "3.8"
services:
glances:
image: nicolargo/glances:latest-full
container_name: glances
restart: unless-stopped
pid: host
network_mode: host
privileged: true
ports:
- "61208:61208"
environment:
- GLANCES_OPT=-w
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/os-release:/etc/os-release:ro
- ./glances.conf:/etc/glances/glances.conf
A few things to note about this configuration:
pid: hostandprivileged: true: Required so Glances can see all host processes and hardware sensors. Without these, you get an incomplete picture.network_mode: host: Needed for accurate network interface monitoring. Bridge mode only shows container network traffic.- Docker socket mount: Enables the Docker container monitoring panel.
-wflag: Starts the web server on port 61208.
docker compose up -d
Access the web UI at http://your-server:61208.
Option 2: Direct Install
If you prefer running Glances directly on the host (useful for bare-metal servers or VMs without Docker):
# Debian/Ubuntu
sudo apt install glances
# Fedora
sudo dnf install glances
# pip (any platform)
pip install glances[all]
The [all] extra installs optional dependencies for Docker support, web UI, sensors, and export plugins.
Run it in terminal mode:
glances
Or start the web server:
glances -w
Configuration
Glances uses a configuration file that controls thresholds, alerts, and which modules are active. Create glances.conf:
[global]
# Refresh rate in seconds
refresh=2
# Check for updates (disable in air-gapped environments)
check_update=false
[cpu]
# Alert thresholds (percentage)
careful=50
warning=70
critical=90
[mem]
careful=50
warning=70
critical=90
[memswap]
careful=50
warning=70
critical=90
[load]
# Based on number of CPU cores
careful=0.7
warning=1.0
critical=5.0
[fs]
# Filesystem usage thresholds
careful=50
warning=70
critical=90
# Hide specific mount points
hide=/boot.*,/snap.*
[network]
# Hide specific interfaces
hide=lo,docker.*,br-.*,veth.*
[docker]
# Enable Docker monitoring
disable=false
# Show all containers (including stopped)
all=true
[sensors]
# Temperature thresholds (Celsius)
careful=60
warning=70
critical=80
The threshold system is what makes Glances more than a passive display. When CPU hits 70%, the value turns yellow (warning). At 90%, it turns red (critical). This instant visual feedback means you can glance at the screen and immediately know if anything needs attention — hence the name.
Like what you're reading? Subscribe to Self-Hosted Weekly — free weekly guides in your inbox.
The Web Interface
The web UI mirrors the terminal layout but adds interactive features. You can:
- Sort processes by CPU, memory, I/O, or name
- Filter processes by typing a search term
- Toggle panels to show or hide specific metrics
- Switch views between summary, per-CPU, Docker, and more
The interface auto-refreshes every 2 seconds by default. It is intentionally minimal — no flashy charts or graphs, just dense, information-rich panels organized logically.
Key Keyboard Shortcuts (Terminal Mode)
| Key | Action |
|---|---|
1 |
Toggle per-CPU stats |
2 |
Toggle left sidebar |
3 |
Toggle quick look |
d |
Toggle disk I/O |
D |
Toggle Docker container stats |
n |
Toggle network I/O |
s |
Toggle sensors |
t |
Toggle network cumulative/rate |
b |
Toggle network bits/bytes |
f |
Toggle filesystem stats |
e |
Toggle process extended stats |
q |
Quit |
REST API
Glances exposes a full REST API on the same port as the web UI. This is incredibly useful for integrations:
# Get all system stats as JSON
curl http://your-server:61208/api/4/all
# Get CPU usage
curl http://your-server:61208/api/4/cpu
# Get memory info
curl http://your-server:61208/api/4/mem
# Get per-container Docker stats
curl http://your-server:61208/api/4/containers
# Get disk I/O
curl http://your-server:61208/api/4/diskio
# Get network interfaces
curl http://your-server:61208/api/4/network
# Get sensor temperatures
curl http://your-server:61208/api/4/sensors
The API returns clean JSON, making it easy to integrate with scripts, dashboards, or automation tools.
Example: Simple Health Check Script
#!/bin/bash
# Alert if CPU usage exceeds 90%
CPU=$(curl -s http://localhost:61208/api/4/cpu | jq '.total')
if (( $(echo "$CPU > 90" | bc -l) )); then
echo "ALERT: CPU usage at ${CPU}%" | \
curl -d "$(cat -)" ntfy.sh/your-alerts-topic
fi
Exporting Metrics to Grafana
Glances can export metrics to various backends for historical tracking and advanced visualization. The most popular setup is exporting to InfluxDB, which Grafana can then visualize.
Add an export section to your glances.conf:
[influxdb2]
host=influxdb
port=8086
protocol=http
org=homelab
bucket=glances
token=your-influxdb-token-here
Then start Glances with the export flag:
environment:
- GLANCES_OPT=-w --export influxdb2
Alternatively, Glances has a built-in Prometheus endpoint. Add to your configuration:
[prometheus]
host=0.0.0.0
port=9091
prefix=glances
Then add Glances as a Prometheus scrape target:
# prometheus.yml
scrape_configs:
- job_name: 'glances'
static_configs:
- targets: ['your-server:9091']
This gives you full historical metrics in Grafana with minimal effort.
Monitoring Multiple Servers
Glances supports a client-server mode where one instance acts as the central viewer:
On each remote server, run Glances in server mode:
glances -s --bind 0.0.0.0
From your workstation, connect as a client:
glances -c @server1
For a more permanent setup, deploy Glances in web mode on each server and use your dashboard tool (Homepage, Homarr) to display all instances in a single page.
Alerting
Beyond visual threshold indicators, Glances can trigger actions when thresholds are crossed. Configure alert actions in glances.conf:
[alert]
# Minimum duration before triggering (seconds)
min_duration=30
# Minimum interval between alerts (seconds)
min_interval=300
Combine this with the API and a cron job for a lightweight alerting system that does not require a full monitoring stack.
Resource Usage
Glances is impressively light:
| Metric | Value |
|---|---|
| RAM (terminal mode) | 30-50 MB |
| RAM (web mode) | 50-80 MB |
| CPU (idle) | < 1% |
| CPU (active monitoring) | 1-3% |
| Disk | ~100 MB (Docker image) |
Compare this to Netdata (200-400 MB RAM) or a Prometheus+Grafana stack (500 MB+ RAM), and Glances looks very attractive for resource-constrained servers or VMs.
When to Use Something Else
Glances is not the right tool for every situation:
- Need historical dashboards? Use Grafana + Prometheus or Netdata. Glances shows real-time data; historical data requires an export backend.
- Need alerting pipelines? Use Alertmanager or Grafana alerting. Glances alerting is basic.
- Monitoring dozens of servers? Use Prometheus, Zabbix, or Netdata Cloud. Glances client-server mode does not scale well beyond a handful of hosts.
- Need application-level metrics? Use Prometheus with application exporters. Glances monitors system metrics, not application internals.
Final Thoughts
Glances is the Swiss Army knife of system monitoring — not the best at any single thing, but remarkably good at everything it does. For a self-hoster running a few servers, it provides exactly the right amount of monitoring: enough to spot problems, not so much that you spend more time on monitoring than on the things being monitored.
Deploy it alongside your Docker stacks, bookmark the web UI, and you will find yourself reaching for it every time something feels off. It takes thirty seconds to deploy and saves hours of diagnostic ssh-and-grep sessions.
