bug: add extra check for process cpu value to be >= 0
This commit is contained in:
parent
4831ec3d5c
commit
549d61b836
|
@ -288,8 +288,7 @@ pub fn linux_get_processes_list(
|
|||
.output()?;
|
||||
let ps_stdout = String::from_utf8_lossy(&ps_result.stdout);
|
||||
let split_string = ps_stdout.split('\n');
|
||||
let cpu_calc = cpu_usage_calculation(prev_idle, prev_non_idle);
|
||||
if let Ok((cpu_usage, cpu_fraction)) = cpu_calc {
|
||||
if let Ok((cpu_usage, cpu_fraction)) = cpu_usage_calculation(prev_idle, prev_non_idle) {
|
||||
let process_list = split_string.collect::<Vec<&str>>();
|
||||
|
||||
let mut new_pid_stats = HashMap::new();
|
||||
|
@ -362,7 +361,9 @@ pub fn windows_macos_get_processes_list(
|
|||
} else {
|
||||
process_val.cpu_usage() as f64 / num_cpus
|
||||
};
|
||||
let process_cpu_usage = if use_current_cpu_total {
|
||||
let process_cpu_usage = if pcu < 0.0 {
|
||||
0.0
|
||||
} else if use_current_cpu_total {
|
||||
pcu / cpu_usage
|
||||
} else {
|
||||
pcu
|
||||
|
|
|
@ -148,7 +148,7 @@ impl CpuGraphWidget for Painter {
|
|||
.enumerate()
|
||||
.rev()
|
||||
.filter_map(|(itx, (cpu, cpu_show_vec))| {
|
||||
if *cpu_show_vec {
|
||||
if *cpu_show_vec {
|
||||
Some(
|
||||
Dataset::default()
|
||||
.marker(if use_dot {
|
||||
|
|
|
@ -132,37 +132,39 @@ impl NetworkGraphWidget for Painter {
|
|||
let dataset = if app_state.app_config_fields.use_old_network_legend && !hide_legend {
|
||||
let mut ret_val = vec![];
|
||||
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(format!("RX: {:7}", app_state.canvas_data.rx_display))
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.rx_style)
|
||||
.data(&network_data_rx).graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(format!("RX: {:7}", app_state.canvas_data.rx_display))
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.rx_style)
|
||||
.data(&network_data_rx)
|
||||
.graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(format!("TX: {:7}", app_state.canvas_data.tx_display))
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.tx_style)
|
||||
.data(&network_data_tx).graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(format!(
|
||||
"Total RX: {:7}",
|
||||
app_state.canvas_data.total_rx_display
|
||||
))
|
||||
.style(self.colours.total_rx_style),
|
||||
);
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(format!("TX: {:7}", app_state.canvas_data.tx_display))
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.tx_style)
|
||||
.data(&network_data_tx)
|
||||
.graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(format!(
|
||||
"Total RX: {:7}",
|
||||
app_state.canvas_data.total_rx_display
|
||||
))
|
||||
.style(self.colours.total_rx_style),
|
||||
);
|
||||
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
|
@ -177,29 +179,31 @@ impl NetworkGraphWidget for Painter {
|
|||
} else {
|
||||
let mut ret_val = vec![];
|
||||
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(&app_state.canvas_data.rx_display)
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.rx_style)
|
||||
.data(&network_data_rx).graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(&app_state.canvas_data.rx_display)
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.rx_style)
|
||||
.data(&network_data_rx)
|
||||
.graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(&app_state.canvas_data.tx_display)
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.tx_style)
|
||||
.data(&network_data_tx).graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
ret_val.push(
|
||||
Dataset::default()
|
||||
.name(&app_state.canvas_data.tx_display)
|
||||
.marker(if app_state.app_config_fields.use_dot {
|
||||
Marker::Dot
|
||||
} else {
|
||||
Marker::Braille
|
||||
})
|
||||
.style(self.colours.tx_style)
|
||||
.data(&network_data_tx)
|
||||
.graph_type(tui::widgets::GraphType::Line),
|
||||
);
|
||||
|
||||
ret_val
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue