X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fminecraft_controller.rs;h=54143e8639cd11c3c4ddda13b1310a668d4dbed1;hb=c849abb7645a38c4fcb91222b399f0914287527a;hp=dfba3eecf148d993f4fb51fb886b0b95a89f4482;hpb=55bef4c00d6f8f6d87fdf482ca63b5efcd85575e;p=minecraft_web.git diff --git a/backend/src/minecraft_controller.rs b/backend/src/minecraft_controller.rs index dfba3ee..54143e8 100644 --- a/backend/src/minecraft_controller.rs +++ b/backend/src/minecraft_controller.rs @@ -130,12 +130,10 @@ fn get_last_backup_datetime(backup_path: &str) -> Option { pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str, rcon_password: &str) -> Option { let mut system = sysinfo::System::new_all(); system.refresh_system(); - let processes = system.get_process_by_name(MINECRAFT_PROCESS_NAME); + let mut processes = system.processes_by_name(MINECRAFT_PROCESS_NAME); // TODO: find the correct process by checking the correct jar name in parameters. - if processes.len() >= 1 { - let process = processes.first().unwrap(); - + if let Some(process) = processes.next() { let world_size = match fs_extra::dir::get_size(world_path) { Ok(l) => l, Err(_) => 0u64 }; let status_from_rcon = get_status_from_rcon(rcon_password); @@ -143,7 +141,7 @@ pub fn get_minecraft_executable_information(world_path: &str, backup_path: &str, Some( MinecraftExe { memory: process.memory() / 3, // Because the Java garbage collector ZGC reports three times more the real memory usage: https://stackoverflow.com/a/62934057/212675 - load_average_5min: system.get_load_average().five / system.get_processors().len() as f64 * 100., + load_average_5min: system.load_average().five / system.processors().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: status_from_rcon.players,