@@ -684,8 +684,15 @@ async function checkPing(target, timeout = 10) {
684684 const { stdout } = await execAsync ( command , { timeout : ( timeout + 2 ) * 1000 } ) ;
685685 const responseTime = Date . now ( ) - startTime ;
686686
687+ // Debug logging for ping output
688+ console . log ( ` [PING DEBUG] Target: ${ target } ` ) ;
689+ console . log ( ` [PING DEBUG] Command: ${ command } ` ) ;
690+ console . log ( ` [PING DEBUG] Raw stdout:\n${ stdout } ` ) ;
691+ console . log ( ` [PING DEBUG] Elapsed time: ${ responseTime } ms` ) ;
692+
687693 const lossMatch = stdout . match ( / ( \d + ) % \s * (?: p a c k e t \s * ) ? l o s s / i) ;
688694 const packetLoss = lossMatch ? parseInt ( lossMatch [ 1 ] , 10 ) : null ;
695+ console . log ( ` [PING DEBUG] Packet loss: ${ packetLoss } %` ) ;
689696
690697 if ( packetLoss === 100 ) {
691698 return {
@@ -696,21 +703,30 @@ async function checkPing(target, timeout = 10) {
696703 }
697704
698705 let pingTime = null ;
706+ let matchedPattern = null ;
699707 const patterns = [
700708 / t i m e [ = < ] ( \d + \. ? \d * ) \s * m s / i, // Most common: time=15ms, time=15.3 ms, time<1ms
701709 / t i m e [ = < ] \s * ( \d + \. ? \d * ) \s * m s / i, // With space after =: time= 15 ms
702710 / r t t \s + m i n \/ a v g \/ m a x \/ \S + \s * = \s * [ \d . ] + \/ ( [ \d . ] + ) / i, // Linux summary: rtt min/avg/max/mdev = 14.267/14.267/14.267/0.000 ms
703711 / ( \d + \. ? \d * ) \s * m s \s * $ / im // Fallback: just "15.3 ms" at end of line
704712 ] ;
705- for ( const pattern of patterns ) {
706- const match = stdout . match ( pattern ) ;
713+ for ( let i = 0 ; i < patterns . length ; i ++ ) {
714+ const match = stdout . match ( patterns [ i ] ) ;
707715 if ( match ) {
708716 pingTime = parseFloat ( match [ 1 ] ) ;
717+ matchedPattern = i ;
718+ console . log ( ` [PING DEBUG] Matched pattern ${ i } : ${ patterns [ i ] } ` ) ;
719+ console . log ( ` [PING DEBUG] Extracted ping time: ${ pingTime } ms` ) ;
709720 break ;
710721 }
711722 }
712723
724+ if ( pingTime === null ) {
725+ console . log ( ` [PING DEBUG] No pattern matched! Using fallback.` ) ;
726+ }
727+
713728 const finalResponseTime = pingTime ?? Math . min ( responseTime , timeout * 1000 ) ;
729+ console . log ( ` [PING DEBUG] Final response time: ${ finalResponseTime } ms` ) ;
714730
715731 return {
716732 status : 'operational' ,
0 commit comments