feat: client-server mode
This commit is contained in:
parent
171194e99f
commit
a689366324
7 changed files with 119 additions and 28 deletions
23
src/server/mod.rs
Normal file
23
src/server/mod.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use std::{io::Write, thread};
|
||||
|
||||
use ron::{Error, ser};
|
||||
|
||||
use crate::sysinfo_snapshot::SysinfoSnapshot;
|
||||
|
||||
pub fn run() -> Result<(), Error> {
|
||||
let mut sys = sysinfo::System::new();
|
||||
let refreshes = sysinfo::RefreshKind::nothing()
|
||||
.with_memory(sysinfo::MemoryRefreshKind::everything())
|
||||
.with_cpu(sysinfo::CpuRefreshKind::nothing().with_cpu_usage());
|
||||
|
||||
sys.refresh_specifics(refreshes);
|
||||
thread::sleep(sysinfo::MINIMUM_CPU_UPDATE_INTERVAL);
|
||||
|
||||
let mut stdout = std::io::stdout();
|
||||
|
||||
loop {
|
||||
sys.refresh_specifics(refreshes);
|
||||
stdout.write_all((ser::to_string(&SysinfoSnapshot::from(&sys))? + "\n").as_bytes())?;
|
||||
thread::sleep(sysinfo::MINIMUM_CPU_UPDATE_INTERVAL);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue