Skip to main content

Run ssh command to check the process running on Check processes of multiple servers parallelly usingin parallel with if conditionstatement

Source Link

Run ssh command to check the process running on multiple servers parallelly using if condition

I have a bash function which checks if there are any process running on servers by reading their IPs from a text file one by one

  while read IP
  do
    if [ 1 -eq "$(echo "$(ssh -n ubuntu@$IP "top -b -n2 -d 0.5|grep Cpu|awk '{print \$2+\$4}'|tail -n1") > 1.0" | bc)" ];then
      echo "process is running on $IP"
    else
      echo "process is not running on $IP"
    fi 
  done < file.ips

file.ips contains few server ips

202.X.X.X
203.X.X.X
204.X.X.X
...
...
...

I want to modify this function to check the process running on multiple servers parallelly