A library for retrieving system information.
use sysinfo_rs::get_machine_info;
fn main() -> anyhow::Result<()> {
let machine_info = get_machine_info()?;
println!("{:?}", machine_info);
Ok(())
}
Before using this library, ensure that you have libudev-devel
installed on your system. This is required for the libudev-sys
crate, which is a dependency of sysinfo_rs
.
You can install libudev-devel
using your package manager. For example:
-
On Debian-based systems (like Ubuntu):
sudo apt-get install libudev-dev
-
On Red Hat-based systems (like CentOS or Fedora):
sudo yum install libudev-devel
hardware
: Contains information about the hardware.cpu_is_virtual
: Analyzes the results of thecpuid
command execution to determine if the system is running in a virtual machine (key field).disk_serial_number
: The serial number of the hard disk.mac_addresses
: A list of MAC addresses for all network interfaces in the system.bios_info
: Contains BIOS information, including manufacturer, version, release date, and whether it's a virtual machine.system_info
: System manufacturer, product name, serial number, and UUID.enclosure_info
: Chassis information, including manufacturer, type, version, serial number, and asset tag number.
software
: Contains information about the software.os_release
: Operating system version information.uname
: Systemuname
information, including machine, nodename, release, sysname, and version fields.