Fix issue with missing CPU...

This commit is contained in:
ClementTsang 2020-02-17 23:15:14 -05:00
parent e7ed8088b5
commit 40900d91ba
2 changed files with 8 additions and 7 deletions

View file

@ -10,11 +10,15 @@ pub type CPUHarvest = Vec<CPUData>;
pub fn get_cpu_data_list(sys: &System) -> CPUHarvest {
let cpu_data = sys.get_processors();
let mut cpu_vec = Vec::new();
let avg_cpu_usage = sys.get_global_processor_info().get_cpu_usage();
let mut cpu_vec = vec![CPUData {
cpu_name: "AVG".to_string(),
cpu_usage: avg_cpu_usage as f64,
}];
for cpu in cpu_data {
cpu_vec.push(CPUData {
cpu_name: cpu.get_name().to_string(),
cpu_name: cpu.get_name().to_uppercase(),
cpu_usage: f64::from(cpu.get_cpu_usage()),
});
}

View file

@ -120,11 +120,8 @@ pub fn convert_cpu_data_points(
let itx_offset = itx - cpu_listing_offset;
if cpu_data_vector.len() <= itx_offset {
cpu_data_vector.push(ConvertedCpuData::default());
cpu_data_vector[itx_offset].cpu_name = if show_avg_cpu && itx_offset == 0 {
"AVG".to_string()
} else {
current_data.cpu_harvest[itx].cpu_name.to_uppercase()
};
cpu_data_vector[itx_offset].cpu_name =
current_data.cpu_harvest[itx].cpu_name.clone();
}
//Insert joiner points