Terminal GuideTerminal Guide

dstat

System Monitoring
Linux
Python

Versatile resource statistics tool.

Official Website

Features

Real-timePluginsCSV ExportCustomizable

Installation

APT (Debian/Ubuntu)
apt install dstat
Pacman (Arch)
pacman -S dstat
DNF (Fedora)
dnf install dstat

Why Use dstat?

Real-Time Versatility

Monitor CPU, memory, disk I/O, network, and more in real-time with a single command and customizable output.

Flexible Plugin System

Extend functionality with plugins for system-specific metrics, temperature monitoring, SMART data, and more.

CSV Export & Integration

Export data in CSV format for integration with other tools, spreadsheets, and custom analysis scripts.

Customizable Output

Choose which metrics to display, adjust update intervals, and format output for specific needs.

Basic Usage

basic-usage
# Default monitoring (CPU, disk, net, page, load)
dstat

# Monitor with 2-second intervals
dstat -t -v

# Show specific metrics
dstat --cpu --mem --disk --net

# Monitor for a specific duration (10 iterations)
dstat 1 10

# Specify update interval (in seconds)
dstat -T -s 2 5

# Show all available metrics
dstat --list

# Get help
dstat -h

Common Options

OptionDescription
-c, --cpuShow CPU stats (user, system, idle, wait)
-m, --memShow memory stats (used, free, buffer, cache)
-d, --diskShow disk I/O stats (read, write)
-n, --netShow network stats (send, receive)
-p, --procShow process stats (runnable, uninterruptible)
-l, --loadShow load average
-t, --timeInclude timestamp in output
-T, --epochShow epoch timestamp
--output FILEWrite output to CSV file

Practical Examples

1. Monitor Everything with Timestamps

example-full-monitoring
# Full system monitoring with timestamps
dstat -tcmlpnd

# Output includes:
# Time, CPU, Memory, Load, Process, Network, Disk

2. Focus on Disk I/O

example-disk-io
# Monitor disk I/O performance
dstat -d --disk-util --disk-tps

# Output shows:
# Disk read/write, utilization, and transactions per second

3. Focus on Network Traffic

example-network
# Monitor network performance
dstat -n --net

# Or monitor per-interface
dstat --net -i eth0

# Check all interfaces
dstat --net --net-packets

4. Memory and Swap Monitoring

example-memory
# Focus on memory usage
dstat -m --mem-adv

# Include swap statistics
dstat -m -s --swap

5. Export to CSV for Analysis

example-csv-export
# Collect data to CSV file (10 samples, 2-second intervals)
dstat -tcmlpnd --output monitoring.csv 2 10

# Run in background and collect for extended period
nohup dstat -tcmlpnd --output monitoring.csv 1 > /dev/null 2>&1 &

# Convert to CSV for Excel or analysis tools
dstat -t --csv --output data.csv 1 100

Plugins & Extended Metrics

Discovering Available Plugins

plugins-list
# List all available plugins
dstat --list

# List only available modules
dstat --list | grep -E "^(internal|external)"

# Typical built-in modules:
# --cpu, --mem, --disk, --net, --proc, --load, --page
# --ipc, --lock, --raw, --socket, --tcp, --udp, --unix, --filesystem

Using Advanced Plugins

plugins-usage
# Monitor filesystem usage
dstat --filesystem

# Monitor TCP connections
dstat --tcp

# Monitor temperature (if available)
dstat --temp

# Monitor battery status
dstat --battery

# Combine multiple plugins
dstat -t --cpu --mem --disk --net --tcp --udp

Comparison with Similar Tools

vs. top/htop

dstat shows system-wide metrics (CPU, disk, network) while top/htop focus on processes. dstat is better for infrastructure monitoring.

vs. iostat

dstat provides more comprehensive metrics including network and memory, while iostat specializes in disk I/O only.

vs. vmstat

dstat is more user-friendly with better formatting. vmstat is lighter on resources and available on more systems by default.

vs. glances

glances provides a more comprehensive all-in-one dashboard with a web interface, while dstat excels at streaming metrics to CSV for scripted analysis.

Tips

1. Create Monitoring Scripts

Wrap dstat in shell scripts to automate data collection with consistent parameters and store results for trend analysis.

2. Use Aliases for Common Monitoring Profiles

Create bash aliases for your most common dstat commands to save typing and ensure consistency.

3. Combine with Log Rotation

When using CSV output, configure logrotate to manage large CSV files and prevent disk space issues.

4. Monitor Specific Devices

Use -D option to focus on specific devices: dstat -D sda,sdb for selective disk monitoring.

5. Integrate with Monitoring Systems

Use dstat's CSV output with tools like Prometheus, InfluxDB, or custom monitoring dashboards for historical analysis.

Written by Dai AokiPublished: 2026-01-20

Related Articles

Explore More