@@ -11,7 +11,7 @@ use constants::{
1111 LAMDBA_NETWORK_INTERFACE , PROC_NET_DEV_PATH , PROC_PATH , PROC_STAT_PATH , PROC_UPTIME_PATH ,
1212} ;
1313use regex:: Regex ;
14- use tracing:: debug;
14+ use tracing:: { debug, trace } ;
1515
1616#[ must_use]
1717pub fn get_pid_list ( ) -> Vec < i64 > {
@@ -244,26 +244,29 @@ fn get_fd_max_data_from_path(path: &str, pids: &[i64]) -> f64 {
244244 fd_max
245245}
246246
247- pub fn get_fd_use_data ( pids : & [ i64 ] ) -> Result < f64 , io:: Error > {
247+ #[ must_use]
248+ pub fn get_fd_use_data ( pids : & [ i64 ] ) -> f64 {
248249 get_fd_use_data_from_path ( PROC_PATH , pids)
249250}
250251
251- fn get_fd_use_data_from_path ( path : & str , pids : & [ i64 ] ) -> Result < f64 , io :: Error > {
252+ fn get_fd_use_data_from_path ( path : & str , pids : & [ i64 ] ) -> f64 {
252253 let mut fd_use = 0 ;
253254
254255 for & pid in pids {
255256 let fd_path = format ! ( "{path}/{pid}/fd" ) ;
256- let Ok ( files) = fs:: read_dir ( fd_path) else {
257- return Err ( io:: Error :: new (
258- io:: ErrorKind :: InvalidData ,
259- "File descriptor use data not found" ,
260- ) ) ;
257+ let Ok ( files) = fs:: read_dir ( & fd_path) else {
258+ trace ! (
259+ "File descriptor use data not found in path {} with pid {}" ,
260+ fd_path,
261+ pid
262+ ) ;
263+ continue ;
261264 } ;
262265 let count = files. count ( ) ;
263266 fd_use += count;
264267 }
265268
266- Ok ( fd_use as f64 )
269+ fd_use as f64
267270}
268271
269272#[ must_use]
@@ -473,14 +476,8 @@ mod tests {
473476 fn test_get_fd_use_data ( ) {
474477 let path = "./tests/proc/process/valid" ;
475478 let pids = get_pid_list_from_path ( path_from_root ( path) . as_str ( ) ) ;
476- let fd_use_result = get_fd_use_data_from_path ( path, & pids) ;
477- assert ! ( fd_use_result. is_ok( ) ) ;
478- let fd_use = fd_use_result. unwrap ( ) ;
479+ let fd_use = get_fd_use_data_from_path ( path, & pids) ;
479480 assert ! ( ( fd_use - 5.0 ) . abs( ) < f64 :: EPSILON ) ;
480-
481- let path = "./tests/proc/process/invalid_missing" ;
482- let fd_use_result = get_fd_use_data_from_path ( path, & pids) ;
483- assert ! ( fd_use_result. is_err( ) ) ;
484481 }
485482
486483 #[ test]
0 commit comments