Skip to content

Glances Cheatsheet

Installation

Platform Command
Ubuntu/Debian sudo apt update && sudo apt install glances
RHEL/CentOS/Fedora sudo dnf install glances or sudo yum install epel-release && sudo yum install glances
Arch Linux sudo pacman -S glances
macOS (Homebrew) brew install glances
Windows (pip) pip install glances
Windows (Chocolatey) choco install glances
Docker docker pull nicolargo/glances
Python pip (all platforms) pip3 install glances
With all features pip3 install 'glances[all]'
From source git clone https://github.com/nicolargo/glances.git && cd glances && python setup.py install

Basic Commands

Command Description
glances Launch glances with default settings
glances -t 5 Set refresh interval to 5 seconds
glances -V Display version information
glances --help Show help and available options
glances --percpu Show per-CPU statistics by default
glances --process-short-name Show only active processes with short names
glances --process-filter="python" Filter processes by name (e.g., "python")
glances --process-filter="user:nginx" Show processes for specific user
glances --theme-white Use white theme (black background)
glances --disable-bg Disable background colors
glances --fahrenheit Display temperature in Fahrenheit instead of Celsius
glances --byte Display network rate in bytes per second
glances --process-max 50 Limit displayed processes to 50
glances --no-kernel-threads Hide kernel threads from process list
glances --disable-bold Disable bold text in interface

Interactive Keyboard Shortcuts

Key Description
q or ESC Quit glances
h Display help screen
c Sort processes by CPU usage
m Sort processes by memory usage
p Sort processes by process name
i Sort processes by I/O rate
t Sort processes by process time
u Sort processes by user
k Kill selected process (requires confirmation)
r Renice (change priority) selected process
1 Toggle between global CPU and per-CPU statistics
d Show/hide disk I/O stats
f Show/hide filesystem stats
n Show/hide network stats
s Show/hide sensors
2 Show/hide left sidebar
z Show/hide processes list
b Toggle network rate between bits/s and bytes/s
w Delete warning logs
x Delete warning and critical logs
D Show/hide Docker containers
T Toggle process tree view
UP/DOWN Navigate through process list
SPACE Tag/untag process for bulk operations

Advanced Usage

Command Description
glances -s Start in server mode (default port 61209)
glances -s -p 8080 Start server on custom port 8080
glances -s --password Start server with password authentication
glances -s -B 192.168.1.100 Bind server to specific IP address
glances -c 192.168.1.100 Connect to remote glances server
glances -c 192.168.1.100 -p 8080 Connect to server on custom port
glances -w Start web server mode (default port 61208)
glances -w --port 8080 Start web server on custom port
glances -w --username admin --password secret Web server with authentication
glances -w -B 0.0.0.0 Make web server accessible from all interfaces
glances --docker Enable Docker container monitoring
glances --export csv --export-csv-file /tmp/glances.csv Export metrics to CSV file
glances --export influxdb Export metrics to InfluxDB
glances --export prometheus Export metrics for Prometheus scraping
glances --export json --export-json-file /tmp/glances.json Export metrics to JSON file
glances --disable-plugin cpu,mem Disable specific plugins
glances --snmp-community public Start SNMP server mode
glances -c 192.168.1.100 --snmp-version 2c --snmp-community public Connect via SNMP
glances --logfile /var/log/glances.log Log output to file
glances --debug Enable debug logging

Docker Usage

Run Glances in Docker Container

# Basic container with web interface
docker run -d --restart="always" \
  -p 61208-61209:61208-61209 \
  -e GLANCES_OPT="-w" \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  --pid host \
  nicolargo/glances

# With custom configuration file
docker run -d \
  -v /path/to/glances.conf:/glances/conf/glances.conf \
  -p 61208-61209:61208-61209 \
  -e GLANCES_OPT="-w" \
  nicolargo/glances

# Server mode only
docker run -d \
  -p 61209:61209 \
  -e GLANCES_OPT="-s" \
  --pid host \
  nicolargo/glances

Configuration

Glances uses a configuration file located at: - Linux: ~/.config/glances/glances.conf or /etc/glances/glances.conf - macOS: ~/Library/Application Support/glances/glances.conf - Windows: %APPDATA%\glances\glances.conf

Basic Configuration Example

[global]
# Refresh rate in seconds
refresh=2
# Check for updates
check_update=false

[cpu]
# CPU thresholds (%)
careful=50
warning=70
critical=90

[mem]
# Memory thresholds (%)
careful=50
warning=70
critical=90

