Crate sysinfo[−][src]
Expand description
sysinfo
is a crate used to get a system’s information.
Supported Oses
It currently supports the following OSes (alphabetically sorted):
- Android
- iOS
- Linux
- macOS
- Windows
You can still use sysinfo
on non-supported OSes, it’ll simply do nothing and always return
empty values. You can check in your program directly if an OS is supported by checking the
SystemExt::IS_SUPPORTED
constant.
Usage
/!\ Before any attempt to read the different structs’ information, you need to update them to get up-to-date information because for most of them, it works on diff between the current value and the old one.
Which is why, it’s much better to keep the same instance of System
around instead of
recreating it multiple times.
Examples
use sysinfo::{ProcessExt, SystemExt}; let mut system = sysinfo::System::new_all(); // 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.processes() { println!("{}:{} => status: {:?}", pid, proc_.name(), proc_.status()); } // Then let's print the temperature of the different components: for component in system.components() { println!("{:?}", component); } // And then all disks' information: for disk in system.disks() { println!("{:?}", disk); } // And finally the RAM and SWAP information: println!("total memory: {} KB", system.total_memory()); println!("used memory : {} KB", system.used_memory()); println!("total swap : {} KB", system.total_swap()); println!("used swap : {} KB", system.used_swap()); // 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());
Macros
Allows to cast only when needed.
Structs
Struct containing a component information (temperature and name for the moment).
Struct containing a disk information.
Type containing read and written bytes.
A group id wrapping a platform specific type
A struct representing system load average value.
Contains network information.
Network interfaces.
Iterator over network interfaces.
Struct containing a process’ information.
Struct containing a processor information.
Used to determine what you want to refresh specifically on System
type.
Struct containing the system’s information.
A user id wrapping a platform specific type
Type containing user information.
Enums
Enum containing the different supported disks types.
Enum describing the different status of a process.
An enum representing signals 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 received and transmitted data.
Interacting with network interfaces.
Contains all the methods of the Process
struct.
Contains all the methods of the Processor
struct.
Contains all the methods of the System
type.
Getting information for a user.
Functions
Returns the pid for the current process.
This function is only used on linux targets, on the other platforms it does nothing and returns
false
.
Type Definitions
Process id.