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.get_processes() { println!("{}:{} => status: {:?}", pid, proc_.name(), proc_.status()); } // Then let's print the temperature of the different components: for component in system.get_components() { 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()); // Display system information: println!("System name: {:?}", system.get_name()); println!("System kernel version: {:?}", system.get_kernel_version()); println!("System OS version: {:?}", system.get_os_version()); println!("System host name: {:?}", system.get_host_name());
Macros
auto_cast | Allows to cast only when needed. |
Structs
Component | Struct containing a component information (temperature and name for the moment). |
Disk | Struct containing a disk information. |
DiskUsage | Type containing read and written bytes. |
Gid | A group id wrapping a platform specific type |
LoadAvg | A struct representing system load average value. |
NetworkData | Contains network information. |
Networks | Network interfaces. |
NetworksIter | Iterator over network interfaces. |
Process | Struct containing a process’ information. |
Processor | Struct containing a processor information. |
RefreshKind | Used to determine what you want to refresh specifically on |
System | Struct containing the system’s information. |
Uid | A user id wrapping a platform specific type |
User | Type containing user information. |
Enums
DiskType | Enum containing the different supported disks types. |
ProcessStatus | Enum describing the different status of a process. |
Signal | An enum representing signals on UNIX-like systems. |
Traits
AsU32 | Trait to have a common fallback for the |
ComponentExt | Getting a component temperature information. |
DiskExt | Contains all the methods of the |
NetworkExt | Getting volume of received and transmitted data. |
NetworksExt | Interacting with network interfaces. |
ProcessExt | Contains all the methods of the |
ProcessorExt | Contains all the methods of the |
SystemExt | Contains all the methods of the |
UserExt | Getting information for a user. |
Functions
get_current_pid | Returns the pid for the current process. |
set_open_files_limit | This function is only used on linux targets, on the other platforms it does nothing and returns
|
Type Definitions
Pid | Process id. |