Update cargo deps

This commit is contained in:
gaofei 2025-01-15 15:07:02 +08:00
parent 35ad80dc13
commit 4a00d93759
2 changed files with 14 additions and 21 deletions

View File

@ -8,12 +8,12 @@ license = "MIT"
[dependencies]
clap = { version = "4.5", features = ["derive"] }
sysinfo = "0.29.11"
tabled = "0.14.0"
serde = { version = "1.0.193", features = ["derive"] }
dirs = "5.0.1"
serde_json = "1.0.108"
crossterm = "0.28.1"
once_cell = "1.18.0"
ctrlc = "3.4.5"
windows-sys = "0.36.1"
sysinfo = "0.33"
tabled = "0.17"
serde = { version = "1.0", features = ["derive"] }
dirs = "6.0.0"
serde_json = "1.0"
crossterm = "0.28"
once_cell = "1.18"
ctrlc = "3.4"
windows-sys = "0.59"

View File

@ -1,6 +1,6 @@
use crate::config::dump::DumpConfig;
use serde::{Deserialize, Serialize};
use sysinfo::{ProcessExt, System, SystemExt, UserExt};
use sysinfo::System;
use tabled::{Table, Tabled};
#[derive(Serialize, Deserialize)]
@ -83,8 +83,7 @@ pub fn read_pmr_processes() -> Vec<PmrProcess> {
}
pub fn list_processes(system: bool) {
let mut sys = System::new();
sys.refresh_all();
let sys = System::new_all();
if system {
let processes: Vec<ProcessInfo> = sys
@ -92,7 +91,7 @@ pub fn list_processes(system: bool) {
.iter()
.map(|(&pid, process)| ProcessInfo {
id: "0".to_string(),
name: process.name().to_string(),
name: process.name().to_str().unwrap_or("unknown").to_string(),
namespace: "default".to_string(),
version: "N/A".to_string(),
pid: pid.to_string(),
@ -101,10 +100,7 @@ pub fn list_processes(system: bool) {
status: process.status().to_string(),
cpu: format!("{:.1}%", process.cpu_usage()),
mem: format!("{:.1} MB", process.memory() as f64 / 1024.0 / 1024.0),
user: process
.user_id()
.and_then(|uid| sys.get_user_by_id(uid))
.map_or("N/A".to_string(), |u| u.name().to_string()),
user: "N/A".to_string(),
})
.collect();
@ -130,10 +126,7 @@ pub fn list_processes(system: bool) {
status: "running".to_string(),
cpu: format!("{:.1}%", sys_proc.cpu_usage()),
mem: format!("{:.1} MB", sys_proc.memory() as f64 / 1024.0 / 1024.0),
user: sys_proc
.user_id()
.and_then(|uid| sys.get_user_by_id(uid))
.map_or("N/A".to_string(), |u| u.name().to_string()),
user: "N/A".to_string(),
}
} else {
// 进程不存在但PID > 0说明进程已经退出