Update cargo deps
This commit is contained in:
parent
35ad80dc13
commit
4a00d93759
18
Cargo.toml
18
Cargo.toml
@ -8,12 +8,12 @@ license = "MIT"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5", features = ["derive"] }
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
sysinfo = "0.29.11"
|
sysinfo = "0.33"
|
||||||
tabled = "0.14.0"
|
tabled = "0.17"
|
||||||
serde = { version = "1.0.193", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
dirs = "5.0.1"
|
dirs = "6.0.0"
|
||||||
serde_json = "1.0.108"
|
serde_json = "1.0"
|
||||||
crossterm = "0.28.1"
|
crossterm = "0.28"
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18"
|
||||||
ctrlc = "3.4.5"
|
ctrlc = "3.4"
|
||||||
windows-sys = "0.36.1"
|
windows-sys = "0.59"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::config::dump::DumpConfig;
|
use crate::config::dump::DumpConfig;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sysinfo::{ProcessExt, System, SystemExt, UserExt};
|
use sysinfo::System;
|
||||||
use tabled::{Table, Tabled};
|
use tabled::{Table, Tabled};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
@ -83,8 +83,7 @@ pub fn read_pmr_processes() -> Vec<PmrProcess> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_processes(system: bool) {
|
pub fn list_processes(system: bool) {
|
||||||
let mut sys = System::new();
|
let sys = System::new_all();
|
||||||
sys.refresh_all();
|
|
||||||
|
|
||||||
if system {
|
if system {
|
||||||
let processes: Vec<ProcessInfo> = sys
|
let processes: Vec<ProcessInfo> = sys
|
||||||
@ -92,7 +91,7 @@ pub fn list_processes(system: bool) {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|(&pid, process)| ProcessInfo {
|
.map(|(&pid, process)| ProcessInfo {
|
||||||
id: "0".to_string(),
|
id: "0".to_string(),
|
||||||
name: process.name().to_string(),
|
name: process.name().to_str().unwrap_or("unknown").to_string(),
|
||||||
namespace: "default".to_string(),
|
namespace: "default".to_string(),
|
||||||
version: "N/A".to_string(),
|
version: "N/A".to_string(),
|
||||||
pid: pid.to_string(),
|
pid: pid.to_string(),
|
||||||
@ -101,10 +100,7 @@ pub fn list_processes(system: bool) {
|
|||||||
status: process.status().to_string(),
|
status: process.status().to_string(),
|
||||||
cpu: format!("{:.1}%", process.cpu_usage()),
|
cpu: format!("{:.1}%", process.cpu_usage()),
|
||||||
mem: format!("{:.1} MB", process.memory() as f64 / 1024.0 / 1024.0),
|
mem: format!("{:.1} MB", process.memory() as f64 / 1024.0 / 1024.0),
|
||||||
user: process
|
user: "N/A".to_string(),
|
||||||
.user_id()
|
|
||||||
.and_then(|uid| sys.get_user_by_id(uid))
|
|
||||||
.map_or("N/A".to_string(), |u| u.name().to_string()),
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@ -130,10 +126,7 @@ pub fn list_processes(system: bool) {
|
|||||||
status: "running".to_string(),
|
status: "running".to_string(),
|
||||||
cpu: format!("{:.1}%", sys_proc.cpu_usage()),
|
cpu: format!("{:.1}%", sys_proc.cpu_usage()),
|
||||||
mem: format!("{:.1} MB", sys_proc.memory() as f64 / 1024.0 / 1024.0),
|
mem: format!("{:.1} MB", sys_proc.memory() as f64 / 1024.0 / 1024.0),
|
||||||
user: sys_proc
|
user: "N/A".to_string(),
|
||||||
.user_id()
|
|
||||||
.and_then(|uid| sys.get_user_by_id(uid))
|
|
||||||
.map_or("N/A".to_string(), |u| u.name().to_string()),
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 进程不存在,但PID > 0,说明进程已经退出
|
// 进程不存在,但PID > 0,说明进程已经退出
|
||||||
|
Loading…
x
Reference in New Issue
Block a user