Skip to content

Commit

Permalink
basic system chart
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimryndin committed Jun 15, 2024
1 parent c817f88 commit fab42b1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/services/system/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,25 @@ pub(super) fn collect(
)
.expect("assert: system boot time timestamp should be valid");
let basic = [
("boot_time".to_string(), Datavalue::Datetime(boot_time)),
(
"memory_available".to_string(),
Datavalue::Size(sys.available_memory()),
),
(
MEMORY_USE.to_string(),
// SAFE for percentage calculation to cast from u64 to f64
Datavalue::HeatmapPercent(100.0 * sys.used_memory() as f64 / total_memory as f64),
),
(
"swap_available".to_string(),
Datavalue::Size(sys.free_swap()),
),
(
SWAP_USE.to_string(),
// SAFE for percentage calculation to cast from u64 to f64
Datavalue::HeatmapPercent(100.0 * sys.used_swap() as f64 / sys.total_swap() as f64),
),
("boot_time".to_string(), Datavalue::Datetime(boot_time)),
(
"memory_available".to_string(),
Datavalue::Size(sys.available_memory()),
),
(
"swap_available".to_string(),
Datavalue::Size(sys.free_swap()),
),
(
"num_of_processes".to_string(),
Datavalue::Integer(
Expand All @@ -252,7 +252,7 @@ pub(super) fn collect(
)
});

let basic_values: Vec<(String, Datavalue)> = basic.into_iter().chain(cpus).collect();
let basic_values: Vec<(String, Datavalue)> = cpus.into_iter().chain(basic).collect();

// 1 for basic, 5 for top_ stats, 1 for network
let mut datarows = Vec::with_capacity(1 + mounts.len() + 5 + names.len() + 1);
Expand Down

0 comments on commit fab42b1

Please sign in to comment.