Alex | dcb792f | 2021-10-04 14:24:21 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | echo "Collecting Ceph cluster data." |
| 3 | |
| 4 | if [ "$#" -lt 2 ]; then echo "Usage: ./ceph_collect.sh <CUSTOMER> <CLUSTERNAME>"; exit; fi |
| 5 | export CUSTOMER=$1 |
| 6 | export CLUSTERNAME=$2 |
| 7 | |
| 8 | if ! which ceph >/dev/null; then echo "ERROR: This script must be run on a ceph monitor or admin node"; exit; fi |
| 9 | |
| 10 | DATE=`date "+%Y-%m-%d"` |
| 11 | DIRNAME="CephCollectData.$CUSTOMER.$CLUSTERNAME.$DATE" |
| 12 | ARCHNAME=$DIRNAME".tar.gz" |
| 13 | mkdir $DIRNAME |
| 14 | cd $DIRNAME |
| 15 | |
| 16 | echo "Collecting CRUSH map" |
| 17 | ceph osd getcrushmap -o crush.bin |
| 18 | crushtool -d crush.bin -o crushmap.txt |
| 19 | crushtool -i crush.bin --dump > crushmap.json |
| 20 | rm crush.bin |
| 21 | |
| 22 | echo "Collecting ceph osd crush dump" |
| 23 | ceph osd crush dump >crushdump.json |
| 24 | |
| 25 | echo "Collecting cluster status" |
| 26 | ceph -s -f json -o ceph_s.json |
| 27 | echo "Collecting health detail" |
| 28 | ceph -f json health detail -o ceph_healt_detail.json |
| 29 | echo "Collecting monmap" |
| 30 | ceph mon dump -f json -o monmap.json |
| 31 | echo "Collecting ceph df" |
| 32 | ceph df -f json -o ceph_df.json |
| 33 | echo "Collecting ceph osd df" |
| 34 | ceph osd df -f json -o ceph_osd_df.json |
| 35 | echo "Collecting ceph osd dump" |
| 36 | ceph osd dump -f json -o ceph_osd_dump.json |
| 37 | echo "Collecting rados df" |
| 38 | rados df -f json >rados_df.json |
| 39 | echo "Collecting ceph report" |
| 40 | ceph report -o ceph_report.json |
| 41 | echo "Collecting auth data anonymized" |
| 42 | ceph auth list -f json |sed 's/AQ[^=]*==/KEY/g' > ceph_auth_ls.json |
| 43 | echo "Collecting ceph pg dump" |
| 44 | ceph pg dump -f json -o ceph_pg_dump.json |
| 45 | echo "Collecting health metrics" |
| 46 | mkdir ceph-health |
| 47 | IFS=$'\n'; for device in `ceph device ls|grep -v DEVICE`; do osd=$(echo $device|awk '{print $3}'); dev=$(echo $device|awk '{print $1}'); ceph device get-health-metrics $dev >ceph-health/$osd-$dev.json ; done |
| 48 | echo "Collecting ceph osd perf" |
| 49 | for i in {0..9}; do echo $i; ceph osd perf -f json -o ceph_osd_perf_$i.json; sleep 4; done |
| 50 | echo "Collecting ceph running configuration" |
| 51 | ceph config dump -f json >ceph_config_dump.json |
| 52 | |
| 53 | tar czf "../"$ARCHNAME * |
| 54 | |