peach-workspace/peach-stats/README.md

1.4 KiB

peach-stats

Generic badge

System statistics library for PeachCloud. Provides a wrapper around the probes and systemstat crates.

Currently offers the following statistics and associated data structures:

  • CPU: user, system, nice, idle (as values or percentages)
  • Disk usage: filesystem, one_k_blocks, one_k_blocks_used, one_k_blocks_free, used_percentage, mountpoint
  • Load average: one, five, fifteen
  • Memory: total, free, used
  • Uptime: seconds

Example Usage

use peach_stats::StatsError;

fn main() -> Result<(), StatsError> {
    let cpu = peach_stats::cpu_stats()?;
    let cpu_percentages = peach_stats::cpu_stats_percent()?;
    let disks = peach_stats::disk_usage()?;
    let load = peach_stats::load_average()?;
    let mem = peach_stats::mem_stats()?;
    let uptime = peach_stats::uptime()?;

    // do things with the retrieved values...

    Ok(())
}

Feature Flags

Feature flags are used to offer Serialize and Deserialize implementations for all struct data types provided by this library. These traits are not provided by default. A choice of miniserde and serde is provided.

Define the desired feature in the Cargo.toml manifest of your project:

peach-stats = { version = "0.1.0", features = ["miniserde_support"] }

License

LGPL-3.0.