fmt
parent
1c1252ecfe
commit
c59ac23997
|
|
@ -5,58 +5,39 @@ use metrics_models::MetricsMode;
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
#[arg(
|
#[arg(
|
||||||
short,
|
short,
|
||||||
default_value="noxis-rs.sock",
|
default_value = "noxis-rs.sock",
|
||||||
help="explicit specify of NOXIS Socket file"
|
help = "explicit specify of NOXIS Socket file"
|
||||||
)]
|
)]
|
||||||
pub socket : String,
|
pub socket: String,
|
||||||
#[command(
|
#[command(subcommand, help = "to manage Noxis work")]
|
||||||
subcommand,
|
pub command: Commands,
|
||||||
help = "to manage Noxis work",
|
|
||||||
)]
|
|
||||||
pub command : Commands,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Subcommand, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Subcommand, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum Commands {
|
pub enum Commands {
|
||||||
#[command(
|
#[command(about = "To get info about current Noxis status")]
|
||||||
about = "To get info about current Noxis status",
|
|
||||||
)]
|
|
||||||
Status,
|
Status,
|
||||||
#[command(
|
#[command(about = "To start Noxis process")]
|
||||||
about = "To start Noxis process",
|
|
||||||
)]
|
|
||||||
Start(StartAction),
|
Start(StartAction),
|
||||||
#[command(
|
#[command(about = "To stop Noxis process")]
|
||||||
about = "To stop Noxis process",
|
|
||||||
)]
|
|
||||||
Stop,
|
Stop,
|
||||||
#[command(
|
#[command(about = "To restart Noxis process")]
|
||||||
about = "To restart Noxis process",
|
|
||||||
)]
|
|
||||||
Restart(StartAction),
|
Restart(StartAction),
|
||||||
#[command(
|
#[command(about = "To get list of processes that are being monitoring")]
|
||||||
about = "To get list of processes that are being monitoring",
|
|
||||||
)]
|
|
||||||
Processes,
|
Processes,
|
||||||
// process command
|
// process command
|
||||||
#[command(
|
#[command(about = "To manage current process that is being monitoring")]
|
||||||
about = "To manage current process that is being monitoring",
|
|
||||||
)]
|
|
||||||
Process(ProcessCommand),
|
Process(ProcessCommand),
|
||||||
#[command(
|
#[command(about = "To manage config settings")]
|
||||||
about = "To manage config settings",
|
|
||||||
)]
|
|
||||||
Config(ConfigCommand),
|
Config(ConfigCommand),
|
||||||
#[command(
|
#[command(about = "To inspect system metrics in restricted mode")]
|
||||||
about = "To inspect system metrics in restricted mode",
|
|
||||||
)]
|
|
||||||
Inspect(MetricsCommand),
|
Inspect(MetricsCommand),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct MetricsCommand {
|
pub struct MetricsCommand {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub mode : MetricsMode,
|
pub mode: MetricsMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
||||||
|
|
@ -66,150 +47,92 @@ pub struct StartAction {
|
||||||
num_args = 1..,
|
num_args = 1..,
|
||||||
value_delimiter = ' '
|
value_delimiter = ' '
|
||||||
)]
|
)]
|
||||||
pub flags : Vec<String>,
|
pub flags: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct ConfigCommand {
|
pub struct ConfigCommand {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
pub action : ConfigAction,
|
pub action: ConfigAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Subcommand, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Subcommand, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ConfigAction {
|
pub enum ConfigAction {
|
||||||
#[command(
|
#[command(about = "To change current Noxis configuration")]
|
||||||
about = "To change current Noxis configuration",
|
|
||||||
)]
|
|
||||||
Local(LocalConfig),
|
Local(LocalConfig),
|
||||||
#[command(
|
#[command(about = "To change credentials of the remote config server")]
|
||||||
about = "To change credentials of the remote config server",
|
|
||||||
)]
|
|
||||||
Remote,
|
Remote,
|
||||||
#[command(
|
#[command(about = "To reset all config settings")]
|
||||||
about = "To reset all config settings",
|
|
||||||
)]
|
|
||||||
Reset,
|
Reset,
|
||||||
#[command(
|
#[command(about = "To get current Noxis configuration", name = "ls")]
|
||||||
about = "To get current Noxis configuration",
|
|
||||||
name = "ls"
|
|
||||||
)]
|
|
||||||
Show(EnvConfig),
|
Show(EnvConfig),
|
||||||
}
|
}
|
||||||
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct EnvConfig {
|
pub struct EnvConfig {
|
||||||
// flag
|
// flag
|
||||||
#[arg(
|
#[arg(long = "env", action, help = "to read environment vars configuration")]
|
||||||
long = "env",
|
pub is_env: bool,
|
||||||
action,
|
|
||||||
help = "to read environment vars configuration",
|
|
||||||
)]
|
|
||||||
pub is_env : bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct LocalConfig {
|
pub struct LocalConfig {
|
||||||
// flag
|
// flag
|
||||||
#[arg(
|
#[arg(long = "json", action, help = "to read following input as JSON")]
|
||||||
long = "json",
|
pub is_json: bool,
|
||||||
action,
|
|
||||||
help = "to read following input as JSON",
|
|
||||||
)]
|
|
||||||
pub is_json : bool,
|
|
||||||
// value
|
// value
|
||||||
#[arg(
|
#[arg(help = "path to config file or config String (with --json flag)")]
|
||||||
help = "path to config file or config String (with --json flag)",
|
pub config: String,
|
||||||
)]
|
|
||||||
pub config : String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct ProcessCommand {
|
pub struct ProcessCommand {
|
||||||
#[arg(
|
#[arg(help = "name of needed process")]
|
||||||
help = "name of needed process",
|
pub process: String,
|
||||||
)]
|
#[command(subcommand, help = "To get current process's status")]
|
||||||
pub process : String,
|
pub action: ProcessAction,
|
||||||
#[command(
|
|
||||||
subcommand,
|
|
||||||
help = "To get current process's status",
|
|
||||||
)]
|
|
||||||
pub action : ProcessAction,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Subcommand, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Subcommand, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum ProcessAction {
|
pub enum ProcessAction {
|
||||||
#[command(
|
#[command(about = "To get info about current process status")]
|
||||||
about = "To get info about current process status",
|
|
||||||
)]
|
|
||||||
Status,
|
Status,
|
||||||
#[command(
|
#[command(about = "To start current process")]
|
||||||
about = "To start current process",
|
|
||||||
)]
|
|
||||||
Start,
|
Start,
|
||||||
#[command(
|
#[command(about = "To stop current process")]
|
||||||
about = "To stop current process",
|
|
||||||
)]
|
|
||||||
Stop,
|
Stop,
|
||||||
#[command(
|
#[command(about = "To freeze (hybernaze) current process")]
|
||||||
about = "To freeze (hybernaze) current process",
|
|
||||||
)]
|
|
||||||
Freeze,
|
Freeze,
|
||||||
#[command(
|
#[command(about = "To unfreeze (unhybernaze) current process")]
|
||||||
about = "To unfreeze (unhybernaze) current process",
|
|
||||||
)]
|
|
||||||
Unfreeze,
|
Unfreeze,
|
||||||
#[command(
|
#[command(about = "To restart current process")]
|
||||||
about = "To restart current process",
|
|
||||||
)]
|
|
||||||
Restart,
|
Restart,
|
||||||
#[command(
|
#[command(about = "To get info about current process's dependencies")]
|
||||||
about = "To get info about current process's dependencies",
|
|
||||||
)]
|
|
||||||
Deps,
|
Deps,
|
||||||
#[command(
|
#[command(about = "To get info about current process's files-dependencies")]
|
||||||
about = "To get info about current process's files-dependencies",
|
|
||||||
)]
|
|
||||||
Files,
|
Files,
|
||||||
#[command(
|
#[command(about = "To get info about current process's services-dependencies")]
|
||||||
about = "To get info about current process's services-dependencies",
|
|
||||||
)]
|
|
||||||
Services,
|
Services,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod metrics_models {
|
pub mod metrics_models {
|
||||||
#[derive(Debug, clap::Parser, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, clap::Parser, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum MetricsMode {
|
pub enum MetricsMode {
|
||||||
#[command(
|
#[command(about = "To capture all metrics about undercontrolled system")]
|
||||||
about = "To capture all metrics about undercontrolled system",
|
|
||||||
)]
|
|
||||||
Full,
|
Full,
|
||||||
// system
|
// system
|
||||||
#[command(
|
#[command(about = "To capture general host info")]
|
||||||
about = "To capture general host info",
|
|
||||||
)]
|
|
||||||
Host,
|
Host,
|
||||||
#[command(
|
#[command(about = "To capture detailed CPU metrics")]
|
||||||
about = "To capture detailed CPU metrics",
|
|
||||||
)]
|
|
||||||
Cpu,
|
Cpu,
|
||||||
#[command(
|
#[command(about = "To capture RAM metrics")]
|
||||||
about = "To capture RAM metrics",
|
|
||||||
)]
|
|
||||||
Ram,
|
Ram,
|
||||||
#[command(
|
#[command(about = "To capture disk environment metrics")]
|
||||||
about = "To capture disk environment metrics",
|
|
||||||
)]
|
|
||||||
Rom,
|
Rom,
|
||||||
#[command(
|
#[command(about = "To capture system net interfaces metrics")]
|
||||||
about = "To capture system net interfaces metrics",
|
|
||||||
)]
|
|
||||||
Network,
|
Network,
|
||||||
// processes
|
// processes
|
||||||
#[command(
|
#[command(about = "To capture monitoring processes metrics")]
|
||||||
about = "To capture monitoring processes metrics",
|
Processes, // Config
|
||||||
)]
|
|
||||||
Processes
|
|
||||||
// Config
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,5 @@ pub enum NoxisCliError {
|
||||||
#[error("Can't parse CLI struct and send as byte stream")]
|
#[error("Can't parse CLI struct and send as byte stream")]
|
||||||
ToStringCliParsingParsing,
|
ToStringCliParsingParsing,
|
||||||
#[error("Can't read Noxis response due to {0}")]
|
#[error("Can't read Noxis response due to {0}")]
|
||||||
CliResponseReadError(String)
|
CliResponseReadError(String),
|
||||||
}
|
}
|
||||||
|
|
@ -1,26 +1,30 @@
|
||||||
use tokio::net::UnixStream;
|
|
||||||
use tokio::io::{AsyncWriteExt, AsyncReadExt};
|
|
||||||
use anyhow::Result;
|
|
||||||
use super::Cli;
|
|
||||||
use super::cli_error::NoxisCliError;
|
use super::cli_error::NoxisCliError;
|
||||||
|
use super::Cli;
|
||||||
|
use anyhow::Result;
|
||||||
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
use tokio::net::UnixStream;
|
||||||
|
|
||||||
async fn create_us_stream(cli: &Cli) -> Result<UnixStream> {
|
async fn create_us_stream(cli: &Cli) -> Result<UnixStream> {
|
||||||
Ok(UnixStream::connect(&cli.socket).await.map_err(|er| NoxisCliError::NoxisDaemonMissing((&cli.socket).to_string(), er.to_string()))?)
|
Ok(UnixStream::connect(&cli.socket).await.map_err(|er| {
|
||||||
|
NoxisCliError::NoxisDaemonMissing((&cli.socket).to_string(), er.to_string())
|
||||||
|
})?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn try_send(cli: Cli) -> Result<()> {
|
pub async fn try_send(cli: Cli) -> Result<()> {
|
||||||
// let stream = create_us_stream(&cli).await;
|
// let stream = create_us_stream(&cli).await;
|
||||||
let mut stream = create_us_stream(&cli).await?;
|
let mut stream = create_us_stream(&cli).await?;
|
||||||
|
|
||||||
let msg = serde_json::to_vec(&cli)
|
let msg = serde_json::to_vec(&cli).map_err(|_| NoxisCliError::ToStringCliParsingParsing)?;
|
||||||
.map_err(|_| NoxisCliError::ToStringCliParsingParsing)?;
|
|
||||||
|
|
||||||
stream.write_all(&msg)
|
stream
|
||||||
|
.write_all(&msg)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| NoxisCliError::CliPromptCanNotBeSent)?;
|
.map_err(|_| NoxisCliError::CliPromptCanNotBeSent)?;
|
||||||
|
|
||||||
let mut response = Vec::new();
|
let mut response = Vec::new();
|
||||||
stream.read_to_end(&mut response).await
|
stream
|
||||||
|
.read_to_end(&mut response)
|
||||||
|
.await
|
||||||
.map_err(|er| NoxisCliError::CliResponseReadError(er.to_string()))?;
|
.map_err(|er| NoxisCliError::CliResponseReadError(er.to_string()))?;
|
||||||
|
|
||||||
let response = String::from_utf8_lossy(&response);
|
let response = String::from_utf8_lossy(&response);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
mod cli_net;
|
|
||||||
mod cli_error;
|
mod cli_error;
|
||||||
|
mod cli_net;
|
||||||
|
|
||||||
pub use cli::*;
|
pub use cli::*;
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
mod cli_net;
|
|
||||||
mod cli_error;
|
mod cli_error;
|
||||||
|
mod cli_net;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::Cli;
|
use cli::Cli;
|
||||||
use cli_net::try_send;
|
use cli_net::try_send;
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()>{
|
async fn main() -> Result<()> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
let cli = Cli::parse().validate_socket();
|
let cli = Cli::parse().validate_socket();
|
||||||
try_send(cli).await?;
|
try_send(cli).await?;
|
||||||
|
|
|
||||||
|
|
@ -138,10 +138,10 @@ pub mod v2 {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub async fn extract_extended_procs(
|
pub async fn extract_extended_procs(
|
||||||
config : Arc<Processes>,
|
config: Arc<Processes>,
|
||||||
prcs_list : &LinkedList<ProcessesController>,
|
prcs_list: &LinkedList<ProcessesController>,
|
||||||
files_list : &LinkedList<FilesController>,
|
files_list: &LinkedList<FilesController>,
|
||||||
servs_list : &LinkedList<ServicesController>,
|
servs_list: &LinkedList<ServicesController>,
|
||||||
) -> Vec<ProcessesAll> {
|
) -> Vec<ProcessesAll> {
|
||||||
let mut procs = Vec::new();
|
let mut procs = Vec::new();
|
||||||
for prc in config.processes.iter() {
|
for prc in config.processes.iter() {
|
||||||
|
|
@ -278,7 +278,8 @@ pub mod v2 {
|
||||||
&self.prcs,
|
&self.prcs,
|
||||||
&self.files,
|
&self.files,
|
||||||
&self.services,
|
&self.services,
|
||||||
).await;
|
)
|
||||||
|
.await;
|
||||||
let _ = self.bus.1.clone().send(BusMessage::Response(
|
let _ = self.bus.1.clone().send(BusMessage::Response(
|
||||||
crate::options::structs::bus::BusMessageDirection::ToMetrics,
|
crate::options::structs::bus::BusMessageDirection::ToMetrics,
|
||||||
BusMessageContentType::ProcessQuery,
|
BusMessageContentType::ProcessQuery,
|
||||||
|
|
|
||||||
|
|
@ -60,14 +60,14 @@ pub async fn init_metrics_grubber(
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Unrecognized Metric mode was given");
|
warn!("Unrecognized Metric mode was given");
|
||||||
let _ = bus_sender
|
let _ = bus_sender
|
||||||
.send(BusMessage::Response(
|
.send(BusMessage::Response(
|
||||||
BusMessageDirection::ToCli,
|
BusMessageDirection::ToCli,
|
||||||
BusMessageContentType::Result,
|
BusMessageContentType::Result,
|
||||||
Box::new(Err(anyhow::Error::msg(format!(
|
Box::new(Err(anyhow::Error::msg(format!(
|
||||||
"Unrecognized Metric mode was given"
|
"Unrecognized Metric mode was given"
|
||||||
)))),
|
)))),
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
Ok(mode) => {
|
Ok(mode) => {
|
||||||
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
|
tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
|
||||||
|
|
@ -98,7 +98,7 @@ pub async fn init_metrics_grubber(
|
||||||
// inspect processes
|
// inspect processes
|
||||||
MetricsMode::Processes => {
|
MetricsMode::Processes => {
|
||||||
todo!();
|
todo!();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
// let metric: Box<dyn BusContent> = Box::new(metric);
|
// let metric: Box<dyn BusContent> = Box::new(metric);
|
||||||
let metric = metric.serialze_into_output();
|
let metric = metric.serialze_into_output();
|
||||||
|
|
@ -118,48 +118,37 @@ pub async fn init_metrics_grubber(
|
||||||
if let Ok(info) = cont.downcast::<ProcessesQuery>() {
|
if let Ok(info) = cont.downcast::<ProcessesQuery>() {
|
||||||
if let ProcessesQuery::All(info) = *info {
|
if let ProcessesQuery::All(info) = *info {
|
||||||
let procs: Vec<_> = info
|
let procs: Vec<_> = info
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|prc| ProcessExtended::from_process_query_all(&mut system, prc))
|
.map(|prc| ProcessExtended::from_process_query_all(&mut system, prc))
|
||||||
.collect();
|
.collect();
|
||||||
let _ = bus_sender
|
let _ = bus_sender
|
||||||
.send(BusMessage::Response(
|
.send(BusMessage::Response(
|
||||||
BusMessageDirection::ToCli,
|
BusMessageDirection::ToCli,
|
||||||
BusMessageContentType::Result,
|
BusMessageContentType::Result,
|
||||||
Box::<anyhow::Result<String>>::new(
|
Box::<anyhow::Result<String>>::new(Ok(serde_json::to_string_pretty(
|
||||||
Ok(serde_json::to_string_pretty(&procs)?)
|
&procs,
|
||||||
)
|
)?)),
|
||||||
),
|
))
|
||||||
)
|
.await;
|
||||||
.await;
|
|
||||||
} else {
|
} else {
|
||||||
let _ = bus_sender
|
let _ = bus_sender
|
||||||
.send(BusMessage::Response(
|
.send(BusMessage::Response(
|
||||||
BusMessageDirection::ToCli,
|
BusMessageDirection::ToCli,
|
||||||
BusMessageContentType::Result,
|
BusMessageContentType::Result,
|
||||||
Box::new(
|
Box::new(Err(anyhow::Error::msg(format!(
|
||||||
Err(
|
"Unknown type was send by the Supervisor"
|
||||||
anyhow::Error::msg(format!(
|
)))),
|
||||||
"Unknown type was send by the Supervisor"
|
))
|
||||||
)
|
.await;
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
))
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = bus_sender
|
let _ = bus_sender
|
||||||
.send(BusMessage::Response(
|
.send(BusMessage::Response(
|
||||||
BusMessageDirection::ToCli,
|
BusMessageDirection::ToCli,
|
||||||
BusMessageContentType::Result,
|
BusMessageContentType::Result,
|
||||||
Box::new(
|
Box::new(Err(anyhow::Error::msg(format!(
|
||||||
Err(
|
"Unknown type was send by the Supervisor"
|
||||||
anyhow::Error::msg(format!(
|
)))),
|
||||||
"Unknown type was send by the Supervisor"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
@ -552,37 +541,34 @@ impl ProcessExtended {
|
||||||
self.virtual_mem_usage = prc.virtual_memory();
|
self.virtual_mem_usage = prc.virtual_memory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn from_process_query_all(
|
pub fn from_process_query_all(system: &mut System, proc: processes::ProcessesAll) -> Self {
|
||||||
system: &mut System,
|
|
||||||
proc : processes::ProcessesAll
|
|
||||||
) -> Self {
|
|
||||||
system.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
system.refresh_processes(sysinfo::ProcessesToUpdate::All, true);
|
||||||
return if let Some(prc) = system.process(proc.pid.new_sysinfo_pid()) {
|
return if let Some(prc) = system.process(proc.pid.new_sysinfo_pid()) {
|
||||||
let disk_usage = prc.disk_usage();
|
let disk_usage = prc.disk_usage();
|
||||||
Self {
|
Self {
|
||||||
name: proc.name,
|
name: proc.name,
|
||||||
status: proc.state,
|
status: proc.state,
|
||||||
pid: proc.pid,
|
pid: proc.pid,
|
||||||
dependencies: proc.dependencies,
|
dependencies: proc.dependencies,
|
||||||
cpu_usage: prc.cpu_usage(),
|
cpu_usage: prc.cpu_usage(),
|
||||||
ram_usage: prc.memory(),
|
ram_usage: prc.memory(),
|
||||||
virtual_mem_usage: prc.virtual_memory(),
|
virtual_mem_usage: prc.virtual_memory(),
|
||||||
disks_usage_read_bytes: disk_usage.read_bytes,
|
disks_usage_read_bytes: disk_usage.read_bytes,
|
||||||
disks_usage_write_bytes: disk_usage.written_bytes,
|
disks_usage_write_bytes: disk_usage.written_bytes,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Self {
|
Self {
|
||||||
name: proc.name,
|
name: proc.name,
|
||||||
status: proc.state,
|
status: proc.state,
|
||||||
pid: proc.pid,
|
pid: proc.pid,
|
||||||
dependencies: proc.dependencies,
|
dependencies: proc.dependencies,
|
||||||
cpu_usage: 0.0,
|
cpu_usage: 0.0,
|
||||||
ram_usage: 0,
|
ram_usage: 0,
|
||||||
virtual_mem_usage: 0,
|
virtual_mem_usage: 0,
|
||||||
disks_usage_read_bytes: 0,
|
disks_usage_read_bytes: 0,
|
||||||
disks_usage_write_bytes: 0,
|
disks_usage_write_bytes: 0,
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue