Skip to main content

Crate linux_procfs

Crate linux_procfs 

Source
Expand description

The linux-procfs crate is the data snap library for the /proc/ filesystem on the linux os.

This crate reads from /proc filesystem, scanne it, stores the value into the struct and returns it. This scans and holds only the required values.

§Usage

§Setup

Add the following to your Cargo.toml:

[dependencies]
linux-procfs = "0.3.17"

§Example 1: load average

use linux_procfs::System;
let mut sys = System::new("/");
let loadavg = sys.get_loadavg().unwrap();
println!("{}, {}, {}, {}", loadavg.a1, loadavg.a5, loadavg.a15, loadavg.last_pid);

§Example 2: disk stats

use linux_procfs::System;
let mut sys = System::new("/");
let diskstats = sys.get_diskstats().unwrap();
for disk in diskstats.disks {
    println!("{}, {}, {}", disk.name, disk.rblk, disk.wblk);
}

Re-exports§

pub use crate::error::ProcError;
pub use crate::error::ProcResult;

Modules§

cpufreqs
diskstats
error
loadavg
meminfo
netdevs
pidentries
stat
uptime
vmstat

Structs§

System
system interface of linux-procfs
SystemConfig

Constants§

DEFAULT_CAPACITY_CPUFREQ
DEFAULT_CAPACITY_CPUFREQ_STATS
DEFAULT_CAPACITY_DISKSTATS
DEFAULT_CAPACITY_LOADAVG
DEFAULT_CAPACITY_MEMINFO
DEFAULT_CAPACITY_NETDEVS
DEFAULT_CAPACITY_PID_CMDLINE
DEFAULT_CAPACITY_PID_COMM
DEFAULT_CAPACITY_PID_STAT
DEFAULT_CAPACITY_PID_STATM
DEFAULT_CAPACITY_PID_STATUS
DEFAULT_CAPACITY_STAT
DEFAULT_CAPACITY_UPTIME
DEFAULT_CAPACITY_VMSTAT

Type Aliases§

Pid