v-list-database-hosts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # info: list database servers
  3. # options: TYPE [FORMAT]
  4. #
  5. # The function for obtaining the list of all hosts of the same databases' type.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. type=${1-mysql}
  11. format=${2-shell}
  12. # Includes
  13. source $VESTA/func/main.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking args
  18. #check_args '1' "$#" 'TYPE [FORMAT]'
  19. #----------------------------------------------------------#
  20. # Action #
  21. #----------------------------------------------------------#
  22. # Defining fileds to select
  23. conf=$VESTA/conf/$type.conf
  24. fields='$HOST $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED'
  25. fields="$fields \$TIME \$DATE"
  26. # Listing database
  27. case $format in
  28. json) json_list ;;
  29. plain) nohead=1; shell_list;;
  30. shell) fields='$HOST $MAX_DB $U_DB_BASES $SUSPENDED $DATE';
  31. shell_list | column -t ;;
  32. *) check_args '2' '0' 'TYPE [FORMAT]'
  33. esac
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. exit