[memswap]
# Swap thresholds (%)
careful=50
warning=70
critical=90

[load]
# Load average thresholds (per CPU)
careful=0.7
warning=1.0
critical=5.0

[network]
# Hide network interfaces
hide=lo,docker.*
# Show cumulative values
cumulative=False

[diskio]
# Hide disk devices
hide=loop.*,/dev/loop.*

[fs]
# Hide filesystems
hide=/boot.*,/snap.*
# Careful threshold (%)
careful=50
warning=70
critical=90

[folders]
# Monitor specific folders
folder_1_path=/home
folder_1_careful=2500
folder_1_warning=3000
folder_1_critical=3500

[sensors]
# Temperature thresholds (Celsius)
temperature_core_careful=60
temperature_core_warning=70
temperature_core_critical=80

[processlist]
# CPU thresholds for processes (%)
cpu_careful=50
cpu_warning=70
cpu_critical=90
# Memory thresholds for processes (%)
mem_careful=50
mem_warning=70
mem_critical=90

[docker]
# Enable Docker monitoring
disable=False
# Maximum containers to display
max_name_size=20

Web Server Configuration

[outputs]
# Export to CSV
export_csv_file=/tmp/glances.csv
export_csv_overwrite=False

# Export to InfluxDB
export_influxdb=True
influxdb_host=localhost
influxdb_port=8086
influxdb_user=root
influxdb_password=root
influxdb_db=glances

# Export to Prometheus
export_prometheus=True
prometheus_port=9091
prometheus_prefix=glances

[serverlist]
# Remote servers to monitor
server_1_name=prod-server-1
server_1_alias=Production 1
server_1_host=192.168.1.100
server_1_port=61209
server_2_name=prod-server-2
server_2_alias=Production 2
server_2_host=192.168.1.101
server_2_port=61209

RESTful API Usage

API Endpoints

Endpoint Description
GET /api/3/status Get server status
GET /api/3/config Get server configuration
GET /api/3/all Get all stats in JSON format
GET /api/3/cpu Get CPU statistics
GET /api/3/mem Get memory statistics
GET /api/3/memswap Get swap memory statistics
GET /api/3/load Get load average
GET /api/3/network Get network statistics
GET /api/3/diskio Get disk I/O statistics
GET /api/3/fs Get filesystem statistics
GET /api/3/processlist Get process list
GET /api/3/sensors Get sensors data
GET /api/3/docker Get Docker containers stats
GET /api/3/processlist/pid/<pid> Get specific process info

API Examples

# Get CPU stats
curl http://localhost:61208/api/3/cpu

# Get memory stats
curl http://localhost:61208/api/3/mem

# Get all stats
curl http://localhost:61208/api/3/all

# Get specific process
curl http://localhost:61208/api/3/processlist/pid/1234

# Pretty print JSON output
curl http://localhost:61208/api/3/cpu | python -m json.tool

# Get stats with authentication
curl -u admin:secret http://localhost:61208/api/3/cpu

Common Use Cases

Use Case 1: Remote Server Monitoring

Monitor multiple servers from a central location:

# On remote servers (run as service)
glances -s -B 0.0.0.0 --password

# On monitoring station
glances -c server1.example.com --password yourpassword

# Or use web interface
glances -w -B 0.0.0.0 --username admin --password secret
# Access via browser: http://server:61208

Use Case 2: Export Metrics to InfluxDB and Grafana

Set up continuous monitoring with visualization:

# Start glances with InfluxDB export
glances --export influxdb \
  --influxdb-host localhost \
  --influxdb-port 8086 \
  --influxdb-user admin \
  --influxdb-password secret \
  --influxdb-db glances

# Or configure in glances.conf and run as daemon
glances --quiet --export influxdb

Configure Grafana to use InfluxDB as data source and create dashboards.

Use Case 3: Docker Container Monitoring

Monitor Docker containers alongside system metrics:

# Enable Docker monitoring
glances --docker

# Docker-only view (hide processes)
glances --docker --disable-process

# Export Docker stats to Prometheus
glances --docker --export prometheus --prometheus-port 9091

# Web interface with Docker stats
glances -w --docker

Use Case 4: Troubleshooting High CPU Usage

Identify and analyze resource-intensive processes:

# Start glances with focus on CPU
glances --percpu

# Interactive steps:
# 1. Press 'c' to sort by CPU usage
# 2. Press '1' to see per-CPU breakdown
# 3. Press 'T' to view process tree
# 4. Navigate to problematic process
# 5. Press 'k' to kill if needed

