[][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::*, miscs::*, users::*};
 
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

Functions related to CPU stats

disks

Functions related to disks stats

memory

Functions related to memory stats

miscs

Functions related to diverse stats

network

Functions related to network stats

sys

Example

users

Functions related to users informations

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.