|
root |
2bfd68 |
#!/bin/bash
|
|
root |
2bfd68 |
# Author: Steve Barnes (steve@echo.id.au)
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# A simple iostat test to verify transfers are being recorded
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
t_Log "Running $0 - a basic iostat test to verify disk measurement"
|
|
root |
2bfd68 |
|
|
Carlos Rodriguez-Fernandez |
4baccd |
output_file=$(mktemp)
|
|
Carlos Rodriguez-Fernandez |
4baccd |
trap "rm -f ${output_file}" EXIT
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# dd options
|
|
Carlos Rodriguez-Fernandez |
4baccd |
bs=4196
|
|
Carlos Rodriguez-Fernandez |
4baccd |
count=10100
|
|
Carlos Rodriguez-Fernandez |
4baccd |
sum=$(expr $bs \* $count / 1024)
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Clear out the pagecache to get an accurate reading
|
|
root |
2bfd68 |
echo 1 > /proc/sys/vm/drop_caches
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Capture a storage device name
|
|
Carlos Rodriguez-Fernandez |
4baccd |
drive=$(fdisk -l|grep -Po -m1 '^/dev/[\D]+')
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Run iostat on the device
|
|
Carlos Rodriguez-Fernandez |
4baccd |
/usr/bin/iostat -d 1 5 $drive >${output_file} 2>&1 &
|
|
root |
2bfd68 |
|
|
Carlos Rodriguez-Fernandez |
4baccd |
# Time for iostat booting
|
|
Carlos Rodriguez-Fernandez |
4baccd |
sleep 1
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Generate some read traffic
|
|
Carlos Rodriguez-Fernandez |
4baccd |
/bin/dd if=$drive of=/dev/null bs=$bs count=$count &>/dev/null
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Give iostat a chance to log our traffic
|
|
Athmane Madjoudj |
b5d067 |
sleep 6
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Confirm our read bytes are >0, excluding the first
|
|
root |
2bfd68 |
# line since that's the average since boot.
|
|
Carlos Rodriguez-Fernandez |
4baccd |
kbytes_read=$(awk '$6 ~ /[0-9]/ {NR>1 && sum+=$6} END {print int(sum)}' ${output_file})
|
|
root |
2bfd68 |
|
|
Carlos Rodriguez-Fernandez |
4baccd |
if [ "$kbytes_read" -eq 0 ]; then
|
|
Carlos Rodriguez-Fernandez |
4baccd |
t_Log "FAIL: ${0}: no io activity registered"
|
|
Carlos Rodriguez-Fernandez |
4baccd |
cat ${output_file}
|
|
Carlos Rodriguez-Fernandez |
4baccd |
t_CheckExitStatus 1
|
|
Carlos Rodriguez-Fernandez |
4baccd |
fi
|
|
root |
2bfd68 |
|
|
Carlos Rodriguez-Fernandez |
4baccd |
t_CheckExitStatus 0
|