Search code examples
bashsshrhel

linux + how to measure ssh time until login to remote machine


we want to measure the time that is needed until ssh successfully login to remote machine

is it possible to measure ssh time until login to remote machine?

note - all machine are RHEL machines

for example

lets say we want to verify how much time is needed to login machine_X from machine_Y

example from machine_Y

while machine_X is machine_[1..100]

ssh time until login to machine1 was 2 sec
ssh time until login to machine2 was 6 sec
ssh time until login to machine3 was 12 sec
ssh time until login to machine4 was 3 sec
.
.
.

Solution

  • #!/bin/bash
    
    # using bash variable SECONDS 
    for srv in machine_{1..100}; do
         START=$SECONDS;        
         ssh "$srv" /usr/bin/true; 
         printf "ssh time until login to %s was %s sec\n" "$srv" "$((SECONDS-START))"; 
    done
    

    ssh time until login to machine1 was 1 sec
    ssh time until login to machine2 was 0 sec
    ssh time until login to machine3 was 0 sec
    ssh time until login to ...