remove unused import. / clippy cleanup
This commit is contained in:
parent
0210b49219
commit
47eff3a75c
@ -1,7 +1,5 @@
|
|||||||
//! Metrics collection using sysinfo for socktop_agent.
|
//! Metrics collection using sysinfo for socktop_agent.
|
||||||
|
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
use crate::gpu::collect_all_gpus;
|
use crate::gpu::collect_all_gpus;
|
||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
@ -12,6 +10,8 @@ use once_cell::sync::OnceCell;
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
use std::fs;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
@ -802,44 +802,44 @@ fn enumerate_child_processes_lightweight(
|
|||||||
// On non-Linux, we have to iterate through all processes in sysinfo
|
// On non-Linux, we have to iterate through all processes in sysinfo
|
||||||
// This is less efficient but maintains cross-platform compatibility
|
// This is less efficient but maintains cross-platform compatibility
|
||||||
for (child_pid, child_process) in system.processes() {
|
for (child_pid, child_process) in system.processes() {
|
||||||
if let Some(parent) = child_process.parent() {
|
if let Some(parent) = child_process.parent()
|
||||||
if parent.as_u32() == parent_pid {
|
&& parent.as_u32() == parent_pid
|
||||||
let child_info = DetailedProcessInfo {
|
{
|
||||||
pid: child_pid.as_u32(),
|
let child_info = DetailedProcessInfo {
|
||||||
name: child_process.name().to_string_lossy().to_string(),
|
pid: child_pid.as_u32(),
|
||||||
command: child_process
|
name: child_process.name().to_string_lossy().to_string(),
|
||||||
.cmd()
|
command: child_process
|
||||||
.iter()
|
.cmd()
|
||||||
.map(|s| s.to_string_lossy().to_string())
|
.iter()
|
||||||
.collect::<Vec<_>>()
|
.map(|s| s.to_string_lossy().to_string())
|
||||||
.join(" "),
|
.collect::<Vec<_>>()
|
||||||
cpu_usage: child_process.cpu_usage(),
|
.join(" "),
|
||||||
mem_bytes: child_process.memory(),
|
cpu_usage: child_process.cpu_usage(),
|
||||||
virtual_mem_bytes: child_process.virtual_memory(),
|
mem_bytes: child_process.memory(),
|
||||||
shared_mem_bytes: None,
|
virtual_mem_bytes: child_process.virtual_memory(),
|
||||||
thread_count: child_process
|
shared_mem_bytes: None,
|
||||||
.tasks()
|
thread_count: child_process
|
||||||
.map(|tasks| tasks.len() as u32)
|
.tasks()
|
||||||
.unwrap_or(0),
|
.map(|tasks| tasks.len() as u32)
|
||||||
fd_count: None,
|
.unwrap_or(0),
|
||||||
status: format!("{:?}", child_process.status()),
|
fd_count: None,
|
||||||
parent_pid: Some(parent_pid),
|
status: format!("{:?}", child_process.status()),
|
||||||
// On non-Linux platforms, sysinfo UID/GID might not be accurate
|
parent_pid: Some(parent_pid),
|
||||||
// Just use 0 as placeholder since we can't read /proc
|
// On non-Linux platforms, sysinfo UID/GID might not be accurate
|
||||||
user_id: 0,
|
// Just use 0 as placeholder since we can't read /proc
|
||||||
group_id: 0,
|
user_id: 0,
|
||||||
start_time: child_process.start_time(),
|
group_id: 0,
|
||||||
cpu_time_user: 0, // Not available on non-Linux in our implementation
|
start_time: child_process.start_time(),
|
||||||
cpu_time_system: 0,
|
cpu_time_user: 0, // Not available on non-Linux in our implementation
|
||||||
read_bytes: Some(child_process.disk_usage().read_bytes),
|
cpu_time_system: 0,
|
||||||
write_bytes: Some(child_process.disk_usage().written_bytes),
|
read_bytes: Some(child_process.disk_usage().read_bytes),
|
||||||
working_directory: child_process.cwd().map(|p| p.to_string_lossy().to_string()),
|
write_bytes: Some(child_process.disk_usage().written_bytes),
|
||||||
executable_path: child_process.exe().map(|p| p.to_string_lossy().to_string()),
|
working_directory: child_process.cwd().map(|p| p.to_string_lossy().to_string()),
|
||||||
child_processes: Vec::new(),
|
executable_path: child_process.exe().map(|p| p.to_string_lossy().to_string()),
|
||||||
threads: Vec::new(), // Not collected for non-Linux
|
child_processes: Vec::new(),
|
||||||
};
|
threads: Vec::new(), // Not collected for non-Linux
|
||||||
children.push(child_info);
|
};
|
||||||
}
|
children.push(child_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user