pub struct Rsys(/* private fields */);
Expand description
Main interface that allows for os-agnostic api.
Implementations§
Source§impl Rsys
impl Rsys
Sourcepub fn hostname(&self) -> Result<String>
pub fn hostname(&self) -> Result<String>
Returns a hostname.
- linux
- by reading
/proc/sys/kernel/hostname
- by reading
- macos
- by calling
sysctl("kern.hostname")
- by calling
- windows
- by calling win32 api
GetComputerNameA
- by calling win32 api
Sourcepub fn uptime(&self) -> Result<u64>
pub fn uptime(&self) -> Result<u64>
Returns time since boot in seconds.
- linux
- by reading
/proc/uptime
- by reading
- macos
- by calling
sysctl("kern.boottime")
- by calling
- windows
- by calling win32 api
GetTickCount64
- by calling win32 api
Sourcepub fn os(&self) -> String
pub fn os(&self) -> String
Returns operating system. Reexported env::consts::OS
for convenience.
Sourcepub fn arch(&self) -> Result<String>
pub fn arch(&self) -> Result<String>
Returns cpu architecture.
- linux and macos
- by calling
uname -m
- by calling
- windows
- by calling win32 api
GetSystemInfo
- by calling win32 api
Sourcepub fn cpu(&self) -> Result<String>
pub fn cpu(&self) -> Result<String>
Returns a cpu model name.
- linux
- by reading
/proc/cpuinfo
- by reading
- macos
- by calling
sysctl("machdep.cpu.brand_string")
…
- by calling
Sourcepub fn cpu_clock(&self) -> Result<f32>
pub fn cpu_clock(&self) -> Result<f32>
Returns clock speed of cpu.
- linux
- by reading
/proc/cpuinfo
- by reading
- macos
- by calling
sysctl("hw.cpufrequency")
…
- by calling
Sourcepub fn cpu_cores(&self) -> Result<u16>
pub fn cpu_cores(&self) -> Result<u16>
Returns cpu cores.
- linux
- by reading
/proc/cpuinfo
- by reading
- macos
- by calling
sysctl("hw.physicalcpu")
- by calling
- windows
- by determining if cpu is hyperthreaded and calculating from logical cores.
Sourcepub fn logical_cores(&self) -> Result<u16>
pub fn logical_cores(&self) -> Result<u16>
Returns logical cpu cores.
- linux
- by reading
/proc/cpuinfo
- by reading
- macos
- by calling
sysctl("hw.logicalcpu")
- by calling
- windows
- by calling win32 api
GetSystemInfo
- by calling win32 api
Sourcepub fn memory_total(&self) -> Result<usize>
pub fn memory_total(&self) -> Result<usize>
Returns total ram memory.
- linux
- by reading
/proc/meminfo
- by reading
- macos
- by calling
sysctl("hw.memsize")
- by calling
- windows
- by calling win32 api
GlobalMemoryStatusEx
- by calling win32 api
Sourcepub fn memory_free(&self) -> Result<usize>
pub fn memory_free(&self) -> Result<usize>
Returns free ram memory.
- linux
- by reading
/proc/meminfo
…
- by reading
Sourcepub fn swap_total(&self) -> Result<usize>
pub fn swap_total(&self) -> Result<usize>
Returns total swap size.
- linux
- by reading
/proc/meminfo
- by reading
- macos
- by calling
sysctl("hw.swapusage")
- by calling
- windows
- by calling win32 api
GlobalMemoryStatusEx
- by calling win32 api
Sourcepub fn swap_free(&self) -> Result<usize>
pub fn swap_free(&self) -> Result<usize>
Returns free swap size.
- linux
- by reading
/proc/meminfo
- by reading
- macos
- by calling
sysctl("hw.swapusage")
- by calling
- windows
- by calling win32 api
GlobalMemoryStatusEx
- by calling win32 api
Sourcepub fn default_iface(&self) -> Result<String>
pub fn default_iface(&self) -> Result<String>
Returns a default internet interface.
- linux
- by calling
route
and determining default route
- by calling
- macos
- by calling
route get default
…
- by calling
Sourcepub fn ipv4(&self, iface: &str) -> Result<String>
pub fn ipv4(&self, iface: &str) -> Result<String>
Returns IP address version 4 of interface iface.
- linux
- by calling
ip address show <iface>
- by calling
- macos
- by calling
ipconfig getifaddr <iface>
…
- by calling
Sourcepub fn ipv6(&self, iface: &str) -> Result<String>
pub fn ipv6(&self, iface: &str) -> Result<String>
Returns IP address version 6 of interface iface.
Sourcepub fn mac(&self, iface: &str) -> Result<String>
pub fn mac(&self, iface: &str) -> Result<String>
Returns a MAC address of interface iface.
- linux
- by calling
ip address show <iface>
…
- by calling
Sourcepub fn interfaces(&self) -> Result<Vec<String>>
pub fn interfaces(&self) -> Result<Vec<String>>
Returns a vector of names of network interfaces that are available.
- linux
- by calling
ip address show
…
- by calling
Sourcepub fn domainname(&self) -> Result<String>
pub fn domainname(&self) -> Result<String>
Returns a domain name.
- linux
- by reading
/proc/sys/kernel/domainname
- by reading
- windows
- by calling win32 api
NetWkstaGetInfo
…
- by calling win32 api
Sourcepub fn stat_block_device(&self, name: &str) -> Result<StorageDevice>
pub fn stat_block_device(&self, name: &str) -> Result<StorageDevice>
Parses a StorageDevice object from system. If the provided name
doesn’t start with sd
returns an error.
Sourcepub fn stat_scsi_cdrom(&self, name: &str) -> Result<ScsiCdrom>
pub fn stat_scsi_cdrom(&self, name: &str) -> Result<ScsiCdrom>
Parses a DeviceMapper object from system. If the provided name
doesn’t start with dm
returns an error.
Sourcepub fn stat_device_mapper(&self, name: &str) -> Result<DeviceMapper>
pub fn stat_device_mapper(&self, name: &str) -> Result<DeviceMapper>
Parses a ScsiCdrom object from system. If the provided name
doesn’t start with sr
returns an error.
Sourcepub fn stat_multiple_device_storage(
&self,
name: &str,
) -> Result<MultipleDeviceStorage>
pub fn stat_multiple_device_storage( &self, name: &str, ) -> Result<MultipleDeviceStorage>
Parses a MultipleDeviceStorage object from system. If the provided name
doesn’t start with md
returns an error.
Sourcepub fn block_size(&self, name: &str) -> Result<i64>
pub fn block_size(&self, name: &str) -> Result<i64>
Returns block size of device in bytes
Sourcepub fn stat_process(&self, pid: i32) -> Result<Process>
pub fn stat_process(&self, pid: i32) -> Result<Process>
Returns detailed Process information parsed from /proc/[pid]/stat
Sourcepub fn processes(&self) -> Result<Processes>
pub fn processes(&self) -> Result<Processes>
Returns all processes currently seen in /proc parsed as Processes
Sourcepub fn kernel_version(&self) -> Result<String>
pub fn kernel_version(&self) -> Result<String>
Returns kernel version of host os.
Sourcepub fn mounts(&self) -> Result<MountPoints>
pub fn mounts(&self) -> Result<MountPoints>
Returns MountPoints read from /proc/mounts
Sourcepub fn processor(&self) -> Result<Processor>
pub fn processor(&self) -> Result<Processor>
Returns a Processor object containing gathered information about host cpu
Sourcepub fn ifaces(&self) -> Result<Interfaces>
pub fn ifaces(&self) -> Result<Interfaces>
Returns network interfaces on host os