Skip to content

Commit

Permalink
Bump sysinfo from 0.30.13 to 0.31.3 (#1174)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Aug 29, 2024
1 parent f390c72 commit 19298e9
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 17 deletions.
62 changes: 52 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions server/src/configs/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerError> for ServerConfig {
Expand Down Expand Up @@ -80,7 +80,9 @@ impl Validatable<ServerError> 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;
Expand Down
8 changes: 4 additions & 4 deletions server/src/streaming/systems/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SysinfoSystem> {
Expand All @@ -26,11 +26,11 @@ impl System {
pub async fn get_stats_bypass_auth(&self) -> Result<Stats, IggyError> {
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;
Expand Down

0 comments on commit 19298e9

Please sign in to comment.