peach-workspace/peach-stats/README.md

53 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2021-08-06 17:58:40 +00:00
# peach-stats
2022-01-25 09:39:28 +00:00
![Generic badge](https://img.shields.io/badge/version-0.3.0-<COLOR>.svg)
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
System statistics library for PeachCloud. Provides a wrapper around the [probes](https://crates.io/crates/probes) and [systemstat](https://crates.io/crates/systemstat) crates.
2021-08-06 17:58:40 +00:00
2022-01-25 09:39:28 +00:00
Currently offers the following system statistics and associated data structures:
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
- 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`
2021-08-06 17:58:40 +00:00
2022-01-25 09:39:28 +00:00
As well as the following go-sbot process statistics:
- Sbot: `state`, `memory`, `uptime`, `downtime`
2021-12-09 07:44:27 +00:00
## Example Usage
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
```rust
2022-01-25 09:39:28 +00:00
use peach_stats::{sbot, stats, StatsError};
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
fn main() -> Result<(), StatsError> {
2021-12-13 05:19:05 +00:00
let cpu = stats::cpu_stats()?;
let cpu_percentages = stats::cpu_stats_percent()?;
let disks = stats::disk_usage()?;
let load = stats::load_average()?;
let mem = stats::mem_stats()?;
let uptime = stats::uptime()?;
2022-01-25 09:39:28 +00:00
let sbot_process = sbot::sbot_stats()?;
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
// do things with the retrieved values...
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
Ok(())
}
```
2021-08-06 17:58:40 +00:00
2021-12-09 07:54:53 +00:00
## 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:
```toml
peach-stats = { version = "0.1.0", features = ["miniserde_support"] }
```
2021-12-09 07:44:27 +00:00
## License
2021-08-06 17:58:40 +00:00
2021-12-09 07:44:27 +00:00
LGPL-3.0.