This crate provides a safe interface for reading and writing information to the kernel using the sysctl interface.
FreeBSD, Linux, macOS and iOS are supported. Contributions for improvements and other platforms are welcome.
Documentation is available on docs.rs
 = "0.4.4"
- Due to limitations in the sysctl(3) API, many of the methods of
Ctltake a mutable reference to
- Sysctl descriptions are not available on macOS/iOS and Linux.
- Some tests failures are ignored, as the respective sysctls do not exist on macos.
sysctl comes with several examples, see the examples folder:
value.rs: shows how to get a sysctl value
value_as.rs: parsing values as structures
value_string.rs: parsing values as string. Use this for cross platform compatibility since all sysctls are strings on Linux.
value_oid_as.rs: getting a sysctl from OID constants from the
set_value.rs: shows how to set a sysctl value
struct.rs: reading data into a struct
temperature.rs: parsing temperatures
iterate.rs: showcases iteration over the sysctl tree
Or to use in your program:
extern crate sysctl; use Sysctl;