Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -eu
  4.  
  5. COUNT_DISK_REWRITES="${COUNT_DISK_REWRITES:-1}"
  6.  
  7. command -v fio >/dev/null 2>&1 || { echo >&2 "fio required but it's not installed. Aborting."; exit 1; }
  8. command -v iostat >/dev/null 2>&1 || { echo >&2 "iostat required but it's not installed. Aborting."; exit 1; }
  9. command -v fdisk >/dev/null 2>&1 || { echo >&2 "fdisk required but it's not installed. Aborting."; exit 1; }
  10. command -v python >/dev/null 2>&1 || { echo >&2 "python required but it's not installed. Aborting."; exit 1; }
  11. command -v lsblk >/dev/null 2>&1 || { echo >&2 "lsblk required but it's not installed. Aborting."; exit 1; }
  12. command -v bc >/dev/null 2>&1 || { echo >&2 "bc required but it's not installed. Aborting."; exit 1; }
  13. command -v screen >/dev/null 2>&1 || { echo >&2 "screen required but it's not installed. Aborting."; exit 1; }
  14. command -v tee >/dev/null 2>&1 || { echo >&2 "tee required but it's not installed. Aborting."; exit 1; }
  15.  
  16.  
  17. if [ $# -eq 0 ]; then
  18. lsblk
  19. echo
  20.  
  21. DEVICES=$(lsblk -J | python -c 'import json,sys; j=json.load(sys.stdin); a=[item["name"] for item in j["blockdevices"] if item["mountpoint"] == None and ("children" not in item or True not in map(lambda x: x["mountpoint"] != None, item["children"])) ]; print " ".join(a)')
  22.  
  23. else
  24. DEVICES="$@"
  25. fi
  26.  
  27. echo
  28. echo "Starting test on devices:" $DEVICES
  29. read -r -p "Are you sure? [y/N] " response
  30. case "$response" in
  31. [yY][eE][sS]|[yY])
  32. echo
  33. ;;
  34. *)
  35. exit
  36. ;;
  37. esac
  38.  
  39. rm -f ./fio_bench.sh
  40. cat <<\EOF >> ./fio_bench.sh
  41. #!/bin/bash
  42.  
  43. DISK=$1
  44. DISK_NAME=$(basename ${DISK})
  45.  
  46. COUNT=$2
  47.  
  48. SIZE_GB=$(sudo fdisk -l ${DISK} | grep 'Disk /dev/' | awk '{ print $3; }')
  49. SIZE_MB=$(echo "1024 * ${SIZE_GB}" | bc)
  50.  
  51. #echo deadline | sudo tee /sys/block/${DISK_NAME}/queue/scheduler
  52. QUEUE_DEPTH=$(cat /sys/block/${DISK_NAME}/queue/nr_requests)
  53.  
  54. while [ $COUNT -gt 0 ]; do
  55. echo "#### $(date '+%s')" | tee -a ./fio_${DISK_NAME}.txt
  56. sudo fio --name=test \
  57. --filename="${DISK}" \
  58. --ioengine=libaio \
  59. --bs=4M \
  60. --iodepth=${QUEUE_DEPTH} \
  61. --direct=1 \
  62. --rw=rw \
  63. --rwmixwrite=50 \
  64. | tee -a ./fio_${DISK_NAME}.txt 2>&1
  65. let COUNT-=1
  66. done
  67. EOF
  68.  
  69. screen -S iostat -d -m bash -c 'iostat -xydt 60 | tee -a ./iostat.txt 2>&1'
  70.  
  71. for var in $DEVICES; do
  72. echo "Starting test in screen on ${var}"
  73. screen -S fio_${var} -d -m bash ./fio_bench.sh /dev/${var} ${COUNT_DISK_REWRITES}
  74. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement