feat: add uptime to title
it will be displayed somewhere else later, hopefully with better formatting too.
This commit is contained in:
parent
79aff51856
commit
534b6cde99
2 changed files with 22 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
|||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SysinfoSnapshot {
|
||||
uptime: u64,
|
||||
|
||||
pub cpu_total: f32,
|
||||
pub cpus: Vec<f32>,
|
||||
|
||||
|
|
@ -8,10 +12,17 @@ pub struct SysinfoSnapshot {
|
|||
pub swap: u64,
|
||||
pub swap_total: u64,
|
||||
}
|
||||
impl SysinfoSnapshot {
|
||||
pub fn uptime(&self) -> Duration {
|
||||
Duration::from_secs(self.uptime)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&sysinfo::System> for SysinfoSnapshot {
|
||||
fn from(value: &sysinfo::System) -> Self {
|
||||
Self {
|
||||
uptime: sysinfo::System::uptime(),
|
||||
|
||||
cpu_total: value.global_cpu_usage(),
|
||||
cpus: value.cpus().iter().map(|cpu| cpu.cpu_usage()).collect(),
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue