v_list_db_hosts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # info: listing data base servers
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. type="$1"
  8. format="${2-shell}"
  9. limit="${3-1000}"
  10. offset="${4-1}"
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_FUNC/shared_func.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking args
  18. check_args '1' "$#" 'type [format] [limit] [offset]'
  19. # Checking argument format
  20. format_validation 'limit' 'offset'
  21. # Checking db type
  22. is_type_valid 'db' "$type"
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Defining config type
  27. conf="$V_DB/$type.conf"
  28. # Defining fileds to select
  29. fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
  30. # Listing database
  31. case $format in
  32. json) v_json_list ;;
  33. shell) fields='$HOST $PORT $MAX_USERS $MAX_DB $U_DB_BASES $ACTIVE $DATE';
  34. v_shell_list | column -t ;;
  35. *) check_args '2' "0" 'type [format] [limit] [offset]'
  36. esac
  37. #----------------------------------------------------------#
  38. # Vesta #
  39. #----------------------------------------------------------#
  40. # Logging
  41. log_event 'system' "$V_EVENT"
  42. exit $OK