Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmaco committed Dec 29, 2024
1 parent f4ffbf1 commit f315025
Show file tree
Hide file tree
Showing 14 changed files with 985 additions and 393 deletions.
1,027 changes: 819 additions & 208 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 22 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,32 @@ default = []
nvidia = ["nvml-wrapper"]

[dependencies]
ratatui = { version = "0.23.*", features = ["crossterm"], default-features = false }
crossterm = "0.27.*"
byte-unit = "~4.0.19"
uzers = "0.11.3"
num-derive = "0.4.1"
ratatui = { version = "0.29.*", features = [
"crossterm",
], default-features = false }
crossterm = "0.28.*"
byte-unit = "~5.1.6"
uzers = "0.12.1"
num-derive = "0.4.2"
num-traits = "0.2"
heim = {git = "https://github.com/bvaisvil/heim.git", branch="zenith_changes", features = ["full"]}
futures = "0.3.28"
heim = { git = "https://github.com/bvaisvil/heim.git", branch = "zenith_changes", features = [
"full",
] }
futures = "0.3.31"
gumdrop = { version = "~0.8.1", features = ["default_expr"] }
chrono = "~0.4.31"
sysinfo = {git = "https://github.com/bvaisvil/sysinfo.git", branch="zenith_changes_15.1"}
chrono = "~0.4.39"
sysinfo = { git = "https://github.com/bvaisvil/sysinfo.git", branch = "zenith_changes_15.1" }
dirs-next = "2.0.0"
serde = { version = "~1.0.189", features = ["derive"] }
serde_derive = "~1.0.189"
flate2 = "1.0.28"
serde = { version = "~1.0.217", features = ["derive"] }
serde_derive = "~1.0.217"
flate2 = "1.0.35"
bincode = "1.3.3"
starship-battery = "0.8.*"
starship-battery = "0.10.*"
signal-hook = "~0.3.17"
log = "~0.4.20"
env_logger = { version = "~0.10.0", default-features = false }
log = "~0.4.22"
env_logger = { version = "~0.11.6", default-features = false }
libc = "0.2"
nvml-wrapper = { version = "0.9.0", optional = true }
unicode-width = "0.1.11"
nvml-wrapper = { version = "0.10.0", optional = true }
unicode-width = "0.2.0"
[target.'cfg(target_os = "linux")'.dependencies]
linux-taskstats = { version = "0.5.0", default-features = false }
linux-taskstats = { version = "0.7.0", default-features = false }
91 changes: 44 additions & 47 deletions src/metrics/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,55 +220,52 @@ impl HistogramMap {
}

