Skip to content

Rust-Dashboard is a cross-platform system monitoring tool built with sysinfo and eframe/egui. It tracks CPU, memory, disk, and network usage in real time, showing top processes by CPU and memory consumption.

Notifications You must be signed in to change notification settings

Technical-1/Rust-Dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rust-Dashboard

A comprehensive cross-platform system monitoring dashboard built with sysinfo and eframe/egui. Features real-time system statistics, historical data visualization, process management, and extensive customization options.

Features

Core Monitoring

  • CPU Monitoring: Global CPU usage with per-core breakdown
  • Memory Monitoring: Detailed memory statistics (used, free, total, available, swap) with visual progress bars
  • Disk Monitoring: Per-disk usage statistics with mount points and file systems
  • Network Monitoring: Per-interface network statistics with human-readable formatting (KB/MB/GB)
  • Process Management: Comprehensive process list with search, filter, and management capabilities

Advanced Features

  • Historical Data & Charts: Time-series visualization of CPU and memory usage trends using egui_plot
  • Process Search & Filter: Real-time filtering by name, CPU threshold, and memory threshold
  • Process Details: Expandable process information showing command line, start time, parent PID
  • Process Actions: Kill/terminate processes with confirmation dialogs
  • Per-CPU Display: Individual CPU core usage percentages with progress bars
  • Color-Coded Thresholds: Visual indicators (πŸŸ’πŸŸ‘πŸ”΄) for CPU and memory usage levels
  • Theme Support: Dark and light themes with persistence
  • Window Persistence: Saves and restores window size and position
  • Export Functionality: Export system statistics to JSON or CSV format
  • Configuration File: Persistent settings via config.toml file
  • Manual Refresh: On-demand refresh button with last refresh timestamp
  • Sortable Process Tables: Click column headers to sort processes by name, CPU%, or memory

Performance Optimizations

  • Conditional repainting (only when data changes)
  • Optimized process list sorting (no unnecessary cloning)
  • Minimized mutex lock duration for better concurrency
  • Synchronized refresh intervals between UI and background thread

Architecture

Core Components

  • src/system.rs: Contains the SystemMonitor struct which wraps sysinfo::System, providing methods for querying CPU, memory, disk, network, and process information
  • src/main.rs: The main application using RustDashboardApp, which:
    • Spawns a background thread to refresh system data
    • Renders a GUI using eframe/egui
    • Manages UI state, historical data, and user interactions
  • src/config.rs: Configuration management module for persistent settings
  • src/error.rs: Custom error types using thiserror for better error handling
  • src/lib.rs: Library exports for using SystemMonitor as a library

Data Flow

  1. Background thread periodically refreshes SystemMonitor data
  2. UI thread reads latest data from SystemMonitor (with minimal lock duration)
  3. Historical data stored in VecDeque for chart visualization
  4. User interactions (search, filter, sort) applied to process lists
  5. Configuration persisted to config.toml on changes

Requirements

  • Rust 1.60+ (2024 edition)
  • Dependencies (automatically managed by Cargo):
    • sysinfo = "0.33.1"
    • eframe = "0.31.1" (with wgpu feature)
    • log = "0.4" and env_logger = "0.11" for logging
    • thiserror = "1.0" for error handling
    • egui_plot = "0.31" for charts
    • serde = "1.0" and serde_json = "1.0" for export
    • csv = "1.3" for CSV export
    • toml = "0.8" and dirs = "5.0" for configuration

Installation

  1. Clone or download this repository:

    git clone <repository-url>
    cd Rust-Dashboard
  2. Build and run:

    cargo run

    This will compile and launch the dashboard.

  3. For release build (optimized):

    cargo build --release
    ./target/release/Rust-Dashboard

Usage

Basic Usage

The dashboard automatically starts monitoring your system. Use the controls in the top panel:

  • Refresh Interval: Select how often data refreshes (1s, 2s, 5s, 10s, 15s, 30s)
  • Manual Refresh: Click the πŸ”„ button to refresh immediately
  • Theme Toggle: Switch between dark (πŸŒ™) and light (β˜€οΈ) themes
  • Last Refresh: See when data was last updated

Process Management

  1. Search Processes: Type in the search box to filter by process name
  2. Filter by Threshold: Use sliders to filter by CPU% or Memory (MB)
  3. View Details: Click on a process name to expand and see details (command, start time, parent PID)
  4. Sort Processes: Click column headers (Name, CPU%, Memory MB) to sort
  5. Kill Process: Click "Kill" button and confirm in the dialog

Exporting Data

Click "πŸ“₯ Export to JSON" or "πŸ“₯ Export to CSV" to export current system statistics. Data includes:

  • CPU usage
  • Memory statistics
  • Process list with CPU and memory usage
  • Timestamp

