uptick: 0.5.6 (#362)

This commit is contained in:
Clement Tsang 2020-12-17 15:42:08 -08:00 committed by GitHub
parent 682f6493d1
commit bfdaa09e3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 19 deletions

View File

@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Bug Fixes
## [0.5.6] - Unreleased
## [0.5.6] - 2020-12-17
## Bug Fixes

2
Cargo.lock generated
View File

@ -233,7 +233,7 @@ dependencies = [
[[package]]
name = "bottom"
version = "0.5.5"
version = "0.5.6"
dependencies = [
"anyhow",
"assert_cmd",

View File

@ -1,6 +1,6 @@
[package]
name = "bottom"
version = "0.5.5"
version = "0.5.6"
authors = ["Clement Tsang <cjhtsang@uwaterloo.ca>"]
edition = "2018"
repository = "https://github.com/ClementTsang/bottom"

View File

@ -87,8 +87,8 @@ cd bottom
cargo install --path .
# Download from releases and install
curl -LO https://github.com/ClementTsang/bottom/archive/0.5.5.tar.gz
tar -xzvf 0.5.5.tar.gz
curl -LO https://github.com/ClementTsang/bottom/archive/0.5.6.tar.gz
tar -xzvf 0.5.6.tar.gz
cargo install --path .
```
@ -120,8 +120,8 @@ yay -S bottom-bin
A `.deb` file is provided on each [release](https://github.com/ClementTsang/bottom/releases/latest):
```bash
curl -LO https://github.com/ClementTsang/bottom/releases/download/0.5.5/bottom_0.5.5_amd64.deb
sudo dpkg -i bottom_0.5.5_amd64.deb
curl -LO https://github.com/ClementTsang/bottom/releases/download/0.5.6/bottom_0.5.6_amd64.deb
sudo dpkg -i bottom_0.5.6_amd64.deb
```
### Fedora/CentOS
@ -175,7 +175,7 @@ to appear.
choco install bottom
# Version number may be required for newer releases, if available:
choco install bottom --version=0.5.5
choco install bottom --version=0.5.6
```
### winget
@ -759,13 +759,13 @@ Thanks to all contributors ([emoji key](https://allcontributors.org/docs/en/emoj
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## Thanks
- This project is very much inspired by both
[gotop](https://github.com/cjbassi/gotop), its successor
[ytop](https://github.com/cjbassi/ytop), and [gtop](https://github.com/aksakalli/gtop).
- This project is very much inspired by [gotop](https://github.com/cjbassi/gotop),
its successor [ytop](https://github.com/cjbassi/ytop), and [gtop](https://github.com/aksakalli/gtop).
- Basic mode is heavily inspired by [htop's](https://hisham.hm/htop/) design.

View File

@ -135,6 +135,11 @@ impl DataCollector {
self.sys.refresh_components_list();
}
// Refresh network list once...
if cfg!(target_os = "windows") && self.widgets_to_harvest.use_net {
self.sys.refresh_networks_list();
}
if self.widgets_to_harvest.use_battery {
// trace!("First run battery vec creation.");
if let Ok(battery_manager) = Manager::new() {
@ -188,6 +193,9 @@ impl DataCollector {
self.sys.refresh_components();
}
}
if cfg!(target_os = "windows") && self.widgets_to_harvest.use_net {
self.sys.refresh_networks();
}
let current_instant = std::time::Instant::now();
@ -233,15 +241,28 @@ impl DataCollector {
}
}
// I am *well* aware that the sysinfo part w/ blocking code is... not great.
let network_data_fut = {
network::get_network_data(
self.last_collection_time,
&mut self.total_rx,
&mut self.total_tx,
current_instant,
self.widgets_to_harvest.use_net,
)
#[cfg(target_os = "windows")]
{
network::get_network_data(
&self.sys,
self.last_collection_time,
&mut self.total_rx,
&mut self.total_tx,
current_instant,
self.widgets_to_harvest.use_net,
)
}
#[cfg(not(target_os = "windows"))]
{
network::get_network_data(
self.last_collection_time,
&mut self.total_rx,
&mut self.total_tx,
current_instant,
self.widgets_to_harvest.use_net,
)
}
};
let mem_data_fut = mem::get_mem_data(self.widgets_to_harvest.use_mem);
let disk_data_fut = disks::get_disk_usage(self.widgets_to_harvest.use_disk);

View File

@ -15,6 +15,48 @@ impl NetworkHarvest {
}
}
#[cfg(target_os = "windows")]
pub async fn get_network_data(
sys: &sysinfo::System, prev_net_access_time: Instant, prev_net_rx: &mut u64,
prev_net_tx: &mut u64, curr_time: Instant, actually_get: bool,
) -> crate::utils::error::Result<Option<NetworkHarvest>> {
use sysinfo::{NetworkExt, SystemExt};
if !actually_get {
return Ok(None);
}
let mut total_rx: u64 = 0;
let mut total_tx: u64 = 0;
let networks = sys.get_networks();
for (_, network) in networks {
total_rx += network.get_total_received();
total_tx += network.get_total_transmitted();
}
let elapsed_time = curr_time.duration_since(prev_net_access_time).as_secs_f64();
let (rx, tx) = if elapsed_time == 0.0 {
(0, 0)
} else {
(
((total_rx.saturating_sub(*prev_net_rx)) as f64 / elapsed_time) as u64,
((total_tx.saturating_sub(*prev_net_tx)) as f64 / elapsed_time) as u64,
)
};
*prev_net_rx = total_rx;
*prev_net_tx = total_tx;
Ok(Some(NetworkHarvest {
rx,
tx,
total_rx,
total_tx,
}))
}
#[cfg(not(target_os = "windows"))]
pub async fn get_network_data(
prev_net_access_time: Instant, prev_net_rx: &mut u64, prev_net_tx: &mut u64,
curr_time: Instant, actually_get: bool,