mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-21 20:54:43 +02:00
Update dependencies
This commit is contained in:
parent
b9b7d61a99
commit
9913cc9fda
16
Cargo.toml
16
Cargo.toml
@ -15,25 +15,23 @@ name = "btm"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.9"
|
chrono = "0.4.10"
|
||||||
clap = "2.33.0"
|
clap = "2.33.0"
|
||||||
crossterm = "0.13"
|
crossterm = "0.13"
|
||||||
failure = "0.1.5"
|
failure = "0.1.6"
|
||||||
futures-preview = "0.3.0-alpha.18"
|
|
||||||
fern = "0.5"
|
fern = "0.5"
|
||||||
futures-timer = "0.3"
|
futures-timer = "0.3"
|
||||||
futures-util = "0.2.1"
|
futures-preview = "0.3.0-alpha.18"
|
||||||
heim = "0.0.7"
|
heim = "0.0.8"
|
||||||
heim-common = "0.0.7"
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rayon = "1.2"
|
rayon = "1.2"
|
||||||
regex = "1.3.1"
|
regex = "1.3.1"
|
||||||
sysinfo = "0.9.4"
|
sysinfo = "0.10.0"
|
||||||
tokio = "0.2.0-alpha.4"
|
tokio = "0.2.4"
|
||||||
winapi = "0.3.8"
|
winapi = "0.3.8"
|
||||||
|
|
||||||
[dependencies.tui]
|
[dependencies.tui]
|
||||||
git = "https://github.com/ClementTsang/tui-rs"
|
# git = "https://github.com/ClementTsang/tui-rs"
|
||||||
# path = "../tui-rs"
|
# path = "../tui-rs"
|
||||||
version = "0.7"
|
version = "0.7"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
@ -1,30 +1,31 @@
|
|||||||
use heim_common::prelude::StreamExt;
|
use futures::StreamExt;
|
||||||
|
use heim::units::information;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct DiskData {
|
pub struct DiskData {
|
||||||
pub name : Box<str>,
|
pub name: Box<str>,
|
||||||
pub mount_point : Box<str>,
|
pub mount_point: Box<str>,
|
||||||
pub free_space : u64,
|
pub free_space: u64,
|
||||||
pub used_space : u64,
|
pub used_space: u64,
|
||||||
pub total_space : u64,
|
pub total_space: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct IOData {
|
pub struct IOData {
|
||||||
pub mount_point : Box<str>,
|
pub mount_point: Box<str>,
|
||||||
pub read_bytes : u64,
|
pub read_bytes: u64,
|
||||||
pub write_bytes : u64,
|
pub write_bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct IOPackage {
|
pub struct IOPackage {
|
||||||
pub io_hash : std::collections::HashMap<String, IOData>,
|
pub io_hash: std::collections::HashMap<String, IOData>,
|
||||||
pub instant : Instant,
|
pub instant: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Result<IOPackage> {
|
pub async fn get_io_usage_list(get_physical: bool) -> crate::utils::error::Result<IOPackage> {
|
||||||
let mut io_hash : std::collections::HashMap<String, IOData> = std::collections::HashMap::new();
|
let mut io_hash: std::collections::HashMap<String, IOData> = std::collections::HashMap::new();
|
||||||
if get_physical {
|
if get_physical {
|
||||||
let mut physical_counter_stream = heim::disk::io_counters_physical();
|
let mut physical_counter_stream = heim::disk::io_counters_physical();
|
||||||
while let Some(io) = physical_counter_stream.next().await {
|
while let Some(io) = physical_counter_stream.next().await {
|
||||||
@ -33,14 +34,13 @@ pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Resu
|
|||||||
io_hash.insert(
|
io_hash.insert(
|
||||||
mount_point.to_string(),
|
mount_point.to_string(),
|
||||||
IOData {
|
IOData {
|
||||||
mount_point : Box::from(mount_point),
|
mount_point: Box::from(mount_point),
|
||||||
read_bytes : io.read_bytes().get::<heim_common::units::information::megabyte>(),
|
read_bytes: io.read_bytes().get::<information::megabyte>(),
|
||||||
write_bytes : io.write_bytes().get::<heim_common::units::information::megabyte>(),
|
write_bytes: io.write_bytes().get::<information::megabyte>(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let mut counter_stream = heim::disk::io_counters();
|
let mut counter_stream = heim::disk::io_counters();
|
||||||
while let Some(io) = counter_stream.next().await {
|
while let Some(io) = counter_stream.next().await {
|
||||||
let io = io?;
|
let io = io?;
|
||||||
@ -48,9 +48,9 @@ pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Resu
|
|||||||
io_hash.insert(
|
io_hash.insert(
|
||||||
mount_point.to_string(),
|
mount_point.to_string(),
|
||||||
IOData {
|
IOData {
|
||||||
mount_point : Box::from(mount_point),
|
mount_point: Box::from(mount_point),
|
||||||
read_bytes : io.read_bytes().get::<heim_common::units::information::byte>(),
|
read_bytes: io.read_bytes().get::<information::byte>(),
|
||||||
write_bytes : io.write_bytes().get::<heim_common::units::information::byte>(),
|
write_bytes: io.write_bytes().get::<information::byte>(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -58,12 +58,12 @@ pub async fn get_io_usage_list(get_physical : bool) -> crate::utils::error::Resu
|
|||||||
|
|
||||||
Ok(IOPackage {
|
Ok(IOPackage {
|
||||||
io_hash,
|
io_hash,
|
||||||
instant : Instant::now(),
|
instant: Instant::now(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>> {
|
pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>> {
|
||||||
let mut vec_disks : Vec<DiskData> = Vec::new();
|
let mut vec_disks: Vec<DiskData> = Vec::new();
|
||||||
let mut partitions_stream = heim::disk::partitions_physical();
|
let mut partitions_stream = heim::disk::partitions_physical();
|
||||||
|
|
||||||
while let Some(part) = partitions_stream.next().await {
|
while let Some(part) = partitions_stream.next().await {
|
||||||
@ -72,11 +72,11 @@ pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>>
|
|||||||
let usage = heim::disk::usage(partition.mount_point().to_path_buf()).await?;
|
let usage = heim::disk::usage(partition.mount_point().to_path_buf()).await?;
|
||||||
|
|
||||||
vec_disks.push(DiskData {
|
vec_disks.push(DiskData {
|
||||||
free_space : usage.free().get::<heim_common::units::information::megabyte>(),
|
free_space: usage.free().get::<information::megabyte>(),
|
||||||
used_space : usage.used().get::<heim_common::units::information::megabyte>(),
|
used_space: usage.used().get::<information::megabyte>(),
|
||||||
total_space : usage.total().get::<heim_common::units::information::megabyte>(),
|
total_space: usage.total().get::<information::megabyte>(),
|
||||||
mount_point : Box::from(partition.mount_point().to_str().unwrap_or("Name Unavailable")),
|
mount_point: Box::from(partition.mount_point().to_str().unwrap_or("Name Unavailable")),
|
||||||
name : Box::from(
|
name: Box::from(
|
||||||
partition
|
partition
|
||||||
.device()
|
.device()
|
||||||
.unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable"))
|
.unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable"))
|
||||||
@ -90,11 +90,9 @@ pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>>
|
|||||||
vec_disks.sort_by(|a, b| {
|
vec_disks.sort_by(|a, b| {
|
||||||
if a.name < b.name {
|
if a.name < b.name {
|
||||||
std::cmp::Ordering::Less
|
std::cmp::Ordering::Less
|
||||||
}
|
} else if a.name > b.name {
|
||||||
else if a.name > b.name {
|
|
||||||
std::cmp::Ordering::Greater
|
std::cmp::Ordering::Greater
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::cmp::Ordering::Equal
|
std::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use heim_common::units::information;
|
use heim::units::information;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
use heim_common::{prelude::StreamExt, units::thermodynamic_temperature};
|
use futures::StreamExt;
|
||||||
|
use heim::units::thermodynamic_temperature;
|
||||||
use sysinfo::{ComponentExt, System, SystemExt};
|
use sysinfo::{ComponentExt, System, SystemExt};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct TempData {
|
pub struct TempData {
|
||||||
pub component_name : Box<str>,
|
pub component_name: Box<str>,
|
||||||
pub temperature : f32,
|
pub temperature: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -20,16 +21,16 @@ impl Default for TemperatureType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -> crate::utils::error::Result<Vec<TempData>> {
|
pub async fn get_temperature_data(sys: &System, temp_type: &TemperatureType) -> crate::utils::error::Result<Vec<TempData>> {
|
||||||
let mut temperature_vec : Vec<TempData> = Vec::new();
|
let mut temperature_vec: Vec<TempData> = Vec::new();
|
||||||
|
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
let mut sensor_data = heim::sensors::temperatures();
|
let mut sensor_data = heim::sensors::temperatures();
|
||||||
while let Some(sensor) = sensor_data.next().await {
|
while let Some(sensor) = sensor_data.next().await {
|
||||||
if let Ok(sensor) = sensor {
|
if let Ok(sensor) = sensor {
|
||||||
temperature_vec.push(TempData {
|
temperature_vec.push(TempData {
|
||||||
component_name : Box::from(sensor.unit()),
|
component_name: Box::from(sensor.unit()),
|
||||||
temperature : match temp_type {
|
temperature: match temp_type {
|
||||||
TemperatureType::Celsius => sensor.current().get::<thermodynamic_temperature::degree_celsius>(),
|
TemperatureType::Celsius => sensor.current().get::<thermodynamic_temperature::degree_celsius>(),
|
||||||
TemperatureType::Kelvin => sensor.current().get::<thermodynamic_temperature::kelvin>(),
|
TemperatureType::Kelvin => sensor.current().get::<thermodynamic_temperature::kelvin>(),
|
||||||
TemperatureType::Fahrenheit => sensor.current().get::<thermodynamic_temperature::degree_fahrenheit>(),
|
TemperatureType::Fahrenheit => sensor.current().get::<thermodynamic_temperature::degree_fahrenheit>(),
|
||||||
@ -37,13 +38,12 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if cfg!(target_os = "windows") {
|
||||||
else if cfg!(target_os = "windows") {
|
|
||||||
let sensor_data = sys.get_components_list();
|
let sensor_data = sys.get_components_list();
|
||||||
for component in sensor_data {
|
for component in sensor_data {
|
||||||
temperature_vec.push(TempData {
|
temperature_vec.push(TempData {
|
||||||
component_name : Box::from(component.get_label()),
|
component_name: Box::from(component.get_label()),
|
||||||
temperature : match temp_type {
|
temperature: match temp_type {
|
||||||
TemperatureType::Celsius => component.get_temperature(),
|
TemperatureType::Celsius => component.get_temperature(),
|
||||||
TemperatureType::Kelvin => component.get_temperature() + 273.15,
|
TemperatureType::Kelvin => component.get_temperature() + 273.15,
|
||||||
TemperatureType::Fahrenheit => (component.get_temperature() * (9.0 / 5.0)) + 32.0,
|
TemperatureType::Fahrenheit => (component.get_temperature() * (9.0 / 5.0)) + 32.0,
|
||||||
@ -58,11 +58,9 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
|
|||||||
temperature_vec.sort_by(|a, b| {
|
temperature_vec.sort_by(|a, b| {
|
||||||
if a.temperature > b.temperature {
|
if a.temperature > b.temperature {
|
||||||
std::cmp::Ordering::Less
|
std::cmp::Ordering::Less
|
||||||
}
|
} else if a.temperature < b.temperature {
|
||||||
else if a.temperature < b.temperature {
|
|
||||||
std::cmp::Ordering::Greater
|
std::cmp::Ordering::Greater
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::cmp::Ordering::Equal
|
std::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -70,11 +68,9 @@ pub async fn get_temperature_data(sys : &System, temp_type : &TemperatureType) -
|
|||||||
temperature_vec.sort_by(|a, b| {
|
temperature_vec.sort_by(|a, b| {
|
||||||
if a.component_name > b.component_name {
|
if a.component_name > b.component_name {
|
||||||
std::cmp::Ordering::Greater
|
std::cmp::Ordering::Greater
|
||||||
}
|
} else if a.component_name < b.component_name {
|
||||||
else if a.component_name < b.component_name {
|
|
||||||
std::cmp::Ordering::Less
|
std::cmp::Ordering::Less
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::cmp::Ordering::Equal
|
std::cmp::Ordering::Equal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user