Configuration

Settings are automatically saved to config.toml in your platform's config directory:

  • macOS: ~/Library/Application Support/rust-dashboard/config.toml
  • Linux: ~/.config/rust-dashboard/config.toml
  • Windows: %APPDATA%\rust-dashboard\config.toml

Settings include:

  • Refresh interval
  • Theme preference
  • Window size and position

Logging

Control log verbosity using the RUST_LOG environment variable:

# Debug level (most verbose)
RUST_LOG=debug cargo run

# Info level (default)
RUST_LOG=info cargo run

# Warning and errors only
RUST_LOG=warn cargo run

Using as a Library

The SystemMonitor can be used as a library:

use rust_dashboard_lib::system::SystemMonitor;

let mut monitor = SystemMonitor::new();
monitor.refresh();

let cpu_usage = monitor.global_cpu_usage();
let (used, free, total, avail, swap_used, swap_total) = monitor.memory_info();
let processes = monitor.combined_process_list();

See examples/basic_usage.rs for a complete example.

Running Examples

# Run the basic usage example
cargo run --example basic_usage

Testing

Run all tests:

cargo test

Test coverage includes:

  • System monitoring functionality
  • Configuration management
  • Export functionality
  • Process management
  • Concurrent access patterns
  • Edge cases and error conditions

Building

Development Build

cargo build

Release Build (Optimized)

cargo build --release

Release builds include:

  • Maximum optimization (opt-level = 3)
  • Link-time optimization (LTO)
  • Stripped binaries for smaller size

CI/CD

The project includes GitHub Actions CI/CD pipeline (.github/workflows/ci.yml) that:

  • Runs tests on push/PR
  • Builds for Linux, macOS, and Windows
  • Checks code formatting
  • Runs clippy lints

Project Structure

Rust-Dashboard/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs          # Main application and UI
β”‚   β”œβ”€β”€ lib.rs           # Library exports
β”‚   β”œβ”€β”€ system.rs        # System monitoring logic
β”‚   β”œβ”€β”€ config.rs        # Configuration management
β”‚   └── error.rs         # Custom error types
β”œβ”€β”€ examples/
β”‚   └── basic_usage.rs   # Example usage
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_system.rs   # System tests
β”‚   β”œβ”€β”€ test_config.rs   # Config tests
β”‚   β”œβ”€β”€ test_export.rs   # Export tests
β”‚   └── test_process_actions.rs  # Process action tests
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml       # CI/CD pipeline
β”œβ”€β”€ Cargo.toml           # Dependencies and build config
└── README.md            # This file

Key Improvements (v1.1.0)

Code Quality

  • βœ… Proper logging system replacing debug prints
  • βœ… Comprehensive error handling with custom error types
  • βœ… Synchronized refresh intervals between UI and background thread
  • βœ… Consistent memory unit display (GiB)

Performance

  • βœ… Optimized process list sorting (no cloning)
  • βœ… Conditional repainting (only when data changes)
  • βœ… Minimized mutex lock duration

Features

  • βœ… Historical data visualization with charts
  • βœ… Process search and filtering
  • βœ… Human-readable network statistics
  • βœ… Expandable process details
  • βœ… Process kill/terminate with confirmation
  • βœ… Dark/light theme support
  • βœ… Window persistence
  • βœ… JSON/CSV export
  • βœ… Per-CPU usage display
  • βœ… Color-coded thresholds
  • βœ… Configuration file support

Testing

  • βœ… Expanded test coverage (41 tests)
  • βœ… Tests for error conditions and edge cases
  • βœ… Concurrent access tests
  • βœ… Integration tests

UI/UX

  • βœ… Grid layout for better organization
  • βœ… Visual progress bars
  • βœ… Sortable process tables
  • βœ… Manual refresh with timestamp
  • βœ… Visual health status indicators

Limitations

  • Disk I/O Statistics: Not available in sysinfo 0.33.1. The Disk API only provides space information, not read/write speeds or I/O operations per second.
  • Process Termination: The terminate() method is not available in sysinfo. Only kill() (SIGKILL) is supported.

Contributing

Contributions are welcome! Please ensure:

  • Code follows Rust style guidelines
  • All tests pass (cargo test)
  • Code is formatted (cargo fmt)
  • No clippy warnings (cargo clippy)

License

[Add your license here]

Acknowledgments

About

Rust-Dashboard is a cross-platform system monitoring tool built with sysinfo and eframe/egui. It tracks CPU, memory, disk, and network usage in real time, showing top processes by CPU and memory consumption.

Topics

Resources

Stars

Watchers

Forks

Languages