v_list_db_hosts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # info: list data base 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
  11. format=${2-shell}
  12. # Importing variables
  13. source $VESTA/conf/vars.conf
  14. source $V_FUNC/shared.func
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking args
  19. check_args '1' "$#" 'type [format] [limit] [offset]'
  20. # Checking argument format
  21. format_validation 'limit' 'offset'
  22. # Checking db type
  23. is_type_valid 'db' "$type"
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Defining config type
  28. conf=$V_DB/$type.conf
  29. # Defining fileds to select
  30. fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
  31. # Listing database
  32. case $format in
  33. json) json_list ;;
  34. plain) nohead=1; shell_list;;
  35. shell) fields='$HOST $PORT $MAX_DB $U_DB_BASES $ACTIVE $DATE';
  36. shell_list | column -t ;;
  37. *) check_args '2' '0' 'type [format]'
  38. esac
  39. #----------------------------------------------------------#
  40. # Vesta #
  41. #----------------------------------------------------------#
  42. exit