summaryrefslogtreecommitdiffstats
path: root/src/app/data_harvester/processes/linux.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/data_harvester/processes/linux.rs')
-rw-r--r--src/app/data_harvester/processes/linux.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/app/data_harvester/processes/linux.rs b/src/app/data_harvester/processes/linux.rs
index 8f50823b..0a1ed539 100644
--- a/src/app/data_harvester/processes/linux.rs
+++ b/src/app/data_harvester/processes/linux.rs
@@ -250,6 +250,12 @@ fn read_proc(
uid,
user,
time,
+ #[cfg(feature = "gpu")]
+ gpu_mem: 0,
+ #[cfg(feature = "gpu")]
+ gpu_mem_percent: 0.0,
+ #[cfg(feature = "gpu")]
+ gpu_util: 0,
},
new_process_times,
))
@@ -326,7 +332,8 @@ pub(crate) fn linux_process_data(
let pid = process.pid;
let prev_proc_details = pid_mapping.entry(pid).or_default();
- if let Ok((process_harvest, new_process_times)) = read_proc(
+ #[allow(unused_mut)]
+ if let Ok((mut process_harvest, new_process_times)) = read_proc(
prev_proc_details,
process,
cpu_usage,
@@ -336,6 +343,23 @@ pub(crate) fn linux_process_data(
total_memory,
user_table,
) {
+ #[cfg(feature = "gpu")]
+ if let Some(gpus) = &collector.gpu_pids {
+ gpus.iter().for_each(|gpu| {
+ // add mem/util for all gpus to pid
+ if let Some((mem, util)) = gpu.get(&(pid as u32)) {
+ process_harvest.gpu_mem += mem;
+ process_harvest.gpu_util += util;
+ }
+ });
+ if let Some(gpu_total_mem) = &collector.gpus_total_mem {
+ process_harvest.gpu_mem_percent = (process_harvest.gpu_mem as f64
+ / *gpu_total_mem as f64
+ * 100.0)
+ as f32;
+ }
+ }
+
prev_proc_details.cpu_time = new_process_times;
prev_proc_details.total_read_bytes = process_harvest.total_read_bytes;
prev_proc_details.total_write_bytes = process_harvest.total_write_bytes;