X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fvalheim_controller.rs;h=a7f10b5ae17d1579eb77f96964b5ba9bced64d23;hb=HEAD;hp=f92e63d459fc6735bdc3b591f7e4970db4b98f39;hpb=aa59a1f9b79009079a5a1fbafd4f65d3130e9ee2;p=valheim_web.git diff --git a/backend/src/valheim_controller.rs b/backend/src/valheim_controller.rs index f92e63d..a7f10b5 100644 --- a/backend/src/valheim_controller.rs +++ b/backend/src/valheim_controller.rs @@ -8,7 +8,7 @@ use systemd::journal; #[derive(Clone, Debug)] pub struct ValheimExe { - memory: u64, // [kB]. + memory: u64, // [B]. load_average_5min: f64, // [%]. uptime: u64, // [s]. world_size: u64, // [B]. @@ -18,7 +18,7 @@ pub struct ValheimExe { impl ValheimExe { pub fn format_memory(&self) -> String { - format_byte_size(self.memory * 1024, 2) + format_byte_size(self.memory, 2) } pub fn format_load_average(&self) -> String { @@ -37,11 +37,13 @@ impl ValheimExe { } pub fn format_active_players(&self) -> String { + /* Commented because the player list isn't correct (the number is). if self.active_players.len() == 0 { String::from("") } else { self.active_players.join(", ") - } + }*/ + self.active_players.len().to_string() } pub fn format_last_backup(&self) -> String { @@ -81,6 +83,7 @@ const STRING_BEFORE_CHARACTER_NAME: &str = "Got character ZDOID from"; #[cfg(target_os = "linux")] const STRING_BEFORE_NB_OF_CONNECTIONS: &str = "Connections"; +// It doesn't work for the moment, it only scan the connection event and do not treat disconnections. #[cfg(target_os = "linux")] fn get_active_players() -> Vec { let mut journal = @@ -162,7 +165,7 @@ pub fn get_valheim_executable_information(world_path: &str, backup_path: &str) - Some( ValheimExe { memory: process.memory(), - load_average_5min: system.load_average().five / system.processors().len() as f64 * 100., + load_average_5min: system.load_average().five / system.cpus().len() as f64 * 100., uptime: std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() - process.start_time(), world_size, active_players: get_active_players(),