riscv_sys_monitor

Crates.ioriscv_sys_monitor
lib.rsriscv_sys_monitor
version
sourcesrc
created_at2024-12-03 19:32:11.332787
updated_at2024-12-04 19:18:40.439639
description A system monitor for RISC-V SBCs on Linux
homepage
repository
max_upload_size
id1470583
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(bensantora1)

documentation

README

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

Commit count: 0

cargo fmt