5 releases
new 0.1.5 | Dec 4, 2024 |
---|---|
0.1.4 | Dec 4, 2024 |
0.1.3 | Dec 3, 2024 |
0.1.2 | Dec 3, 2024 |
0.1.0 | Dec 3, 2024 |
#215 in Filesystem
445 downloads per month
10KB
114 lines
riscv_sys_monitor
riscv_sys_monitor is a lightweight, real-time system monitoring tool for RISC-V single-board computers (SBCs) running Linux. It provides insights into CPU usage, memory consumption, and disk usage with customizable update intervals, making it an essential utility for developers and enthusiasts.
Features
CPU Monitoring: Displays the average CPU usage across all cores. Memory Monitoring: Reports used and total memory in MB. Disk Monitoring: Displays detailed usage for each disk, including a summary of total used, free, and total space. Customizable Update Interval: Allows you to specify how frequently the system statistics are refreshed.
Installation
Prerequisites
Ensure you have the following installed on your system:
Rust: Install it using rustup. Linux OS: The tool is designed for Linux-based RISC-V platforms.
Steps Clone the repository:
git clone https://github.com/your-username/riscv_sys_monitor.git
cd riscv_sys_monitor
Build the project:
cargo build --release
Run the executable:
./target/release/riscv_sys_monitor
Usage
Run riscv_sys_monitor with a user-defined update interval (in seconds):
./riscv_sys_monitor --interval <SECONDS>
Command-Line Optionss
Option | Description | Default |
---|---|---|
-i, --interval |
Sets the update interval in seconds | 1 |
Example
To update system statistics every 5 seconds:
./riscv_sys_monitor --interval 5
Example Output
Starting riscv_sys_monitor...
System Metrics - 2024-12-03 14:12:45
---------------------------
CPU Usage: 15.67%
Memory Usage: 2048 / 4096 MB
Disk Usage:
Disk: /dev/sda1 | Used: 50.00 GB | Free: 450.00 GB | Total: 500.00 GB
Disk: /dev/sda2 | Used: 100.00 GB | Free: 100.00 GB | Total: 200.00 GB
Total Disk Usage: Used: 150.00 GB | Free: 550.00 GB | Total: 700.00 GB
Code Overview
The tool consists of the following core functionalities:
refresh_system: Refreshes all system statistics using the sysinfo crate. format_size: Converts byte sizes into a human-readable format (e.g., KB, MB, GB, TB). print_system_info: Outputs CPU, memory, and disk usage metrics.
Code Structure
Main Program: Reads the update interval from command-line arguments and repeatedly fetches and displays system statistics. Unit Tests: Validates the correctness of CPU, memory, and disk usage calculations.
Testing
Run tests using:
cargo test
The tests include:
CPU usage calculations Memory usage retrieval Disk usage retrieval and verification
License
This project is licensed under the MIT License
Author
Ben Santora - Cape Ann MA
Dependencies
~6MB
~107K SLoC