pub(crate) fn save_histograms(&mut self) {
match &self.db {
Some(db) => {
debug!("Saving Histograms...");
self.previous_stop = Some(SystemTime::now());
let dbfile = db.join("store");
let database_open = fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(dbfile);
match database_open {
Ok(database) => {
let mut gz = GzEncoder::new(database, Compression::default());
gz.write_all(&bincode::serialize(self).expect(SER_ERROR))
.expect("Failed to compress/write to file.");
match gz.finish() {
Ok(_r) => {
debug!("Write Finished.");
}
Err(_e) => {
error!("Couldn't complete database write.");
}
};
let configuration = db.join(".configuration");
let mut configuration = fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(configuration)
.expect("Couldn't open Configuration");
configuration
.write_all(
format!("version={:}\n", env!("CARGO_PKG_VERSION")).as_bytes(),
)
.expect("Failed to write file.");
}
Err(e) => {
exit_with_message!(
format!(
"Couldn't write to {}, error: {}",
db.join("store").to_string_lossy(),
e.to_string()
),
1
);
}
if let Some(db) = &self.db {
debug!("Saving Histograms...");
self.previous_stop = Some(SystemTime::now());
let dbfile = db.join("store");
let database_open = fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(dbfile);
match database_open {
Ok(database) => {
let mut gz = GzEncoder::new(database, Compression::default());
gz.write_all(&bincode::serialize(self).expect(SER_ERROR))
.expect("Failed to compress/write to file.");
match gz.finish() {
Ok(_r) => {
debug!("Write Finished.");
}
Err(_e) => {
error!("Couldn't complete database write.");
}
};
let configuration = db.join(".configuration");
let mut configuration = fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(configuration)
.expect("Couldn't open Configuration");
configuration
.write_all(
format!("version={:}\n", env!("CARGO_PKG_VERSION")).as_bytes(),
)
.expect("Failed to write file.");
}
Err(e) => {
exit_with_message!(
format!(
"Couldn't write to {}, error: {}",
db.join("store").to_string_lossy(),
e.to_string()
),
1
);
}
}
None => {}
}
}

Expand Down
33 changes: 15 additions & 18 deletions src/metrics/zprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,23 @@ impl ZProcess {
#[cfg(target_os = "linux")]
pub fn update_delay(&mut self, client: &Option<Client>) {
debug!("Getting Task Stats for {}", self.pid);
match client {
Some(c) => {
let stats_result = c.pid_stats(self.pid as u32);
match stats_result {
Ok(s) => {
self.prev_io_delay = self.io_delay;
self.prev_swap_delay = self.swap_delay;
self.io_delay = s.delays.blkio.delay_total;
self.swap_delay = s.delays.swapin.delay_total;
debug!(
"Pid: {} io_delay: {} swap_delay: {}",
self.pid,
self.io_delay.as_secs(),
self.swap_delay.as_secs()
);
}
Err(_) => debug!("Couldn't get stats for {}", self.pid),
if let Some(c) = client {
let stats_result = c.pid_stats(self.pid as u32);
match stats_result {
Ok(s) => {
self.prev_io_delay = self.io_delay;
self.prev_swap_delay = self.swap_delay;
self.io_delay = s.delays.blkio.delay_total;
self.swap_delay = s.delays.swapin.delay_total;
debug!(
"Pid: {} io_delay: {} swap_delay: {}",
self.pid,
self.io_delay.as_secs(),
self.swap_delay.as_secs()
);
}
Err(_) => debug!("Couldn't get stats for {}", self.pid),
}
None => {}
}
}

Expand Down
22 changes: 11 additions & 11 deletions src/renderer/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use super::style::{max_style, ok_style, MAX_COLOR, OK_COLOR};
use crate::float_to_byte_string;
use crate::metrics::histogram::{HistogramKind, View};
use crate::metrics::CPUTimeApp;
use crate::renderer::{percent_of, split_left_right_pane, Render, ZBackend};
use byte_unit::{Byte, ByteUnit};
use crate::renderer::{percent_of, split_left_right_pane, Render};
use byte_unit::{Byte, Unit};
use ratatui::layout::{Constraint, Direction, Layout, Rect};
use ratatui::style::{Color, Modifier, Style};
use ratatui::text::{Line, Span};
Expand Down Expand Up @@ -92,8 +92,8 @@ fn mem_title(app: &CPUTimeApp) -> Line {
Span::styled(
format!(
"{} / {} - {:}%",
float_to_byte_string!(app.mem_utilization as f64, ByteUnit::KB),
float_to_byte_string!(app.mem_total as f64, ByteUnit::KB),
float_to_byte_string!(app.mem_utilization as f64, Unit::KB),
float_to_byte_string!(app.mem_total as f64, Unit::KB),
mem
),
if mem > 95 { max_style() } else { ok_style() },
Expand All @@ -102,8 +102,8 @@ fn mem_title(app: &CPUTimeApp) -> Line {
Span::styled(
format!(
"{} / {} - {:}%",
float_to_byte_string!(app.swap_utilization as f64, ByteUnit::KB),
float_to_byte_string!(app.swap_total as f64, ByteUnit::KB),
float_to_byte_string!(app.swap_utilization as f64, Unit::KB),
float_to_byte_string!(app.swap_total as f64, Unit::KB),
swp,
),
if swp > 20 { max_style() } else { ok_style() },
Expand All @@ -113,7 +113,7 @@ fn mem_title(app: &CPUTimeApp) -> Line {
])
}

fn render_cpu_histogram(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBackend>, view: &View) {
fn render_cpu_histogram(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_>, view: &View) {
let h = match app.histogram_map.get_zoomed(&HistogramKind::Cpu, view) {
Some(h) => h,
None => return,
Expand All @@ -127,7 +127,7 @@ fn render_cpu_histogram(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBackend
.render(f, area);
}

fn render_memory_histogram(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBackend>, view: &View) {
fn render_memory_histogram(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_>, view: &View) {
let h = match app.histogram_map.get_zoomed(&HistogramKind::Mem, view) {
Some(h) => h,
None => return,
Expand All @@ -141,7 +141,7 @@ fn render_memory_histogram(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBack
.render(f, area);
}

fn render_cpu_bars(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBackend>, style: &Style) {
fn render_cpu_bars(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_>, style: &Style) {
let cpus = app.cpus.to_owned();
if cpus.is_empty() {
return;
Expand Down Expand Up @@ -176,7 +176,7 @@ fn render_cpu_bars(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBackend>, st

let cols = 4;

let nrows = ((cpus.len() as u16 + cols - 1) / cols) as usize;
let nrows = (cpus.len() as u16).div_ceil(cols) as usize;

let mut items = vec![];
for i in 0..nrows {
Expand Down Expand Up @@ -269,7 +269,7 @@ fn render_cpu_bars(app: &CPUTimeApp, area: Rect, f: &mut Frame<'_, ZBackend>, st
pub fn render_cpu(
app: &CPUTimeApp,
area: Rect,
f: &mut Frame<'_, ZBackend>,
f: &mut Frame<'_>,
view: View,
border_style: Style,
) {
Expand Down
32 changes: 16 additions & 16 deletions src/renderer/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use super::style::{max_style, ok_style};
/**
* Copyright 2019-2022, Benjamin Vaisvil and the zenith contributors
*/
use super::{split_left_right_pane, FileSystemDisplay, Render, ZBackend};
use super::{split_left_right_pane, FileSystemDisplay, Render};
use crate::float_to_byte_string;
use crate::metrics::histogram::{HistogramKind, View};
use crate::metrics::CPUTimeApp;
use byte_unit::{Byte, ByteUnit};
use byte_unit::{Byte, Unit};
use ratatui::layout::{Constraint, Direction, Layout, Rect};
use ratatui::style::{Color, Style};
use ratatui::text::{Line, Span};
Expand All @@ -17,7 +17,7 @@ use std::borrow::Cow;
pub fn render_disk(
app: &CPUTimeApp,
layout: Rect,
f: &mut Frame<'_, ZBackend>,
f: &mut Frame<'_>,
view: View,
border_style: Style,
file_system_index: &usize,
Expand Down Expand Up @@ -82,7 +82,7 @@ pub fn render_disk(
}
fn disk_activity_histogram(
app: &CPUTimeApp,
f: &mut Frame<'_, ZBackend>,
f: &mut Frame<'_>,
view: View,
area: &[Rect],
file_system_index: &usize,
Expand All @@ -91,7 +91,7 @@ fn disk_activity_histogram(
disk_list.sort_by(|a, b| b.mount_point.cmp(&a.mount_point));
if let Some(fs) = disk_list.get(*file_system_index) {
let read_up =
float_to_byte_string!(fs.get_read_bytes_sec(&app.histogram_map.tick), ByteUnit::B);
float_to_byte_string!(fs.get_read_bytes_sec(&app.histogram_map.tick), Unit::B);
let h_read = match app
.histogram_map
.get_zoomed(&HistogramKind::IoRead(fs.name.to_string()), &view)
Expand All @@ -104,7 +104,7 @@ fn disk_activity_histogram(
Some(x) => *x,
None => 1,
};
let read_max_bytes = float_to_byte_string!(read_max as f64, ByteUnit::B);
let read_max_bytes = float_to_byte_string!(read_max as f64, Unit::B);

let top_reader = match app.top_pids.read.pid {
Some(pid) => match app.process_map.get(&pid) {
Expand All @@ -115,7 +115,7 @@ fn disk_activity_histogram(
};

let write_down =
float_to_byte_string!(fs.get_write_bytes_sec(&app.histogram_map.tick), ByteUnit::B);
float_to_byte_string!(fs.get_write_bytes_sec(&app.histogram_map.tick), Unit::B);
let h_write = match app
.histogram_map
.get_zoomed(&HistogramKind::IoWrite(fs.name.to_string()), &view)
Expand All @@ -128,7 +128,7 @@ fn disk_activity_histogram(
Some(x) => *x,
None => 1,
};
let write_max_bytes = float_to_byte_string!(write_max as f64, ByteUnit::B);
let write_max_bytes = float_to_byte_string!(write_max as f64, Unit::B);

let top_writer = match app.top_pids.write.pid {
Some(pid) => match app.process_map.get(&pid) {
Expand Down Expand Up @@ -196,7 +196,7 @@ fn disk_activity_histogram(

fn disk_usage(
app: &CPUTimeApp,
f: &mut Frame<'_, ZBackend>,
f: &mut Frame<'_>,
view: View,
area: &[Rect],
file_system_index: &usize,
Expand All @@ -211,9 +211,9 @@ fn disk_usage(
Some(h) => h,
None => return,
};
let free = float_to_byte_string!(fs.available_bytes as f64, ByteUnit::B);
let used = float_to_byte_string!(fs.get_used_bytes() as f64, ByteUnit::B);
let size = float_to_byte_string!(fs.size_bytes as f64, ByteUnit::B);
let free = float_to_byte_string!(fs.available_bytes as f64, Unit::B);
let used = float_to_byte_string!(fs.get_used_bytes() as f64, Unit::B);
let size = float_to_byte_string!(fs.size_bytes as f64, Unit::B);
Sparkline::default()
.block(
Block::default().title(
Expand Down Expand Up @@ -259,9 +259,9 @@ fn disk_usage(
"{:} /s ({:})",
float_to_byte_string!(
fs.get_read_bytes_sec(&app.histogram_map.tick),
ByteUnit::B
Unit::B
),
float_to_byte_string!(fs.current_io.read_bytes as f64, ByteUnit::B),
float_to_byte_string!(fs.current_io.read_bytes as f64, Unit::B),
),
rhs_style,
),
Expand All @@ -288,9 +288,9 @@ fn disk_usage(
"{:} /s ({:})",
float_to_byte_string!(
fs.get_write_bytes_sec(&app.histogram_map.tick),
ByteUnit::B
Unit::B
),
float_to_byte_string!(fs.current_io.write_bytes as f64, ByteUnit::B),
float_to_byte_string!(fs.current_io.write_bytes as f64, Unit::B),
),
rhs_style,
),
Expand Down
Loading

0 comments on commit f315025

Please sign in to comment.