Further tweaking of network
This commit is contained in:
parent
1339df81e1
commit
e6b6048afb
|
@ -37,6 +37,22 @@ pub struct Data {
|
||||||
pub list_of_disks: Vec<disks::DiskData>,
|
pub list_of_disks: Vec<disks::DiskData>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Data {
|
||||||
|
pub fn first_run_cleanup(&mut self) {
|
||||||
|
self.list_of_cpu_packages = Vec::new();
|
||||||
|
self.list_of_io = Vec::new();
|
||||||
|
self.list_of_physical_io = Vec::new();
|
||||||
|
self.memory = Vec::new();
|
||||||
|
self.swap = Vec::new();
|
||||||
|
self.list_of_temperature_sensor = Vec::new();
|
||||||
|
self.list_of_processes = Vec::new();
|
||||||
|
self.grouped_list_of_processes = None;
|
||||||
|
self.list_of_disks = Vec::new();
|
||||||
|
|
||||||
|
self.network.first_run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct DataState {
|
pub struct DataState {
|
||||||
pub data: Data,
|
pub data: Data,
|
||||||
first_run: bool,
|
first_run: bool,
|
||||||
|
@ -110,7 +126,6 @@ impl DataState {
|
||||||
.get(&self.data.network.last_collection_time)
|
.get(&self.data.network.last_collection_time)
|
||||||
{
|
{
|
||||||
// If not empty, inject joining points
|
// If not empty, inject joining points
|
||||||
|
|
||||||
let rx_diff = new_network_data.rx as f64 - prev_data.0.rx as f64;
|
let rx_diff = new_network_data.rx as f64 - prev_data.0.rx as f64;
|
||||||
let tx_diff = new_network_data.tx as f64 - prev_data.0.tx as f64;
|
let tx_diff = new_network_data.tx as f64 - prev_data.0.tx as f64;
|
||||||
let time_gap = current_instant
|
let time_gap = current_instant
|
||||||
|
@ -188,7 +203,7 @@ impl DataState {
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.first_run {
|
if self.first_run {
|
||||||
self.data = Data::default();
|
self.data.first_run_cleanup();
|
||||||
self.first_run = false;
|
self.first_run = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,14 @@ impl Default for NetworkStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NetworkStorage {
|
||||||
|
pub fn first_run(&mut self) {
|
||||||
|
self.data_points = BTreeMap::default();
|
||||||
|
self.rx = 0;
|
||||||
|
self.tx = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
/// Note all values are in bytes...
|
/// Note all values are in bytes...
|
||||||
pub struct NetworkData {
|
pub struct NetworkData {
|
||||||
|
@ -68,13 +76,10 @@ pub async fn get_network_data(
|
||||||
.duration_since(*prev_net_access_time)
|
.duration_since(*prev_net_access_time)
|
||||||
.as_secs_f64();
|
.as_secs_f64();
|
||||||
|
|
||||||
if *prev_net_rx == 0 {
|
debug!(
|
||||||
*prev_net_rx = net_rx;
|
"net rx: {}, net tx: {}, net prev rx: {}, net prev tx: {}",
|
||||||
}
|
net_rx, net_tx, *prev_net_rx, *prev_net_tx
|
||||||
|
);
|
||||||
if *prev_net_tx == 0 {
|
|
||||||
*prev_net_tx = net_tx;
|
|
||||||
}
|
|
||||||
|
|
||||||
let rx = ((net_rx - *prev_net_rx) as f64 / elapsed_time) as u64;
|
let rx = ((net_rx - *prev_net_rx) as f64 / elapsed_time) as u64;
|
||||||
let tx = ((net_tx - *prev_net_tx) as f64 / elapsed_time) as u64;
|
let tx = ((net_tx - *prev_net_tx) as f64 / elapsed_time) as u64;
|
||||||
|
|
Loading…
Reference in New Issue