Projects /Β rtop

git clone https://molodetz.nl/retoor/rtop.git

Files

rtop

Author: retoor retoor@molodetz.nl

A terminal-based system monitoring tool written in C that displays comprehensive system statistics in a tabbed, auto-refreshing interface. rtop is designed as a lightweight alternative to htop with no external dependencies beyond the standard C library.

Features

  • Tabbed interface with 5 dedicated views (CPU, Memory, Network, Disk, Process)
  • Real-time system monitoring with configurable refresh interval
  • Auto-rotate tabs at configurable interval
  • Pause mode for copy/paste operations
  • Per-core CPU utilization with temperature and frequency display
  • Memory and swap usage statistics with task summary
  • Process listing sorted by CPU or memory usage
  • Network interface statistics with RX/TX rates and IP addresses
  • Disk I/O statistics with IOPS
  • Filesystem usage information
  • Color-coded progress bars for utilization levels
  • Terminal resize handling

Requirements

  • Linux operating system
  • GCC compiler (C99 compliant)
  • Make build system

Building

make

The build produces a single binary rtop with minimal dependencies.

Build Options

make clean      # Remove build artifacts
make debug # Build with debug symbols
make install # Install to /usr/local/bin (requires root)

Usage

./rtop [OPTIONS]

Options:
-d, --delay SECS Update interval in seconds (default: 1.0)
-r, --rotate SECS Auto-rotate tabs every SECS seconds (0=off, default: 0)
-s, --sort MODE Sort by: cpu (default), mem
-h, --help Show help message
-v, --version Show version

Examples

./rtop              # Run with default settings
./rtop -d 2 # Update every 2 seconds
./rtop -r 5 # Auto-rotate tabs every 5 seconds
./rtop -s mem # Sort processes by memory usage
./rtop -d 0.5 -r 3 # Fast refresh with 3-second tab rotation

Tabs

| Tab | Content | |-----|---------| | CPU | Per-core utilization bars, temperature, frequency, total usage | | Memory | RAM/Swap usage, buffers/cache, task summary (running, sleeping, stopped, zombie) | | Network | Interface list with IP addresses, RX/TX rates, total bytes transferred | | Disk | Per-device I/O rates, IOPS, filesystem mount points with usage | | Process | Detailed process list with PID, user, CPU%, MEM%, command |

Controls

| Key | Action | |-----|--------| | Left/Right arrows | Switch between tabs | | 1-5 | Jump directly to tab | | ESC | Pause refresh (for copy/paste) | | q / Q | Quit the application | | Ctrl+C | Terminate |

Technical Details

Data Sources

All system information is read from the Linux /proc and /sys filesystems:

| Source | Information | |--------|-------------| | /proc/stat | CPU statistics | | /proc/meminfo | Memory information | | /proc/[pid]/stat | Process information | | /proc/net/dev | Network statistics | | /proc/diskstats | Disk I/O statistics | | /sys/class/thermal/ | Temperature sensors | | /sys/devices/system/cpu/ | CPU frequency |

Performance

  • Target CPU usage: <5%
  • Startup time: <100ms
  • Memory footprint: <10MB RSS

Project Structure

rtop/
β”œβ”€β”€ include/
β”‚ β”œβ”€β”€ cpu.h
β”‚ β”œβ”€β”€ disk.h
β”‚ β”œβ”€β”€ display.h
β”‚ β”œβ”€β”€ filesystem.h
β”‚ β”œβ”€β”€ memory.h
β”‚ β”œβ”€β”€ network.h
β”‚ β”œβ”€β”€ process.h
β”‚ β”œβ”€β”€ system.h
β”‚ └── terminal.h
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ cpu.c
β”‚ β”œβ”€β”€ disk.c
β”‚ β”œβ”€β”€ display.c
β”‚ β”œβ”€β”€ filesystem.c
β”‚ β”œβ”€β”€ main.c
β”‚ β”œβ”€β”€ memory.c
β”‚ β”œβ”€β”€ network.c
β”‚ β”œβ”€β”€ process.c
β”‚ β”œβ”€β”€ system.c
β”‚ └── terminal.c
β”œβ”€β”€ Makefile
└── README.md

License

This project is provided as-is for educational and personal use.

Files

  • CHANGELOG.md 768 B raw
  • Makefile 705 B raw
  • README.md 3.7 KB raw
  • include
  • src