diff --git a/Cargo.lock b/Cargo.lock index eae279563..c7607a0ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2256,7 +2256,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -4606,15 +4606,14 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.30.13" +version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3" +checksum = "2b92e0bdf838cbc1c4c9ba14f9c97a7ec6cdcd1ae66b10e1e42775a25553f45d" dependencies = [ - "cfg-if", "core-foundation-sys", "libc", + "memchr", "ntapi", - "once_cell", "rayon", "windows", ] @@ -5469,11 +5468,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.52.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" dependencies = [ - "windows-core", + "windows-core 0.57.0", "windows-targets 0.52.6", ] @@ -5486,17 +5485,60 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.75", +] + +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.75", +] + [[package]] name = "windows-registry" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-strings", "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.2.0" @@ -5512,7 +5554,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ - "windows-result", + "windows-result 0.2.0", "windows-targets 0.52.6", ] diff --git a/server/Cargo.toml b/server/Cargo.toml index 936a37f5a..8f6c3e92d 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -48,7 +48,7 @@ sled = "0.34.7" static-toml = "1.2.0" strip-ansi-escapes = "0.2.0" strum = { version = "0.26.2", features = ["derive"] } -sysinfo = "0.30.12" +sysinfo = "0.31.3" thiserror = "1.0.61" tokio = { version = "1.38.0", features = ["full"] } tokio-native-tls = "0.3.1" diff --git a/server/src/configs/validators.rs b/server/src/configs/validators.rs index 306171c49..75e7baf1a 100644 --- a/server/src/configs/validators.rs +++ b/server/src/configs/validators.rs @@ -15,7 +15,7 @@ use iggy::utils::byte_size::IggyByteSize; use iggy::utils::expiry::IggyExpiry; use iggy::utils::topic_size::MaxTopicSize; use iggy::validatable::Validatable; -use sysinfo::System; +use sysinfo::{Pid, ProcessesToUpdate, System}; use tracing::{info, warn}; impl Validatable for ServerConfig { @@ -80,7 +80,9 @@ impl Validatable for CacheConfig { let limit_bytes = self.size.clone().into(); let mut sys = System::new_all(); sys.refresh_all(); - sys.refresh_processes(); + sys.refresh_processes(ProcessesToUpdate::Some(&[ + Pid::from_u32(std::process::id()), + ])); let total_memory = sys.total_memory(); let free_memory = sys.free_memory(); let cache_percentage = (limit_bytes as f64 / total_memory as f64) * 100.0; diff --git a/server/src/streaming/systems/stats.rs b/server/src/streaming/systems/stats.rs index e58b335f3..0273e2316 100644 --- a/server/src/streaming/systems/stats.rs +++ b/server/src/streaming/systems/stats.rs @@ -4,7 +4,7 @@ use iggy::error::IggyError; use iggy::locking::IggySharedMutFn; use iggy::models::stats::Stats; use std::sync::OnceLock; -use sysinfo::{Pid, System as SysinfoSystem}; +use sysinfo::{Pid, ProcessesToUpdate, System as SysinfoSystem}; use tokio::sync::Mutex; fn sysinfo() -> &'static Mutex { @@ -26,11 +26,11 @@ impl System { pub async fn get_stats_bypass_auth(&self) -> Result { let mut sys = sysinfo().lock().await; let process_id = std::process::id(); - sys.refresh_cpu(); + sys.refresh_cpu_all(); sys.refresh_memory(); - sys.refresh_process(Pid::from_u32(process_id)); + sys.refresh_processes(ProcessesToUpdate::Some(&[Pid::from_u32(process_id)])); - let total_cpu_usage = sys.global_cpu_info().cpu_usage(); + let total_cpu_usage = sys.global_cpu_usage(); let total_memory = sys.total_memory().into(); let available_memory = sys.available_memory().into(); let clients_count = self.client_manager.read().await.get_clients().len() as u32;