Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AndPuQing/iotop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iotop - Rust Implementation

A modern, high-performance Rust implementation of iotop - a tool to monitor I/O usage of processes on Linux.

GitHub Actions Workflow Status Crates.io Version Crates.io Downloads (recent) dependency status Crates.io License Crates.io Size

Snapshot

Installation

From Cargo (Recommended)

Install directly from crates.io:

cargo install iotop

From Source

Clone and build from source:

git clone https://github.com/AndPuQing/iotop.git
cd iotop
cargo build --release

The binary will be available at ./target/release/iotop.

System-wide Installation

Option 1: Copy binary to system path

cargo build --release
sudo cp target/release/iotop /usr/local/bin/
sudo cp doc/iotop.8 /usr/share/man/man8/
sudo mandb  # Update man page database

Option 2: Using cargo install with prefix

cargo install --path . --root /usr/local
sudo cp doc/iotop.8 /usr/share/man/man8/
sudo mandb

Permissions Setup

iotop requires root privileges to access the kernel's taskstats interface. You have two options:

Option 1: Run with sudo (simplest)

sudo iotop

Option 2: Grant CAP_NET_ADMIN capability (no sudo needed)

# Allow iotop to run without sudo by granting the required capability
sudo setcap cap_net_admin+eip /usr/local/bin/iotop

# Now you can run without sudo
iotop

Enable Kernel Delay Accounting

For full functionality (SWAPIN and IO columns), enable kernel delay accounting:

# Temporary (until reboot)
sudo sysctl -w kernel.task_delayacct=1

# Permanent (survives reboot)
echo "kernel.task_delayacct = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Usage

Basic Examples

Run interactively:

sudo iotop

Show only processes doing I/O:

sudo iotop -o

Run in batch mode (5 iterations, 2 second delay):

sudo iotop -b -n 5 -d 2

Monitor specific process:

sudo iotop -p 1234

Monitor user's processes:

sudo iotop -u www-data

Batch mode with timestamps:

sudo iotop -t -b -n 10 > iotop.log

Command-Line Options

Option Long Form Description
-o --only Only show processes or threads actually doing I/O
-P --processes Show processes instead of all threads
-a --accumulated Show accumulated I/O instead of bandwidth
-d --delay Delay between iterations in seconds [default: 1.0]
-n --iterations Number of iterations before ending (infinite if not specified)
-b --batch Batch mode (non-interactive)
-p --pid Monitor specific processes/threads (can be repeated)
-u --user Monitor processes by username or UID (can be repeated)
-t --time Add timestamp on each line (implies --batch)
-q --quiet Suppress column names and headers (implies --batch)
-k --kilobytes Use kilobytes instead of human-friendly units

Interactive Mode Controls

When running in interactive mode (default), you can use the following keyboard shortcuts:

Key Action
q / Q / Ctrl+C Quit the program
o / O Toggle showing only processes doing I/O
a / A Toggle between bandwidth and accumulated I/O
p / P Toggle between showing processes and threads
r / R Reverse the current sort order
Space Pause/resume display updates
Left / Right Cycle through sort columns
Up / Down Scroll through process list
PageUp / PageDown Scroll by 10 rows
Home Jump to first sort column (or first row with Ctrl)
End Jump to last sort column (or last row with Ctrl)

Mouse wheel scrolling is also supported for navigating the process list.

Architecture

This implementation uses:

  • Netlink Taskstats: Interfaces with the Linux kernel's taskstats interface via netlink sockets
  • Procfs: Reads process information from /proc filesystem
  • Async/Await: Tokio-based async runtime for concurrent data collection
  • TUI Framework: Crossterm + Ratatui for terminal rendering

Development

Run the project in development mode:

# Build and run
cargo run -- [options]

# Build in release mode
cargo build --release

# Run tests
cargo test

# Check for issues
cargo clippy

# Format code
cargo fmt

# Run with custom options
cargo run -- -o -d 2

License

MIT License - See LICENSE file for details.

References

Contributing

Contributions are welcome! This is an ongoing migration project. Areas for contribution include:

  • Additional test coverage
  • Performance optimizations
  • Documentation improvements
  • Bug fixes and feature requests

Please open an issue or pull request on GitHub.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •