[][src]Crate procfs

This crate provides to an interface into the linux procfs filesystem, usually mounted at /proc.

This is a pseudo-filesystem which is available on most every linux system and provides an interface to kernel data structures.

Kernel support

Not all fields/data are available in each kernel. Some fields were added in specific kernel releases, and other fields are only present in certain kernel configuration options are enabled. These are represented as Option fields in this crate.

This crate aims to support all 2.6 kernels (and newer).

Documentation

In almost all cases, the documentation is taken from the proc.5 manual page. This means that sometimes the style of writing is not very "rusty", or may do things like reference related files (instead of referencing related structs). Contributions to improve this are welcome.

Panicing

While previous versions of the library could panic, this current version aims to be panic-free in a many situations as possible. Whenever the procfs crate encounters a bug in its own parsing code, it will return an InternalError error. This should be considered a bug and should be reported. If you encounter a panic, please report that as well.

Cargo features

The following cargo features are available:

  • chrono -- Default. Optional. This feature enables a few methods that return values as DateTime objects.
  • backtrace -- Optional. This feature lets you get a stack trace whenever an InternalError is raised.

Examples

Examples can be found in the various modules shown below.

Re-exports

pub use crate::sys::kernel::Version as KernelVersion;

Modules

net

Information about the networking layer.

process

Functions and structs related to process information

sys

Sysctl is a means of configuring certain aspects of the kernel at run-time, and the /proc/sys/ directory is there so that you don't even need special tools to do it!

Structs

CGroupController

Container group controller information.

CpuInfo

Represents the data from /proc/cpuinfo.

CpuPressure

CPU pressure information

CpuTime

The amount of time, measured in seconds, the CPU has been in specific states

DiskStat

Disk IO stat information

InternalError

An internal error in the procfs crate

IoPressure

IO pressure information

KernelModule
KernelStats

Kernel/system statistics, from /proc/stat

LoadAverage

Load average figures.

Meminfo

This struct reports statistics about memory usage on the system, based on the /proc/meminfo file.

MemoryPressure

Memory pressure information

PressureRecord

Pressure stall information for either CPU, memory, or IO.

ProcessCgroup

Information about a process cgroup

Enums

ConfigSetting

Possible values for a kernel config option

ProcError

The various error conditions in the procfs crate.

Functions

boot_time

The boottime of the system, as a DateTime object.

boot_time_secs

The boottime of the system, in seconds since the epoch

cgroups

Information about the cgroup controllers that are compiled into the kernel

cpu_pressureDeprecated

Get CPU pressure information

cpuinfoDeprecated

Get CPU info, from /proc/cpuinfo

diskstats

Get disk IO stat info from /proc/diskstats

io_pressureDeprecated

Get IO pressure information

kernel_config

Returns a configuration options used to build the currently running kernel

memory_pressureDeprecated

Get memory pressure information

modules

Get a list of loaded kernel modules

page_size

Memory page size, in bytes.

ticks_per_second

Return the number of ticks per second.

vmstat

Get various vritual memory statistics

Type Definitions

ProcResult

The main error type for the procfs crate.