make sampling period configurable

This commit is contained in:
Ondrej Novak 2026-06-30 22:20:53 +02:00
parent be897c3681
commit 81794de504
Signed by: handy
SSH Key Fingerprint: SHA256:jlNm8ijkaMl4X7+nn3zBFTJufdQgT4unKJoZVH6kYTM
3 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,6 @@
[global]
period = 1
[[graph]]
name = "cpu load"
path = "cpu.png"

View File

@ -4,9 +4,15 @@ use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Config {
pub global: Global,
pub graph: Vec<GraphConfig>,
}
#[derive(Debug, Deserialize)]
pub struct Global {
pub period: f32,
}
#[derive(Debug, Deserialize)]
pub struct GraphConfig {
pub name: String,

View File

@ -34,7 +34,7 @@ fn main() {
if let Err(e) = r {
println!("{}", e.to_string());
}
thread::sleep(time::Duration::from_secs(1));
thread::sleep(time::Duration::from_secs_f32(config.global.period));
}
} else {
panic!("sock not found!");