2 releases
new 1.0.4 |
|
---|---|
0.1.6 | Nov 6, 2024 |
0.1.5 | Nov 6, 2024 |
0.1.1 |
|
0.1.0 |
|
#7 in #uptime
585 downloads per month
10KB
105 lines
oxide_linux2
oxide_linux2
is a Rust library that provides utilities for retrieving system information on Linux. It allows users to easily fetch details like kernel version, system uptime, available memory, CPU information, load averages, and disk usage.
Features
- Retrieve Linux kernel version
- Fetch system uptime
- Get available memory in kilobytes
- Retrieve CPU information
- Fetch system load averages
- Get disk usage statistics
Installation
To use oxide_linux2
in your project, add it as a dependency in your Cargo.toml
file:
[dependencies]
oxide_linux2 = "0.1.5"
thiserror = "1.0"
nix = "0.23.0"
usage
Here's an example of how to use the library:
use oxide_linux2::SystemInfo;
fn main() {
// Kernel version
if let Some(kernel_version) = SystemInfo::kernel_version() {
println!("Kernel Version: {}", kernel_version);
} else {
println!("Failed to get Kernel Version.");
}
// System uptime
match SystemInfo::system_uptime() {
Ok(uptime) => println!("System Uptime: {:.2} seconds", uptime),
Err(e) => println!("Failed to get System Uptime: {}", e),
}
// Available memory
match SystemInfo::available_memory() {
Ok(memory) => println!("Available Memory: {} kB", memory),
Err(e) => println!("Failed to get Available Memory: {}", e),
}
// CPU information
match SystemInfo::cpu_info() {
Ok(cpu_info) => println!("CPU Information: \n{}", cpu_info),
Err(e) => println!("Failed to get CPU Information: {}", e),
}
// Load average
match SystemInfo::load_average() {
Ok(loadavg) => println!("Load Average: {:.2}, {:.2}, {:.2}", loadavg[0], loadavg[1], loadavg[2]),
Err(e) => println!("Failed to get Load Average: {}", e),
}
// Disk usage
match SystemInfo::disk_usage("/") {
Ok((total, free)) => println!("Disk Usage: Total - {} bytes, Free - {} bytes", total, free),
Err(e) => println!("Failed to get Disk Usage: {}", e),
}
}
License
This project is licensed under the MIT License
Author
Ben Santora bensatlantik@gmail.com
Donate
Dependencies
~2.5MB
~52K SLoC