mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-25 22:55:06 +02:00
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()?;
|
.output()?;
|
||||||
let ps_stdout = String::from_utf8_lossy(&ps_result.stdout);
|
let ps_stdout = String::from_utf8_lossy(&ps_result.stdout);
|
||||||
let split_string = ps_stdout.split('\n');
|
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_usage_calculation(prev_idle, prev_non_idle) {
|
||||||
if let Ok((cpu_usage, cpu_fraction)) = cpu_calc {
|
|
||||||
let process_list = split_string.collect::<Vec<&str>>();
|
let process_list = split_string.collect::<Vec<&str>>();
|
||||||
|
|
||||||
let mut new_pid_stats = HashMap::new();
|
let mut new_pid_stats = HashMap::new();
|
||||||
@ -362,7 +361,9 @@ pub fn windows_macos_get_processes_list(
|
|||||||
} else {
|
} else {
|
||||||
process_val.cpu_usage() as f64 / num_cpus
|
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
|
pcu / cpu_usage
|
||||||
} else {
|
} else {
|
||||||
pcu
|
pcu
|
||||||
|
@ -148,7 +148,7 @@ impl CpuGraphWidget for Painter {
|
|||||||
.enumerate()
|
.enumerate()
|
||||||
.rev()
|
.rev()
|
||||||
.filter_map(|(itx, (cpu, cpu_show_vec))| {
|
.filter_map(|(itx, (cpu, cpu_show_vec))| {
|
||||||
if *cpu_show_vec {
|
if *cpu_show_vec {
|
||||||
Some(
|
Some(
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.marker(if use_dot {
|
.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 dataset = if app_state.app_config_fields.use_old_network_legend && !hide_legend {
|
||||||
let mut ret_val = vec![];
|
let mut ret_val = vec![];
|
||||||
|
|
||||||
ret_val.push(
|
ret_val.push(
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(format!("RX: {:7}", app_state.canvas_data.rx_display))
|
.name(format!("RX: {:7}", app_state.canvas_data.rx_display))
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
Marker::Dot
|
Marker::Dot
|
||||||
} else {
|
} else {
|
||||||
Marker::Braille
|
Marker::Braille
|
||||||
})
|
})
|
||||||
.style(self.colours.rx_style)
|
.style(self.colours.rx_style)
|
||||||
.data(&network_data_rx).graph_type(tui::widgets::GraphType::Line),
|
.data(&network_data_rx)
|
||||||
);
|
.graph_type(tui::widgets::GraphType::Line),
|
||||||
|
);
|
||||||
|
|
||||||
ret_val.push(
|
ret_val.push(
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(format!("TX: {:7}", app_state.canvas_data.tx_display))
|
.name(format!("TX: {:7}", app_state.canvas_data.tx_display))
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
Marker::Dot
|
Marker::Dot
|
||||||
} else {
|
} else {
|
||||||
Marker::Braille
|
Marker::Braille
|
||||||
})
|
})
|
||||||
.style(self.colours.tx_style)
|
.style(self.colours.tx_style)
|
||||||
.data(&network_data_tx).graph_type(tui::widgets::GraphType::Line),
|
.data(&network_data_tx)
|
||||||
);
|
.graph_type(tui::widgets::GraphType::Line),
|
||||||
ret_val.push(
|
);
|
||||||
Dataset::default()
|
ret_val.push(
|
||||||
.name(format!(
|
Dataset::default()
|
||||||
"Total RX: {:7}",
|
.name(format!(
|
||||||
app_state.canvas_data.total_rx_display
|
"Total RX: {:7}",
|
||||||
))
|
app_state.canvas_data.total_rx_display
|
||||||
.style(self.colours.total_rx_style),
|
))
|
||||||
);
|
.style(self.colours.total_rx_style),
|
||||||
|
);
|
||||||
|
|
||||||
ret_val.push(
|
ret_val.push(
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
@ -177,29 +179,31 @@ impl NetworkGraphWidget for Painter {
|
|||||||
} else {
|
} else {
|
||||||
let mut ret_val = vec![];
|
let mut ret_val = vec![];
|
||||||
|
|
||||||
ret_val.push(
|
ret_val.push(
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(&app_state.canvas_data.rx_display)
|
.name(&app_state.canvas_data.rx_display)
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
Marker::Dot
|
Marker::Dot
|
||||||
} else {
|
} else {
|
||||||
Marker::Braille
|
Marker::Braille
|
||||||
})
|
})
|
||||||
.style(self.colours.rx_style)
|
.style(self.colours.rx_style)
|
||||||
.data(&network_data_rx).graph_type(tui::widgets::GraphType::Line),
|
.data(&network_data_rx)
|
||||||
);
|
.graph_type(tui::widgets::GraphType::Line),
|
||||||
|
);
|
||||||
|
|
||||||
ret_val.push(
|
ret_val.push(
|
||||||
Dataset::default()
|
Dataset::default()
|
||||||
.name(&app_state.canvas_data.tx_display)
|
.name(&app_state.canvas_data.tx_display)
|
||||||
.marker(if app_state.app_config_fields.use_dot {
|
.marker(if app_state.app_config_fields.use_dot {
|
||||||
Marker::Dot
|
Marker::Dot
|
||||||
} else {
|
} else {
|
||||||
Marker::Braille
|
Marker::Braille
|
||||||
})
|
})
|
||||||
.style(self.colours.tx_style)
|
.style(self.colours.tx_style)
|
||||||
.data(&network_data_tx).graph_type(tui::widgets::GraphType::Line),
|
.data(&network_data_tx)
|
||||||
);
|
.graph_type(tui::widgets::GraphType::Line),
|
||||||
|
);
|
||||||
|
|
||||||
ret_val
|
ret_val
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user