# Export data for analysis
glances --export csv --export-csv-file /tmp/cpu-analysis.csv -t 1

Use Case 5: Automated Monitoring Script

Create a monitoring script with alerts:

#!/bin/bash
# monitor.sh - Check system health via Glances API

# Start glances web server in background
glances -w --quiet &
GLANCES_PID=$!
sleep 5

# Check CPU usage
CPU_USAGE=$(curl -s http://localhost:61208/api/3/cpu | \
  python -c "import sys, json; print(json.load(sys.stdin)['total'])")

if (( $(echo "$CPU_USAGE > 80" | bc -l) )); then
    echo "ALERT: CPU usage is ${CPU_USAGE}%"
    # Send notification or alert
fi

# Check memory usage
MEM_USAGE=$(curl -s http://localhost:61208/api/3/mem | \
  python -c "import sys, json; print(json.load(sys.stdin)['percent'])")

if (( $(echo "$MEM_USAGE > 90" | bc -l) )); then
    echo "ALERT: Memory usage is ${MEM_USAGE}%"
fi

# Cleanup
kill $GLANCES_PID

Best Practices

  • Use configuration files instead of command-line options for permanent settings to maintain consistency across sessions and make configurations version-controllable

  • Set appropriate refresh intervals - Use 2-5 seconds for interactive monitoring, 10-30 seconds for background monitoring to balance responsiveness with system load

  • Filter unnecessary information - Hide irrelevant network interfaces, disk devices, and filesystems to reduce clutter and focus on important metrics

  • Implement authentication for remote monitoring and web interfaces to prevent unauthorized access to system information, especially in production environments

  • Export to time-series databases like InfluxDB or Prometheus for long-term trend analysis, capacity planning, and historical troubleshooting

  • Run as a systemd service on Linux servers for automatic startup and monitoring continuity across reboots

  • Monitor Docker containers when running containerized workloads to track resource usage per container and identify resource-hungry applications

  • Use color thresholds wisely - Configure careful/warning/critical thresholds based on your system's normal operating ranges to avoid alert fatigue

  • Leverage the API for automation and integration with existing monitoring systems, alerting tools, or custom dashboards

  • Keep glances updated - Regularly update to get new features, performance improvements, and security patches

Troubleshooting

Issue Solution
glances: command not found Ensure glances is installed and in PATH. Try pip3 install --user glances and add ~/.local/bin to PATH
High CPU usage by glances itself Increase refresh interval with -t 5 or higher. Disable unused plugins with --disable-plugin
Cannot connect to remote server Check firewall rules allow port 61209. Verify server is running with glances -s. Test connectivity with telnet server 61209
Web interface not accessible Ensure glances started with -w flag. Check if port 61208 is available with netstat -tulpn \| grep 61208. Bind to all interfaces with -B 0.0.0.0
Docker containers not showing Verify Docker socket is accessible: ls -l /var/run/docker.sock. Run glances with appropriate permissions or add user to docker group
Permission denied errors Run with sudo for full system access, or adjust permissions for specific resources. Some features require root privileges
Sensors not displaying Install lm-sensors package and run sensors-detect. Install Python sensors library: pip3 install py3sensors
InfluxDB export not working Verify InfluxDB is running and accessible. Check credentials and database name. Install InfluxDB client: pip3 install influxdb
Missing GPU information Install NVIDIA monitoring library: pip3 install nvidia-ml-py3. Ensure NVIDIA drivers are installed and working
Config file changes not applied Verify config file location with glances --version. Check file syntax. Restart glances after configuration changes
Process list incomplete Increase process limit with --process-max 0 for unlimited. Check if kernel threads are hidden with --no-kernel-threads
Unicode/display issues in terminal Set proper locale: export LANG=en_US.UTF-8. Use --disable-unicode flag if terminal doesn't support Unicode

Optional Dependencies

Install these packages for enhanced functionality:

# Docker monitoring
pip3 install docker

# GPU monitoring (NVIDIA)
pip3 install nvidia-ml-py3

# Sensors support (Linux)
pip3 install py3sensors

# Web interface
pip3 install bottle

# InfluxDB export
pip3 install influxdb influxdb-client

# Prometheus export
pip3 install prometheus_client

# Elasticsearch export
pip3 install elasticsearch

# StatsD export
pip3 install statsd

# IP geolocation
pip3 install geoip2

# All optional features
pip3 install 'glances[all]'