Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. BASE_NAME=influxDignostic_$(hostname)_$(date +%Y%m%d-%H%M)
  4. OUT_DIR=$BASE_NAME
  5. INFLUXDB_USER="foo"
  6. INFLUXDB_PASSWORD="bar"
  7.  
  8. while [[ $# -gt 1 ]]
  9. do
  10. key="$1"
  11.  
  12. case $key in
  13. -u|--username)
  14. $INFLUXDB_USER="$2"
  15. shift # past argument
  16. ;;
  17. -p|--password)
  18. $INFLUXDB_PASSWORD="$2"
  19. shift # past argument
  20. ;;
  21. *)
  22. # unknown option
  23. ;;
  24. esac
  25. shift # past argument or value
  26. done
  27.  
  28. echo $BASE_NAME
  29. echo USERNAME = "${INFLUXDB_USER}"
  30. echo PASSWORD = "${INFLUXDB_PASSWORD}"
  31.  
  32. if [ ! -f $OUT_DIR ];
  33. then
  34. mkdir $OUT_DIR
  35. fi
  36.  
  37. base() {
  38. echo "#######################"
  39. echo "OS and INFLUXDB VERSION"
  40. echo "#######################"
  41.  
  42. if [ -f /etc/redhat-release ];
  43. then
  44. echo 'Detected RHEL or Centos'
  45. cat /etc/redhat-release
  46. rpm -qa | grep influx
  47. elif [ -f /etc/lsb-release ];
  48. then
  49. echo 'Detected Ubuntu or other Debian OS'
  50. cat /etc/lsb-release
  51. dpkg -l | grep influx
  52. else
  53. echo 'Detected other OS. This script only works on RHEL/CentOS or Ubuntu/Debian.'
  54. echo 'Exiting.'
  55. exit 1
  56. fi
  57.  
  58. echo -e ""
  59. echo "################"
  60. echo "MEMORY and CPU"
  61. echo "################"
  62. free
  63. cat /proc/cpuinfo
  64.  
  65. echo -e ""
  66. echo "################"
  67. echo "DISK"
  68. echo "################"
  69. df -hT
  70. mount
  71. fdisk -l
  72.  
  73. if hash iostat 2>/dev/null; then
  74. iostat -xd 1 30
  75. else
  76. echo -e ""
  77. echo "iostat not installed. Skipping"
  78. fi
  79. }
  80.  
  81. base > $OUT_DIR/$BASE_NAME.txt
  82.  
  83. cp /etc/influxdb/influxdb.conf $OUT_DIR
  84. # look for a meta conf file
  85. # Thsi should only exist for Enterprise Customers
  86. if [ -f /etc/influxdb/influxdb-meta.conf ]; then
  87. echo "Found meta conf file"
  88. cp /etc/influxdb/influxdb-meta.conf .
  89. fi
  90.  
  91. influx -username $INFLUXDB_USER -password $INFLUXDB_PASSWORD -execute "SHOW SHARDS;" > $OUT_DIR/show_shards.txt
  92. influx -username $INFLUXDB_USER -password $INFLUXDB_PASSWORD -execute "SHOW STATS;" > $OUT_DIR/show_stats.txt
  93. influx -username $INFLUXDB_USER -password $INFLUXDB_PASSWORD -execute "SHOW DIAGNOSTICS;" > $OUT_DIR/show_diagnostics.txt
  94. for db in $(influx -execute 'show databases' -format csv | tr ',' ' ' | awk '/databases/ { print $2 }'); do
  95. influx -username $INFLUXDB_USER -password $INFLUXDB_PASSWORD -execute "show retention policies on $db" >> $OUT_DIR/show_retention_policies.txt;
  96. done
  97. influx -username $INFLUXDB_USER -password $INFLUXDB_PASSWORD -execute "SHOW CONTINUOUS QUERIES;" > $OUT_DIR/show_continuous_queries.txt
  98.  
  99. #ZIP it all up and send it
  100. tar -czvf ${BASE_NAME}.tar.gz $OUT_DIR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement