### Build and Run C Example Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md Builds the C example using the Makefile and runs the resulting executable. ```bash > make > ./simple ``` -------------------------------- ### Run C Example with LD_LIBRARY_PATH Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md Runs the C example, specifying the library path if needed. ```bash > LD_LIBRARY_PATH=target/debug/ ./simple ``` -------------------------------- ### Install ARM Toolchain on Ubuntu Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md Installs the necessary ARM cross-compilation toolchain on Ubuntu systems. ```bash > sudo apt-get install gcc-multilib-arm-linux-gnueabihf ``` -------------------------------- ### Get Process Name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the name or command used to start the process. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] {}", pid, process.name()); } } ``` -------------------------------- ### Process::name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Returns the process name or command line used to start it. ```APIDOC ## Process::name ### Description Returns the process name/command. ### Method `Process::name(&self) -> &str` ### Parameters None ### Returns - `&str` - Process name ### Example ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] {}", pid, process.name()); } } ``` ``` -------------------------------- ### Process::start_time Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Returns the process start time as a Unix timestamp. ```APIDOC ## Process::start_time ### Description Returns when the process started as Unix timestamp. ### Returns `u64` - Seconds since epoch ``` -------------------------------- ### Initialize System Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Use `System::new_all()` to get comprehensive system information. This function may return an error, so it should be handled appropriately. ```rust let sys = System::new_all()?; ``` -------------------------------- ### Create System Instance with All Data Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Convenience constructor that immediately loads all available system information upon creation. Useful for getting a complete snapshot. ```rust use sysinfo::System; if let Ok(system) = System::new_all() { println!("CPUs: {}", system.cpus().len()); println!("Processes: {}", system.processes().len()); } ``` -------------------------------- ### Minimal Setup: System Info Only Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Configure the sysinfo crate to only include system information by disabling default features and explicitly enabling the 'system' feature. ```toml sysinfo = { version = "0.39", default-features = false, features = ["system"] } ``` -------------------------------- ### Get OS Version Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the operating system version string. Returns None if the version cannot be determined. ```rust use sysinfo::System; // System::os_version() returns Option // Example usage would involve unwrapping or matching on the Option. ``` -------------------------------- ### Get System Information with sysinfo Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md This snippet demonstrates how to retrieve comprehensive system information including OS details, memory, swap, CPU count, processes, disks, networks, and component temperatures. Ensure to keep a single instance of `System` and call `refresh_all()` for updated data. It's recommended to use `System::new_all()` to ensure all lists are populated. ```rust use sysinfo::{ Components, Disks, Networks, System, }; // Please note that we use "new_all" to ensure that all lists of // CPUs and processes are filled! println!("=> system:"); // Display system information: println!("System name: {:?}", System::name()); println!("System kernel version: {:?}", System::kernel_version()); println!("System OS version: {:?}", System::os_version()); println!("System host name: {:?}", System::host_name()); if let Ok(mut sys) = System::new_all() { // First we update all information of our `System` struct. sys.refresh_all(); // RAM and swap information: println!("total memory: {} bytes", sys.total_memory()); println!("used memory : {} bytes", sys.used_memory()); println!("total swap : {} bytes", sys.total_swap()); println!("used swap : {} bytes", sys.used_swap()); // Number of CPUs: println!("NB CPUs: {}", sys.cpus().len()); // Display processes ID, name and disk usage: for (pid, process) in sys.processes() { println!("[{pid}] {:?} {:?}", process.name(), process.disk_usage()); } } // We display all disks' information: println!("=> disks:"); let disks = Disks::new_with_refreshed_list(); for disk in &disks { println!("{disk:?}"); } // Network interfaces name, total data received and total data transmitted: let networks = Networks::new_with_refreshed_list(); println!("=> networks:"); for (interface_name, data) in &networks { println!( "{interface_name}: {} B (down) / {} B (up)", data.total_received(), data.total_transmitted(), ); // If you want the amount of data received/transmitted since last call // to `Networks::refresh`, use `received`/`transmitted`. } // Components temperature: let components = Components::new_with_refreshed_list(); println!("=> components:"); for component in &components { println!("{component:?}"); } ``` -------------------------------- ### Serialize System State to JSON Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Example demonstrating how to serialize the current system state to a JSON string using the `serde` feature and `serde_json` crate. ```rust use sysinfo::System; let sys = System::new_all()?; // Serialize to JSON (requires serde_json) let json = serde_json::to_string(&sys)?; println!("{}", json); ``` -------------------------------- ### Get Host Name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system's hostname. Returns None if the hostname cannot be determined. ```rust use sysinfo::System; // System::host_name() returns Option // Example usage would involve unwrapping or matching on the Option. ``` -------------------------------- ### Basic System Query in Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/00-README.txt Initializes a new System instance and retrieves basic system information, such as the number of CPUs. This is a common starting point for using the sysinfo crate. ```rust let sys = System::new_all()?; println!("CPUs: {}", sys.cpus().len()); ``` -------------------------------- ### Refresh System Info with Specifics Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Use RefreshKind to specify which system information to update. This example refreshes only CPU usage. ```rust use sysinfo::{RefreshKind, MemoryRefreshKind, CpuRefreshKind, ProcessRefreshKind, System}; // Refresh only CPU usage let refresh = RefreshKind::nothing() .with_cpu(CpuRefreshKind::nothing().with_usage()); let sys = System::new_with_specifics(refresh)?; ``` -------------------------------- ### Send Terminate Signal to Processes Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md This example demonstrates how to check for supported signals and then iterate through all processes, attempting to send a terminate signal to each. Only Signal::Kill is guaranteed to be available on all platforms. ```rust use sysinfo::{System, SUPPORTED_SIGNALS, Signal}; println!("Supported signals: {:?}", SUPPORTED_SIGNALS); if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { let _ = process.kill_with(Signal::Terminate); } } ``` -------------------------------- ### Get Process Command Line Arguments Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the full command line arguments passed to the process. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] cmd: {:?}", pid, process.cmd()); } } ``` -------------------------------- ### General I/O Error Handling with System::new_all Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/errors.md Provides a structured way to handle `Error::Io` variants by matching on the `io::Error` and its kind. This example demonstrates a fallback for other I/O errors. ```rust use sysinfo::{System, Error}; if let Err(e) = System::new_all() { match e { Error::Io(io_err) => { eprintln!("I/O Error: {}", io_err); eprintln!("Kind: {:?}", io_err.kind()); } _ => eprintln!("Other error: {}", e), } } ``` -------------------------------- ### Get System Boot Time Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system boot time as a Unix timestamp (seconds since epoch). ```rust use sysinfo::System; // System::boot_time() returns Result // Example usage would involve matching on the Result. ``` -------------------------------- ### Initialize User Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Use `Users::new_with_refreshed_list()` to get information about user accounts. This function refreshes the user list upon creation. ```rust let users = Users::new_with_refreshed_list(); ``` -------------------------------- ### Get Long OS Version Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves a more detailed OS version string. Returns None if the detailed version cannot be determined. ```rust use sysinfo::System; // System::long_os_version() returns Option // Example usage would involve unwrapping or matching on the Option. ``` -------------------------------- ### Minimal File Descriptor Usage Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Example demonstrating minimal file descriptor usage by setting a low limit. This is useful for applications that require very few file descriptors. ```rust use sysinfo::set_open_files_limit; // Minimal file descriptor usage set_open_files_limit(10); let sys = System::new_all()?; ``` -------------------------------- ### Get System Uptime Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system uptime in seconds since boot. Handles potential errors during retrieval. ```rust use sysinfo::System; match System::uptime() { Ok(uptime) => println!("Uptime: {} seconds", uptime), Err(e) => eprintln!("Error: {}", e), } ``` -------------------------------- ### Get Total System Memory Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieve the total amount of RAM installed on the system in bytes. This is useful for calculating memory utilization. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { let mb = sys.total_memory() / (1024 * 1024); println!("Total memory: {} MB", mb); } ``` -------------------------------- ### System::new_all() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Creates a new System instance and immediately loads all available system information. ```APIDOC ## System::new_all() ### Description Creates a new `System` instance with all information loaded. This is a convenience method equivalent to calling `System::new_with_specifics(RefreshKind::everything())`. ### Method `System::new_all()` ### Parameters None ### Returns `Result` - System with all data refreshed ### Example ```rust use sysinfo::System; if let Ok(system) = System::new_all() { println!("CPUs: {}", system.cpus().len()); println!("Processes: {}", system.processes().len()); } ``` ``` -------------------------------- ### Get Component List Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/component.md Returns a slice of all components. This is useful for reading component information without modifying it. ```rust use sysinfo::Components; let components = Components::new_with_refreshed_list(); for component in components.list() { println!("{}", component.label()); } ``` -------------------------------- ### Initialize Disk Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Use `Disks::new_with_refreshed_list()` to get information about storage devices. This function refreshes the list of disks upon creation. ```rust let disks = Disks::new_with_refreshed_list(); ``` -------------------------------- ### Get Target OS Configuration Source: https://github.com/guillaumegomez/sysinfo/blob/main/ADDING_NEW_PLATFORMS.md Use this command to retrieve target operating system configuration details, such as `target_os`. This information is crucial for conditional compilation. ```bash rustc --print cfg ``` -------------------------------- ### Process::root Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Gets the root directory of the process. ```APIDOC ## Process::root ### Description Returns the root directory of the process. ### Returns `&Path` - Root directory path ``` -------------------------------- ### Refresh CPU Usage Periodically Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md This example shows how to continuously refresh CPU usage information. It requires creating a `System` instance and repeatedly calling `refresh_cpu_usage()`. A sleep interval is necessary to allow the system to gather meaningful data. This snippet is marked with `no_run` as it's intended for demonstration and continuous execution. ```rust use sysinfo::System; let Ok(mut sys) = System::new() else { return }; loop { sys.refresh_cpu_usage(); // Refreshing CPU usage. for cpu in sys.cpus() { print!("{}% ", cpu.usage()); } // Sleeping to let time for the system to run for long // enough to have useful information. std::thread::sleep(sysinfo::MINIMUM_CPU_UPDATE_INTERVAL); } ``` -------------------------------- ### Process::user_id Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Gets the user ID of the process owner, if available. ```APIDOC ## Process::user_id ### Description Returns the user ID that owns this process. ### Returns `Option<&Uid>` - User ID if available ``` -------------------------------- ### Motherboard::new() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Creates motherboard information if available. Returns None if no motherboard information can be retrieved. ```APIDOC ## Motherboard::new() ### Description Creates motherboard information if available. ### Parameters None ### Returns `Option` - Motherboard info or None ``` -------------------------------- ### Get System Name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system name, such as "Linux" or "Windows". Returns None if the name cannot be determined. ```rust use sysinfo::System; // System::name() returns Option // Example usage would involve unwrapping or matching on the Option. ``` -------------------------------- ### Configure Memory Refresh Options Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Select specific memory components to refresh. Use `everything()` to get both RAM and SWAP, `with_ram()` for only RAM, or `with_swap()` for only SWAP. ```rust use sysinfo::{MemoryRefreshKind, System}; // Refresh both RAM and SWAP let kind = MemoryRefreshKind::everything(); // Refresh only RAM let kind = MemoryRefreshKind::nothing().with_ram(); // Refresh only SWAP let kind = MemoryRefreshKind::nothing().with_swap(); ``` -------------------------------- ### System::new() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Creates a new System instance with no data loaded. Call a refresh method to populate system information. ```APIDOC ## System::new() ### Description Creates a new `System` instance with nothing loaded. Call a refresh method to populate data. ### Method `System::new()` ### Parameters None ### Returns `Result` - A new System instance with empty data ### Example ```rust use sysinfo::System; match System::new() { Ok(s) => println!("System created"), Err(e) => eprintln!("Failed to create system: {}", e), } ``` ``` -------------------------------- ### Initialize Network Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Use `Networks::new_with_refreshed_list()` to get information about network interfaces. This function refreshes the list of networks upon creation. ```rust let networks = Networks::new_with_refreshed_list(); ``` -------------------------------- ### Get Kernel Long Version Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the full kernel version string. ```rust use sysinfo::System; // System::kernel_long_version() returns String // Example usage would involve directly using the returned string. ``` -------------------------------- ### Get Supported Signals (Rust) Source: https://github.com/guillaumegomez/sysinfo/blob/main/md_doc/supported_signals.md This snippet demonstrates how to retrieve and print the list of signals supported by the current operating system using the `sysinfo` crate. It utilizes the `SUPPORTED_SIGNALS` constant, which provides this information directly. ```Rust use sysinfo::{System, SUPPORTED_SIGNALS}; println!("supported signals: {:?}", SUPPORTED_SIGNALS); ``` -------------------------------- ### Configuration with Serialization Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Enable the 'serde' feature to allow serialization and deserialization of sysinfo types. ```toml sysinfo = { version = "0.39", features = ["serde"] } ``` -------------------------------- ### Get Parent Process ID Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the PID of the parent process, if available. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] parent: {:?}", pid, process.parent()); } } ``` -------------------------------- ### Get Process ID Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the unique Process ID (PID) of the process. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] {}", pid, process.pid()); } } ``` -------------------------------- ### Test Linux Configuration with Mock Filesystems Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Demonstrates how to override the default /proc path for testing purposes using environment variables. This allows for testing with mock filesystems. ```bash # Run with alternative /proc location SYSINFO_LINUX_PROC_PATH=/tmp/mock_proc cargo run ``` ```rust std::env::set_var("SYSINFO_LINUX_PROC_PATH", "/tmp/mock_proc"); ``` -------------------------------- ### Handle System Initialization Errors Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/00-README.txt Demonstrates error handling for system initialization, specifically catching unsupported platforms or other errors. ```rust match System::new_all() { Ok(sys) => { /* use system */ } Err(Error::Unsupported) => eprintln!("Platform unsupported"), Err(e) => eprintln!("Error: {}", e), } ``` -------------------------------- ### Get Group Name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/user.md Iterates through users and their groups to print only the group name. ```rust use sysinfo::Users; let users = Users::new(); for user in users.list() { for group in user.groups() { println!("{}", group.name()); } } ``` -------------------------------- ### Get System Load Average Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system load averages for the last 1, 5, and 15 minutes. Prints the values if successful. ```rust use sysinfo::System; if let Ok(load) = System::load_average() { println!("Load: 1m={}, 5m={}, 15m={}", load.one, load.five, load.fifteen); } ``` -------------------------------- ### Use Error Handling for System Initialization Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Implement robust error handling when initializing `System` using `System::new_all()`. Handle specific errors like `Error::Unsupported` and general errors. ```rust use sysinfo::{System, Error}; match System::new_all() { Ok(sys) => println!("System initialized"), Err(Error::Unsupported) => eprintln!("Platform not supported"), Err(e) => eprintln!("Error: {}", e), } ``` -------------------------------- ### Get Process Run Time Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the total time in seconds that the process has been running. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] run time: {} seconds", pid, process.run_time()); } } ``` -------------------------------- ### Minimal Build (Process Info Only) Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Configure sysinfo for a minimal build by disabling default features and explicitly enabling only the 'system' feature for process information. This reduces compile times and binary size. ```toml [dependencies] sysinfo = { version = "0.39", default-features = false, features = ["system"] } ``` -------------------------------- ### Get Process CPU Usage Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the current CPU usage percentage for the process. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] CPU usage: {:.2}%", pid, process.cpu_usage()); } } ``` -------------------------------- ### System::new_with_specifics() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Creates a new System instance and selectively refreshes data based on the provided RefreshKind. ```APIDOC ## System::new_with_specifics(refreshes: RefreshKind) ### Description Creates a new `System` instance and refreshes data according to the specified `RefreshKind`. Allows for selective initialization of system information. ### Method `System::new_with_specifics(refreshes: RefreshKind)` ### Parameters #### Path Parameters - **refreshes** (RefreshKind) - Required - Specifies what system information to refresh ### Returns `Result` - System with specified data refreshed ### Example ```rust use sysinfo::{ProcessRefreshKind, RefreshKind, System}; if let Ok(system) = System::new_with_specifics( RefreshKind::nothing().with_processes(ProcessRefreshKind::everything()), ) { println!("Processes loaded: {}", system.processes().len()); } ``` ``` -------------------------------- ### Get Process Executable Path Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the absolute path to the executable file of the process. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] exe: {:?}", pid, process.executable()); } } ``` -------------------------------- ### Initialize System Once Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Create the System object once at application startup and reuse it throughout your application for efficiency. This avoids repeated initialization overhead. ```rust use sysinfo::System; // Create once at startup let mut sys = System::new_all()?; // Reuse throughout application loop { sys.refresh_cpu_usage(); println!("CPU: {}%", sys.global_cpu_usage()); } ``` -------------------------------- ### Get Disk Name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/disk.md Iterates through disks and prints their names. Requires the `Disks` struct. ```rust use sysinfo::Disks; let disks = Disks::new_with_refreshed_list(); for disk in disks.list() { println!("Disk: {{:?}}", disk.name()); } ``` -------------------------------- ### Get CPU Architecture Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the CPU architecture as a string (e.g., "x86_64"). ```rust use sysinfo::System; // System::cpu_arch() returns String // Example usage would involve directly using the returned string. ``` -------------------------------- ### Initialize and Convert Pid Types Source: https://github.com/guillaumegomez/sysinfo/blob/main/md_doc/pid.md Demonstrates how to create a Pid instance from an integer and how to convert it back to a u32 for general usage. This approach ensures compatibility across different operating systems. ```rust use sysinfo::Pid; // 0's type will be different depending on the platform! let p = Pid::from(0); // For something more "general": let p = Pid::from_u32(0); let i: u32 = p.as_u32(); ``` -------------------------------- ### Initialize Component Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Use `Components::new_with_refreshed_list()` to get hardware sensor data, such as temperatures. This function refreshes the component list upon creation. ```rust let components = Components::new_with_refreshed_list(); ``` -------------------------------- ### Get Kernel Version Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the kernel version string. Returns None if the version cannot be determined. ```rust use sysinfo::System; // System::kernel_version() returns Option // Example usage would involve unwrapping or matching on the Option. ``` -------------------------------- ### Get Process Memory Usage Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the amount of resident memory used by the process in bytes. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { let mb = process.memory() / (1024 * 1024); println!("[{}] memory: {} MB", pid, mb); } } ``` -------------------------------- ### Basic Error Handling with `match` Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/errors.md Use `match` to handle both successful initialization and potential errors when creating a `System` object. This is suitable for straightforward error reporting. ```rust use sysinfo::System; match System::new_all() { Ok(sys) => { println!("Memory: {} bytes", sys.total_memory()); } Err(e) => { eprintln!("Failed to get system info: {}", e); } } ``` -------------------------------- ### Get Process Status Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the current status of the process (e.g., Running, Sleeping, Zombie). ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] status: {:?}", pid, process.status()); } } ``` -------------------------------- ### Handling Error::Unsupported for Gpus Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/errors.md Demonstrates how to match against the `Error::Unsupported` variant when initializing `Gpus`. This is useful for gracefully handling cases where GPU detection is not available on the current platform. ```rust use sysinfo::{Gpus, Error}; match Gpus::new() { Ok(gpus) => println!("GPUs detected"), Err(Error::Unsupported) => eprintln!("GPU detection not supported"), Err(e) => eprintln!("Error: {}", e), } ``` -------------------------------- ### Get Disk Kind Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/disk.md Iterates through disks and prints their names and kinds. Requires the `Disks` struct. ```rust use sysinfo::Disks; let disks = Disks::new_with_refreshed_list(); for disk in disks.list() { println!("[{:?}] {{:?}}", disk.name(), disk.kind()); } ``` -------------------------------- ### Process::cmd Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Returns the full command line arguments as a slice of strings. ```APIDOC ## Process::cmd ### Description Returns the full command line arguments. ### Method `Process::cmd(&self) -> &[String]` ### Parameters None ### Returns - `&[String]` - Slice of command arguments ### Example ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] cmd: {:?}", pid, process.cmd()); } } ``` ``` -------------------------------- ### GET /signals Source: https://github.com/guillaumegomez/sysinfo/blob/main/md_doc/supported_signals.md Retrieves the list of supported signals available on the current system for process termination. ```APIDOC ## GET /signals ### Description Returns the list of the supported signals on this system, which are used by the `Process::kill_with` method. ### Method GET ### Endpoint /signals ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **signals** (Array) - A list of supported signal constants available on the host system. #### Response Example ```rust use sysinfo::{System, SUPPORTED_SIGNALS}; println!("supported signals: {:?}", SUPPORTED_SIGNALS); ``` ``` -------------------------------- ### Add ARM Target and Cross-Compile Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md Adds the ARM target to your Rust installation and performs a cross-compilation build. ```bash rustup target add armv7-unknown-linux-gnueabihf cargo build --target=armv7-unknown-linux-gnueabihf ``` -------------------------------- ### Accessing System Information via Static Methods Source: https://github.com/guillaumegomez/sysinfo/blob/main/migration_guide.md Demonstrates the usage of the new static methods in the System struct, which allow retrieving system information without requiring an instance of the System object. ```rust println!("host name: {}", System::host_name()); ``` -------------------------------- ### Verify OS Support with sysinfo Source: https://github.com/guillaumegomez/sysinfo/blob/main/md_doc/is_supported.md This snippet demonstrates how to use the IS_SUPPORTED_SYSTEM constant to check for OS compatibility. It prints a message indicating whether the current system is supported or not. ```rust if sysinfo::IS_SUPPORTED_SYSTEM { println!("This OS is supported!"); } else { println!("This OS isn't supported (yet?)."); } ``` -------------------------------- ### Get Used Swap Space Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the amount of swap space currently in use by the system, in bytes. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { let used_swap_mb = sys.used_swap() / (1024 * 1024); println!("Used swap: {} MB", used_swap_mb); } ``` -------------------------------- ### Create System Instance with Specific Refreshes Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Initializes a System instance and selectively refreshes only the specified system information. Use RefreshKind to control what data is loaded. ```rust use sysinfo::{ProcessRefreshKind, RefreshKind, System}; if let Ok(system) = System::new_with_specifics( RefreshKind::nothing().with_processes(ProcessRefreshKind::everything()), ) { println!("Processes loaded: {}", system.processes().len()); } ``` -------------------------------- ### Get Free Swap Space Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the amount of free swap space available on the system, in bytes. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { let free_swap_mb = sys.free_swap() / (1024 * 1024); println!("Free swap: {} MB", free_swap_mb); } ``` -------------------------------- ### Get Total Swap Space Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the total size of the swap space configured on the system, in bytes. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { let total_swap_mb = sys.total_swap() / (1024 * 1024); println!("Total swap: {} MB", total_swap_mb); } ``` -------------------------------- ### Handle Unsupported Platforms with sysinfo Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Check the `IS_SUPPORTED_SYSTEM` flag before proceeding to ensure compatibility and provide a graceful exit or alternative behavior for unsupported platforms. ```rust use sysinfo::IS_SUPPORTED_SYSTEM; if !IS_SUPPORTED_SYSTEM { eprintln!("sysinfo not supported on this platform"); return; } let sys = System::new_all()?; ``` -------------------------------- ### Get Used System Memory Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the amount of RAM currently in use by the system and its processes, in bytes. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { let used_mb = sys.used_memory() / (1024 * 1024); println!("Used memory: {} MB", used_mb); } ``` -------------------------------- ### Get Process Virtual Memory Usage Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves the amount of virtual memory used by the process in bytes. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { println!("[{}] virtual memory: {} bytes", pid, process.virtual_memory()); } } ``` -------------------------------- ### Motherboard::version() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the version of the motherboard. Returns None if the version is not available. ```APIDOC ## Motherboard::version() ### Description Returns the motherboard version. ### Parameters None ### Returns `Option` - Version or None ``` -------------------------------- ### Handling Specific I/O Errors with System::new_all Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/errors.md Shows how to specifically catch and handle `io::ErrorKind::PermissionDenied` when initializing `System`. This allows for targeted error messages based on the I/O error kind. ```rust use sysinfo::{System, Error}; use std::io; match System::new_all() { Ok(sys) => println!("System initialized"), Err(Error::Io(e)) if e.kind() == io::ErrorKind::PermissionDenied => { eprintln!("Permission denied accessing system info"); } Err(e) => eprintln!("Error: {}", e), } ``` -------------------------------- ### Get User by ID Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/user.md Finds a user by their unique ID. The Uid type must be used for searching. ```rust use sysinfo::{Users, Uid}; let users = Users::new(); let uid = Uid::from(1000); if let Some(user) = users.get_user_by_id(&uid) { println!("Found user: {}", user.name()); } ``` -------------------------------- ### Serialize System Information to JSON Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Demonstrates how to serialize the System object to a JSON string using the serde and serde_json crates. Ensure the 'serde' feature is enabled for sysinfo. ```rust use sysinfo::System; let sys = System::new_all()?; let json = serde_json::to_string(&sys)?; ``` -------------------------------- ### Get Mount Point Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/disk.md Iterates through disks and prints their names and mount points. Requires the `Disks` struct. ```rust use sysinfo::Disks; let disks = Disks::new_with_refreshed_list(); for disk in disks.list() { println!("[{:?}] mounted at: {{:?}}", disk.name(), disk.mount_point()); } ``` -------------------------------- ### Create Disks Container with Initialized List Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/disk.md Convenience constructor that creates a new Disks container and immediately loads the disk list. Useful for immediate access to disk details. ```rust use sysinfo::Disks; let disks = Disks::new_with_refreshed_list(); for disk in disks.list() { println!("Disk: {:?}", disk.name()); println!(" Total: {} bytes", disk.total_space()); println!(" Available: {} bytes", disk.available_space()); } ``` -------------------------------- ### Create New System Instance Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Instantiates a new System object without loading any data. You must call a refresh method to populate it. ```rust use sysinfo::System; match System::new() { Ok(s) => println!("System created"), Err(e) => eprintln!("Failed to create system: {}", e), } ``` -------------------------------- ### Get Physical Core Count Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the number of physical CPU cores. Returns None if the count cannot be determined. ```rust use sysinfo::System; // System::physical_core_count() returns Option // Example usage would involve unwrapping or matching on the Option. ``` -------------------------------- ### Get Linux Distribution ID Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the Linux distribution identifier. Returns an empty string if not applicable or determinable. ```rust use sysinfo::System; // System::distribution_id() returns String // Example usage would involve directly using the returned string. ``` -------------------------------- ### Configure Disk Refresh Options Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Specify disk information to refresh. `everything()` updates both the disk list and their usage statistics. `with_usage()` refreshes only the usage statistics. ```rust use sysinfo::{DiskRefreshKind, Disks}; // Refresh disk list and usage let mut disks = Disks::new(); disks.refresh_specifics(DiskRefreshKind::everything()); // Refresh only usage (not list) disks.refresh_specifics(DiskRefreshKind::nothing().with_usage()); ``` -------------------------------- ### System::boot_time Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system boot time as a Unix timestamp. ```APIDOC ## System::boot_time() ### Description Returns system boot time as Unix timestamp. ### Method `System::boot_time()` ### Parameters None ### Returns `Result` - Seconds since Unix epoch ``` -------------------------------- ### Run Benchmarks Source: https://github.com/guillaumegomez/sysinfo/blob/main/README.md Executes the benchmarks for the sysinfo crate using Rust nightly. ```bash > cargo bench ``` -------------------------------- ### Get Operational State of Interfaces Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/network.md Iterate through network interfaces and print their operational state. Requires the `Networks` struct. ```rust use sysinfo::Networks; let networks = Networks::new_with_refreshed_list(); for (name, data) in &networks { println!("{}: {:?}", name, data.operational_state()); } ``` -------------------------------- ### Iterate and Get User Name Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/user.md Iterates through system users and prints only their names. Requires the `Users` struct to be initialized. ```rust use sysinfo::Users; let users = Users::new(); for user in users.list() { println!("{}", user.name()); } ``` -------------------------------- ### Product::name() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the name of the system product. Returns None if the product name is not available. ```APIDOC ## Product::name() ### Description Returns the product name. ### Parameters None ### Returns `Option` - Product name or None ``` -------------------------------- ### Get Component ID - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/component.md Iterates through components and prints their identifier if available. The ID format varies by platform. ```rust use sysinfo::Components; let components = Components::new_with_refreshed_list(); for component in components.list() { if let Some(id) = component.id() { println!("{}: {}", component.label(), id); } } ``` -------------------------------- ### Build C Library Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Commands to build the sysinfo C library as a shared library for different operating systems. ```bash # Build as shared library carp build --release --features c-interface # Library location: target/release/libsysinfo.so (Linux) # target/release/libsysinfo.dylib (macOS) # target/release/sysinfo.dll (Windows) ``` -------------------------------- ### Get Supported Signals Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/types.md Access the list of signals supported on the current platform. This is useful for understanding signal handling capabilities. ```rust use sysinfo::SUPPORTED_SIGNALS; println!("Supported signals: {:?}", SUPPORTED_SIGNALS); ``` -------------------------------- ### Enumerate All Resources Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/INDEX.md Access and iterate over various system resources including processes, disks, networks, components, and users. This snippet demonstrates how to initialize and retrieve lists for each resource type. ```rust use sysinfo::{System, Disks, Networks, Components, Users}; let sys = System::new_all()?; let disks = Disks::new_with_refreshed_list(); let networks = Networks::new_with_refreshed_list(); let components = Components::new_with_refreshed_list(); let users = Users::new_with_refreshed_list(); for process in sys.processes().values() { println!("Process: {}", process.name()); } for disk in disks.list() { println!("Disk: {:?}", disk.name()); } for (name, data) in &networks { println!("Interface: {}", name); } ``` -------------------------------- ### Get CPU Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieve a slice containing information about each CPU core. This includes CPU names and their current usage. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { println!("CPUs: {}", sys.cpus().len()); for cpu in sys.cpus() { println!(" {} - {}%", cpu.name(), cpu.usage()); } } ``` -------------------------------- ### Configure CPU Refresh Options Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Choose which CPU details to refresh. `everything()` includes usage and frequency. Note that CPU usage requires two calls for accuracy. ```rust use sysinfo::{CpuRefreshKind, System}; // Refresh usage (requires two calls for accuracy) let kind = CpuRefreshKind::nothing().with_usage(); // Refresh frequency let kind = CpuRefreshKind::nothing().with_frequency(); // Refresh both let kind = CpuRefreshKind::everything(); ``` -------------------------------- ### Get IP Networks for Interfaces Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/network.md Iterate through network interfaces and print their assigned IP networks. Requires the `Networks` struct. ```rust use sysinfo::Networks; let networks = Networks::new_with_refreshed_list(); for (name, data) in &networks { println!("{}: {:?}", name, data.ip_networks()); } ``` -------------------------------- ### Create and Iterate Users Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/user.md Creates a new Users container and iterates through the list of users, printing each user's name. Ensure the sysinfo crate is added as a dependency. ```rust use sysinfo::Users; let users = Users::new(); for user in users.list() { println!("User: {}", user.name()); } ``` -------------------------------- ### Get Process Disk Usage - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/process.md Retrieves disk I/O statistics for a process. This can be useful for monitoring resource consumption. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { for (pid, process) in sys.processes() { let disk = process.disk_usage(); println!("[{}] read: {} bytes", pid, disk.read_bytes); } } ``` -------------------------------- ### Networks::new Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/network.md Creates a new empty Networks container. Call `refresh()` to populate interface list. ```APIDOC ## Networks::new ### Description Creates a new empty `Networks` container. Call `refresh()` to populate interface list. ### Method `Networks::new() -> Self` ### Parameters None ### Returns `Networks` - Empty container ### Example ```rust use sysinfo::Networks; let mut networks = Networks::new(); networks.refresh(false); for (interface_name, data) in &networks { println!("{}: {} B recv, {} B sent", interface_name, data.total_received(), data.total_transmitted()); } ``` ``` -------------------------------- ### Get Network Data for Specific Interface Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/network.md Returns data for a specific interface by name. Returns `None` if the interface does not exist. ```rust use sysinfo::Networks; let networks = Networks::new_with_refreshed_list(); if let Some(eth0) = networks.get("eth0") { println!("eth0 received: {} bytes", eth0.total_received()); } ``` -------------------------------- ### Refresh Network Interface Statistics Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/network.md Refreshes network interface list and statistics. Useful for getting updated data after a delay. ```rust use sysinfo::Networks; let mut networks = Networks::new_with_refreshed_list(); std::thread::sleep(std::time::Duration::from_secs(1)); networks.refresh(); for (name, data) in &networks { println!("{}: {} B in (since last refresh)", name, data.received()); } ``` -------------------------------- ### Fast refresh with multiple threads Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Instantiate System with `new_all()` for a fast refresh using multiple threads. This leverages the default multithreaded feature for improved performance. ```rust use sysinfo::System; // Fast refresh with multiple threads let sys = System::new_all()?; ``` -------------------------------- ### Get Total Disk Space Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/disk.md Iterates through disks and prints their names and total capacities in GB. Requires the `Disks` struct. ```rust use sysinfo::Disks; let disks = Disks::new_with_refreshed_list(); for disk in disks.list() { let gb = disk.total_space() / (1024 * 1024 * 1024); println!("[{:?}] Total: {} GB", disk.name(), gb); } ``` -------------------------------- ### Gpus::new() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/gpu.md Creates a new empty Gpus container. Call refresh() to populate the GPU list. May return an error on unsupported platforms. ```APIDOC ## Gpus::new() ### Description Creates a new empty `Gpus` container. Call `refresh()` to populate GPU list. May return an error on unsupported platforms. ### Method `Gpus::new()` ### Parameters None ### Returns `Result` - Empty container or error ### Example ```rust use sysinfo::Gpus; match Gpus::new() { Ok(mut gpus) => { gpus.refresh(false); for gpu in gpus.list() { println!("{:?}", gpu); } } Err(e) => eprintln!("GPUs not supported: {}", e), } ``` ``` -------------------------------- ### Get File System Type Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/disk.md Iterates through disks and prints their names and file system types. Requires the `Disks` struct. ```rust use sysinfo::Disks; let disks = Disks::new_with_refreshed_list(); for disk in disks.list() { println!("[{:?}] FS: {{:?}}", disk.name(), disk.file_system()); } ``` -------------------------------- ### Get GPU Model Name - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/gpu.md Iterates through available GPUs and prints their model name. Requires the sysinfo crate. ```rust use sysinfo::Gpus; if let Ok(gpus) = Gpus::new_with_refreshed_list() { for gpu in gpus.list() { println!("Model: {}", gpu.model()); } } ``` -------------------------------- ### Get GPU Brand Name - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/gpu.md Iterates through available GPUs and prints their brand name. Requires the sysinfo crate. ```rust use sysinfo::Gpus; if let Ok(gpus) = Gpus::new_with_refreshed_list() { for gpu in gpus.list() { println!("Brand: {}", gpu.brand()); } } ``` -------------------------------- ### Create and Populate Networks Container Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/network.md Creates an uninitialized container. Call `refresh()` to populate interface list. ```rust use sysinfo::Networks; let mut networks = Networks::new(); networks.refresh(false); for (interface_name, data) in &networks { println!("{}: {} B recv, {} B sent", interface_name, data.total_received(), data.total_transmitted()); } ``` -------------------------------- ### Print GPU PCI Address Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/gpu.md Prints the PCI address of a GPU. This example demonstrates accessing the PCI field of a GPU object. ```rust use sysinfo::Gpus; if let Ok(gpus) = Gpus::new_with_refreshed_list() { for gpu in gpus.list() { println!("GPU at {}", gpu.pci()); } } ``` -------------------------------- ### Get Free System Memory Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Returns the amount of free RAM in bytes. This indicates memory that is not currently in use by any process or the system. ```rust use sysinfo::System; if let Ok(sys) = System::new_all() { let free_mb = sys.free_memory() / (1024 * 1024); println!("Free memory: {} MB", free_mb); } ``` -------------------------------- ### System::uptime Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieves the system uptime in seconds since the last boot. ```APIDOC ## System::uptime() ### Description Returns system uptime in seconds since boot. ### Method `System::uptime()` ### Parameters None ### Returns `Result` - Uptime in seconds ### Example ```rust use sysinfo::System; match System::uptime() { Ok(uptime) => println!("Uptime: {} seconds", uptime), Err(e) => eprintln!("Error: {}", e), } ``` ``` -------------------------------- ### Get Specific Process Information Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/system.md Retrieve details for a single process by its Process ID (PID). Returns `None` if the process is not found. ```rust use sysinfo::{System, Pid}; if let Ok(sys) = System::new_all() { if let Some(process) = sys.process(Pid::from(1234)) { println!("Process name: {}", process.name()); } } ``` -------------------------------- ### Users::new() Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/user.md Creates a new `Users` container, loading the list of all users on the system. ```APIDOC ## Users::new() ### Description Creates a new `Users` container. ### Parameters None ### Returns `Users` - Container with system users ### Example ```rust use sysinfo::Users; let users = Users::new(); for user in users.list() { println!("User: {}", user.name()); } ``` ``` -------------------------------- ### Iterate and Get User ID Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/user.md Iterates through all system users and prints their name and user ID. Requires the `Users` struct to be initialized. ```rust use sysinfo::Users; let users = Users::new(); for user in users.list() { println!("User: {} (ID: {:?})", user.name(), *user.id()); } ``` -------------------------------- ### Get Component Critical Temperature - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/component.md Iterates through components and prints their critical temperature threshold if available. This is the temperature above which the component should halt. ```rust use sysinfo::Components; let components = Components::new_with_refreshed_list(); for component in components.list() { if let Some(crit) = component.critical() { println!("{}: critical threshold {}°C", component.label(), crit); } } ``` -------------------------------- ### Choose Appropriate Features for sysinfo Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/configuration.md Specify features in your Cargo.toml to include only necessary components, like system information, to reduce build times and binary size. ```toml # If you only need process info: sysinfo = { version = "0.39", default-features = false, features = ["system"] } ``` ```toml # If you need everything: sysinfo = { version = "0.39" } ``` -------------------------------- ### Get Component Temperature - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/component.md Iterates through components and prints their temperature if available. On Linux, returns f32::NAN if retrieval failed. ```rust use sysinfo::Components; let components = Components::new_with_refreshed_list(); for component in components.list() { if let Some(temp) = component.temperature() { println!("{}: {}°C", component.label(), temp); } } ``` -------------------------------- ### Check Platform Support Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/errors.md Verify if the current operating system platform is supported by the sysinfo library. This is a compile-time check. ```rust use sysinfo::IS_SUPPORTED_SYSTEM; println!("Platform supported: {}", IS_SUPPORTED_SYSTEM); ``` -------------------------------- ### Get GPU PCI Information - Rust Source: https://github.com/guillaumegomez/sysinfo/blob/main/_autodocs/gpu.md Iterates through available GPUs and prints their PCI bus information. Requires the sysinfo crate. ```rust use sysinfo::Gpus; if let Ok(gpus) = Gpus::new_with_refreshed_list() { for gpu in gpus.list() { println!("PCI: {}", gpu.pci()); } } ```