ssh-stress01-rmt.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
  3. # Copyright (c) International Business Machines Corp., 2005
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2 of
  8. # the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it would be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write the Free Software Foundation,
  17. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. # Author: Mitsuru Chinen <mitch@jp.ibm.com>
  20. #
  21. TCID="ssh_stress01_rmt"
  22. TST_TOTAL=1
  23. . test.sh
  24. if [ $# -ne 4 ]; then
  25. tst_brkm TBROK "Usage: $0 ipver rhost config connections"
  26. fi
  27. ip_ver="$1"
  28. server_ipaddr="$2"
  29. ssh_config="$3"
  30. connections="$4"
  31. ssh -$ip_ver -F $ssh_config $server_ipaddr \
  32. "true < /dev/null > /dev/null 2>&1" > /dev/null
  33. [ $? -ne 0 ] && tst_brkm TBROK "Can't connect to '$server_ipaddr'"
  34. # Make ssh connections
  35. num=0
  36. while [ $num -lt $connections ]; do
  37. ssh -$ip_ver -f -N -F $ssh_config $server_ipaddr
  38. if [ $? -ne 0 ]; then
  39. tst_resm TINFO "'$num' seems the max num of ssh conn"
  40. break
  41. fi
  42. num=$(($num + 1))
  43. done
  44. # Disconnect all ssh connection
  45. all_conn=$(ps auxw | grep -Fv grep | \
  46. grep "ssh[[:blank:]].*${ssh_config}" | awk '{print $2}')
  47. kill $all_conn
  48. # Check the connectivity again
  49. ssh -$ip_ver -F $ssh_config $server_ipaddr \
  50. "true < /dev/null > /dev/null 2>&1" > /dev/null
  51. if [ $? -ne 0 ]; then
  52. tst_brkm TBROK "Failed to connect $server_ipaddr"
  53. fi
  54. tst_exit