Crate sysinfo[][src]

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_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());

Structs

Component

More information can be found at kernel.org.

Disk

Struct containing a disk information.

DiskUsage

Type containing read and written bytes.

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 type.

System

Structs containing system’s information.

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 signal on UNIX-like systems.

Traits

AsU32

Trait to have a common fallback for the Pid type.

ComponentExt

Getting a component temperature information.

DiskExt

Contains all the methods of the Disk struct.

NetworkExt

Getting volume of received and transmitted data.

NetworksExt

Interacting with network interfaces.

ProcessExt

Contains all the methods of the Process struct.

ProcessorExt

Contains all the methods of the Processor struct.

SystemExt

Contains all the methods of the System type.

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 false.

Type Definitions

Pid

Process id.