v-list-web-stats 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # info: list web statistics
  3. # options: [FORMAT]
  4. #
  5. # The function for obtaining the list of web statistics analyzer.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. # JSON list function
  15. json_list() {
  16. objects=$(echo "$stats" | wc -w)
  17. i=1
  18. echo '['
  19. for str in $stats; do
  20. if [ "$i" -lt "$objects" ]; then
  21. echo -e "\t\"$str\","
  22. else
  23. echo -e "\t\"$str\""
  24. fi
  25. (( ++i))
  26. done
  27. echo "]"
  28. }
  29. # SHELL list function
  30. shell_list() {
  31. echo "PARSER"
  32. echo "------"
  33. for parser in $stats; do
  34. echo "$parser"
  35. done
  36. }
  37. # PLAIN list function
  38. plain_list() {
  39. for parser in $stats; do
  40. echo "$parser"
  41. done
  42. }
  43. # CSV list function
  44. csv_list() {
  45. echo "PARSER"
  46. for parser in $stats; do
  47. echo "$parser"
  48. done
  49. }
  50. #----------------------------------------------------------#
  51. # Action #
  52. #----------------------------------------------------------#
  53. # Parsing stats system
  54. stats=$(echo "none ${STATS_SYSTEM//,/ }")
  55. # Listing data
  56. case $format in
  57. json) json_list ;;
  58. plain) plain_list ;;
  59. csv) csv_list ;;
  60. shell) shell_list ;;
  61. esac
  62. #----------------------------------------------------------#
  63. # Vesta #
  64. #----------------------------------------------------------#
  65. exit