mem stats: rescale from kb to bytes (#21282)

This commit is contained in:
Jeff Washington (jwash) 2021-11-15 14:42:41 -06:00 committed by GitHub
parent d8a392c20b
commit f2bd9947cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -186,16 +186,22 @@ impl SystemMonitorService {
fn report_mem_stats() { fn report_mem_stats() {
if let Ok(info) = sys_info::mem_info() { if let Ok(info) = sys_info::mem_info() {
// stats are returned in kb.
const KB: u64 = 1_024;
datapoint_info!( datapoint_info!(
"memory-stats", "memory-stats",
("total", info.total, i64), ("total", info.total * KB, i64),
("swap_total", info.swap_total, i64), ("swap_total", info.swap_total, i64),
( (
"free_percent", "free_percent",
Self::calc_percent(info.free, info.total), Self::calc_percent(info.free, info.total),
f64 f64
), ),
("used_bytes", info.total.saturating_sub(info.avail), i64), (
"used_bytes",
info.total.saturating_sub(info.avail) * KB,
i64
),
( (
"avail_percent", "avail_percent",
Self::calc_percent(info.avail, info.total), Self::calc_percent(info.avail, info.total),