[][src]Crate sys_metrics

sys_metrics is a crate used to get a system's information.

It attempt to provide information about:

  • CPU
  • Disks
  • Host
  • Memory
  • Networks (wip)

Quick start

use sys_metrics::{cpu::*, disks::*, host::*};

fn main() -> Result<(), std::io::Error> {
    let host_info = match get_host_info() {
        Ok(val) => val,
        Err(x) => return Err(x),
    };

    let _uuid = get_uuid().expect("Cannot retrieve UUID");
    let _os = host_info.os_version;
    let _hostname = host_info.hostname;
    let _uptime = host_info.uptime;
    let _cpufreq = match get_cpufreq() {
        Ok(val) => val as i64,
        Err(_) => -1,
    };
    let _loadavg = host_info.loadavg;
    let _disks = match get_partitions_physical() {
        Ok(val) => Some(val),
        Err(_) => None,
    };
    let _iostats = match get_iostats() {
        Ok(val) => Some(val),
        Err(_) => None,
    };
    let _memory = host_info.memory;
    let _users = get_users();

    Ok(())
}

Modules

cpu

CPU information

disks

Disks information

host

Host system information

memory

Memory and swap information

Structs

Disks

Struct containing a disk' information.

HostInfo

Struct containing the principal host's information.

IoStats

Struct containing a disk_io (bytes read/wrtn) information.

LoadAvg

Struct containing a cpu's loadavg information.

Memory

Struct containing the memory (ram/swap) information.