[][src]Struct rsys::Rsys

pub struct Rsys(_, _);

Main interface that allows for os-agnostic api.

Implementations

impl Rsys[src]

pub fn new() -> Self[src]

Creates a new instance of Rsys

pub fn hostname(&self) -> Result<String>[src]

Returns a hostname.

  • linux
    • by reading /proc/sys/kernel/hostname
  • macos
    • by calling sysctl("kern.hostname")
  • windows
    • by calling win32 api GetComputerNameA

pub fn uptime(&self) -> Result<u64>[src]

Returns time since boot in seconds.

  • linux
    • by reading /proc/uptime
  • macos
    • by calling sysctl("kern.boottime")
  • windows
    • by calling win32 api GetTickCount64

pub fn os(&self) -> String[src]

Returns operating system. Reexported env::consts::OS for convenience.

pub fn arch(&self) -> Result<String>[src]

Returns cpu architecture.

  • linux and macos
    • by calling uname -m
  • windows
    • by calling win32 api GetSystemInfo

pub fn cpu(&self) -> Result<String>[src]

Returns a cpu model name.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("machdep.cpu.brand_string") ...

pub fn cpu_clock(&self) -> Result<f32>[src]

Returns clock speed of cpu.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("hw.cpufrequency") ...

pub fn cpu_cores(&self) -> Result<u16>[src]

Returns cpu cores.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("hw.physicalcpu")
  • windows
    • by determining if cpu is hyperthreaded and calculating from logical cores.

pub fn logical_cores(&self) -> Result<u16>[src]

Returns logical cpu cores.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("hw.logicalcpu")
  • windows
    • by calling win32 api GetSystemInfo

pub fn memory_total(&self) -> Result<usize>[src]

Returns total ram memory.

  • linux
    • by reading /proc/meminfo
  • macos
    • by calling sysctl("hw.memsize")
  • windows
    • by calling win32 api GlobalMemoryStatusEx

pub fn memory_free(&self) -> Result<usize>[src]

Returns free ram memory.

  • linux
    • by reading /proc/meminfo ...

pub fn swap_total(&self) -> Result<usize>[src]

Returns total swap size.

  • linux
    • by reading /proc/meminfo
  • macos
    • by calling sysctl("hw.swapusage")
  • windows
    • by calling win32 api GlobalMemoryStatusEx

pub fn swap_free(&self) -> Result<usize>[src]

Returns free swap size.

  • linux
    • by reading /proc/meminfo
  • macos
    • by calling sysctl("hw.swapusage")
  • windows
    • by calling win32 api GlobalMemoryStatusEx

pub fn default_iface(&self) -> Result<String>[src]

Returns a default internet interface.

  • linux
    • by calling route and determining default route
  • macos
    • by calling route get default ...

pub fn ipv4(&self, iface: &str) -> Result<String>[src]

Returns IP address version 4 of interface iface.

  • linux
    • by calling ip address show <iface>
  • macos
    • by calling ipconfig getifaddr <iface> ...

pub fn ipv6(&self, iface: &str) -> Result<String>[src]

Returns IP address version 6 of interface iface.

pub fn mac(&self, iface: &str) -> Result<String>[src]

Returns a MAC address of interface iface.

  • linux
    • by calling ip address show <iface> ...

pub fn interfaces(&self) -> Result<Vec<String>>[src]

Returns a vector of names of network interfaces that are available.

  • linux
    • by calling ip address show ...

pub fn domainname(&self) -> Result<String>[src]

Returns a domain name.

  • linux
    • by reading /proc/sys/kernel/domainname
  • windows
    • by calling win32 api NetWkstaGetInfo ...

pub fn stat_block_device(&self, name: &str) -> Result<StorageDevice>[src]

Parses a StorageDevice object from system. If the provided name doesn't start with sd returns an error.

pub fn stat_scsi_cdrom(&self, name: &str) -> Result<ScsiCdrom>[src]

Parses a DeviceMapper object from system. If the provided name doesn't start with dm returns an error.

pub fn stat_device_mapper(&self, name: &str) -> Result<DeviceMapper>[src]

Parses a ScsiCdrom object from system. If the provided name doesn't start with sr returns an error.

pub fn stat_multiple_device_storage(
    &self,
    name: &str
) -> Result<MultipleDeviceStorage>
[src]

Parses a MultipleDeviceStorage object from system. If the provided name doesn't start with md returns an error.

pub fn block_size(&self, name: &str) -> Result<i64>[src]

Returns block size of device in bytes

pub fn memory(&self) -> Result<Memory>[src]

Returns detailed information about memory

pub fn stat_process(&self, pid: i32) -> Result<Process>[src]

Returns detailed Process information parsed from /proc/[pid]/stat

pub fn pids(&self) -> Result<Vec<i32>>[src]

Returns a list of pids read from /proc

pub fn processes(&self) -> Result<Processes>[src]

Returns all processes currently seen in /proc parsed as Processes

pub fn kernel_version(&self) -> Result<String>[src]

Returns kernel version of host os.

pub fn mounts(&self) -> Result<MountPoints>[src]

Returns MountPoints read from /proc/mounts

pub fn cores(&self) -> Result<Cores>[src]

Returns virtual Cores of host cpu

pub fn processor(&self) -> Result<Processor>[src]

Returns a Processor object containing gathered information about host cpu

Auto Trait Implementations

impl !RefUnwindSafe for Rsys

impl !Send for Rsys

impl !Sync for Rsys

impl Unpin for Rsys

impl !UnwindSafe for Rsys

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.