Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/bin/bash
  2. #set -x
  3.  
  4. servers=/Users/spala/works/iplist.txt
  5.  
  6. #set -u
  7.  
  8. while read -u140 multiplessh;
  9. do
  10.  
  11.  
  12. USER="testuser"
  13. PASS="testpassword"
  14. PORT="55022"
  15. current_ver="3.2.3"
  16.  
  17. command1="/usr/sbin/zabbix_agentd -V & hostname -f /dev/null"
  18. connection_method=`/usr/local/bin/sshpass -p $PASS /usr/bin/ssh -n -p$port -o StrictHostKeyChecking=no $user@$multiplessh $command1`
  19.  
  20.  
  21. first_step="$connection_method"
  22.  
  23. ###
  24. result=$(echo $first_step |grep 'zabbix_agentd|.spala' | awk '{print $1, $5}')
  25. # - 'zabbix_agentd' ---> "zabbix_agent -V" command output..
  26. # - '.spala' my server hostname fqdn..--> test.spala test1.spala test2.spala
  27.  
  28. hostname=$(echo $result |awk '{print $1}')
  29. version=$(echo $result |awk '{print $2}')
  30.  
  31.  
  32. if [[ "$version" == "$current_ver" ]]
  33. then
  34. echo "$hostname used version ---> $version"
  35. echo "Version is ok..."
  36. exit 1
  37. else
  38. echo "$hostname used version ---> $version"
  39. echo "Old version.. Need update !"
  40. exit 1
  41. fi
  42. exit 0
  43.  
  44. done 140<"$servers"
  45.  
  46. sh test.sh
  47. test1.spala used version ---> 3.2.2
  48. Old version.. Need update !
  49.  
  50. cat /Users/spala/works/iplist.txt
  51. 1.1.1.1
  52. 2.2.2.2
  53. 3.3.3.3
  54. 4.4.4.4
  55. 5.5.5.5
  56. ...
  57. total 140 servers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement