check_ip.sh 538 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. #service=iru-swarm.infoclinica.ru
  3. #floating_ip=swarm.sdsys.ru
  4. check_service() {
  5. curl -f ${service}
  6. if [ $? == 0 ]; then echo "${service} is up and running!!!"; return 0; else echo "${service} is down!!!"; return 1; fi
  7. }
  8. check_ip() {
  9. curl -f ${vip}
  10. if [ $? == 0 ]; then echo "${vip} is exist!!!"; return 0; else echo "The ${vip} doesn't exist!"; return 1; fi
  11. }
  12. check=0
  13. while [ ${check} -eq 0 ]
  14. do
  15. check_service
  16. if [ $? != 0 ]
  17. then
  18. sleep 10
  19. else
  20. check_ip
  21. if [ $? != 0 ]; then check=1; else sleep 10; fi
  22. fi
  23. done