diff --git a/src/main.rs b/src/main.rs index 5e0d558..6fde423 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,16 +42,6 @@ impl Default for DiskDeltaTracker { } impl DiskDeltaTracker { - pub fn delta_all(&mut self, disks: BTreeMap) -> (u64, u64) { - let mut r_tot : u64 = 0; - let mut w_tot : u64 = 0; - for drive in disks.values() { - r_tot += drive.read_sectors as u64; - w_tot += drive.write_sectors as u64; - } - return self.delta(r_tot, w_tot); - } - pub fn delta(&mut self, r: u64, w: u64) -> (u64, u64) { let out = (r - self.r, w - self.w); self.r = r; @@ -149,7 +139,8 @@ async fn stats_delta( let net_tracker = store_disk.get_mut(&session).unwrap(); let disks = sys.block_device_statistics().map_err(to_403_err)?; - (disk_r, disk_w) = net_tracker.delta_all(disks); + let disk = disks.get("sda2").ok_or(Unauthorized(Some("not found".to_string())))?; + (disk_r, disk_w) = net_tracker.delta(disk.read_sectors as u64, disk.write_sectors as u64); } Ok(Json(SystemInfoView { @@ -167,7 +158,7 @@ async fn stats_delta( async fn stats_total() -> Json { let sys = System::new(); - let (net_tx, net_rx) = match sys.network_stats(&"enp5s0".to_string()) { + let (net_tx, net_rx) = match sys.network_stats(&"eth0".to_string()) { Ok(stats) => (stats.tx_bytes.as_u64(), stats.rx_bytes.as_u64()), Err(_e) => (0, 0), };