Finished network polling.
This commit is contained in:
parent
ac85c42ce9
commit
8da38c061d
|
@ -17,10 +17,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let mut list_of_timed_memory : Vec<mem::MemData> = Vec::new();
|
||||
let mut list_of_timed_swap : Vec<mem::MemData> = Vec::new();
|
||||
let mut list_of_timed_temperature : Vec<temperature::TimedTempData> = Vec::new();
|
||||
let mut list_of_timed_network : Vec<network::TimedNetworkData> = Vec::new();
|
||||
|
||||
loop {
|
||||
println!("Start data loop...");
|
||||
sys.refresh_system();
|
||||
sys.refresh_network();
|
||||
|
||||
// TODO: Get data, potentially store? Use a result to check!
|
||||
let list_of_processes = processes::get_sorted_processes_list(processes::ProcessSorting::CPU, true).await;
|
||||
|
@ -82,6 +84,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
}
|
||||
|
||||
list_of_timed_network.push(network::get_network_data(&sys));
|
||||
if !list_of_timed_network.is_empty() {
|
||||
let current_network = list_of_timed_network.last().unwrap();
|
||||
println!("Network: {} rx, {} tx at {:?}", current_network.rx, current_network.tx, current_network.time);
|
||||
}
|
||||
|
||||
// Send to drawing module
|
||||
println!("End data loop...");
|
||||
window::draw_terminal();
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
use sysinfo::{NetworkExt, System, SystemExt};
|
||||
|
||||
pub struct TimedNetworkData {
|
||||
pub rx : u32,
|
||||
pub tx : u32,
|
||||
pub rx : u64,
|
||||
pub tx : u64,
|
||||
pub time : std::time::SystemTime,
|
||||
}
|
||||
|
||||
pub fn get_network_data() -> TimedNetworkData {
|
||||
pub fn get_network_data(sys : &System) -> TimedNetworkData {
|
||||
let network_data = sys.get_network();
|
||||
TimedNetworkData {
|
||||
rx : 0,
|
||||
tx : 0,
|
||||
rx : network_data.get_income(),
|
||||
tx : network_data.get_outcome(),
|
||||
time : std::time::SystemTime::now(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue