Expand description
sysinfo
is a crate used to get a system’s information.
Before any attempt to read the different structs’ information, you need to update them to get up-to-date information.
Examples
use sysinfo::{ProcessExt, SystemExt};
let mut system = sysinfo::System::new();
// First we update all information of our system struct.
system.refresh_all();
// Now let's print every process' id and name:
for (pid, proc_) in system.get_process_list() {
println!("{}:{} => status: {:?}", pid, proc_.name(), proc_.status());
}
// Then let's print the temperature of the different components:
for component in system.get_components_list() {
println!("{:?}", component);
}
// And then all disks' information:
for disk in system.get_disks() {
println!("{:?}", disk);
}
// And finally the RAM and SWAP information:
println!("total memory: {} kB", system.get_total_memory());
println!("used memory : {} kB", system.get_used_memory());
println!("total swap : {} kB", system.get_total_swap());
println!("used swap : {} kB", system.get_used_swap());
Macros
Structs
Struct containing a component information (temperature and name for the moment).
Struct containing a disk information.
Contains network information.
Struct containing a process’ information.
Struct containing a processor information.
Struct containing system’s information.
Enums
Enum containing the different handled disks types.
Enum describing the different status of a process.
An enum representing signal on UNIX-like systems.
Traits
Trait to have a common fallback for the
Pid
type.Getting a component temperature information.
Contains all the methods of the
Disk
struct.Getting volume of incoming and outcoming data.
Contains all the methods of the
Process
struct.Contains all the methods of the
Processor
struct.Contains all the methods of the
System
struct.Functions
Returns the pid for the current process.
Type Definitions
Process id.