Advertisement
Guest User

Untitled

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