I've written this code to get the connections from one machine and adding them with the number of connection of the other machine.
This code is not giving any netstat, 0 is coming for the live active connections.
#!/usr/bin/ksh -xvf
Machine_Detail="prpm@sp204|LC1_R11_LCP|LC1_R12_LCP|LC1_FR15_LCP|LC1_R16_LCP prpm1@sp2048|LC1_R13_LCP|LC1_R14_LCP|LC1_R17_LCP|LC1_R18_LCP"
for i in $Machine_Detail
do
machine_connect=$(echo $i | cut -d'|' -f1)
echo $machine_connect
ssh $machine_connect
Conn_count=**$(netstat -an | grep $`echo ${i} | cut -d'|' -f2`| wc -l | sed 's/ //g')**
Conn_count=$((${Conn_count}+$(netstat -an | grep $`echo ${i} | cut -d'|' -f3` | wc -l | sed 's/ //g')))
Conn_count=$((${Conn_count}+$(netstat -an | grep $`echo ${i} | cut -d'|' -f4` | wc -l | sed 's/ //g')))
Conn_count=$((${Conn_count}+$(netstat -an | grep $`echo ${i} | cut -d'|' -f5` | wc -l | sed 's/ //g')))
Total_Conn_Count=$((${Total_Conn_Count}+${Conn_count}))
echo $Total_Conn_Count
exit
done