Browse Source

Implement #1963. Better pv and dd support.

Also better AUTOMAGIC support. #1965.
nrpe_passwd_sed
Benoît S. 5 years ago
parent
commit
6ad4142239
  1. 180
      src/modules/97_benchmark.sh

180
src/modules/97_benchmark.sh

@ -24,7 +24,9 @@ FIO=false
time="/usr/bin/time"
totalRAM=$(free -bt | sed -n 's/Mem:[[:space:]]*\([[:digit:]]*\)*/\1/p' | cut -f1 -d' ')
totalRAM512bs=$((totalRAM / 512))
totalRAM512bsx2=$((totalRAM512bs * 2))
totalRAM4096bs=$((totalRAM / 4096))
totalRAM4096bsx2=$((totalRAM4096bs *2))
totalRAMx2=$((totalRAM * 2))
totalRAMx2G=$((totalRAMx2 / 1024 / 1024 / 1024))
totalRAMx2K=$((totalRAMx2 / 1024))
@ -57,99 +59,107 @@ if step "Set the right setup to do the benchs..."; then
fi
if step "Starting benchmarks..."; then
# We force AUTOMAGIC to have non interruption during benchmarks.
AUTOMAGIC=true
if ! ($AUTOMAGIC); then
# We force AUTOMAGIC to have non interruption during benchmarks.
if step "Would you like to do all tests in one pass?"; then
AUTOMAGIC=true
fi
fi
warn "/!\ Benchmarks could take time. Be patient! Maybe go drink a cofee or a tea ;-)"
sleep 3
cd "$benchPath"
say "### Test 1/8 (Test disk with hdparm) ###"
! is_pkg_installed hdparm && HDPARM=true
installpkg hdparm
for step in {1..3}; do
say "> Buffered disk read (#${step}/3)"
hdparm -t "$device"
done
for step in {1..3}; do
say "> Cache read (#${step}/3)"
hdparm -T "$device"
done
say "### Test 2/8 (Test RAM with dd) ###"
! is_pkg_installed time && installpkg time
say "> Read 2x total RAM"
for i in {1..2}; do
$time dd if=/dev/zero bs=512 count=$totalRAM512bs 2>/tmp/out | \
pv > /dev/null ; cat /tmp/out
done
say "### Test 3/8 (Test disk with dd) ###"
say "> Write and read 2x total RAM"
for i in {1..2}; do
$time dd if=/dev/zero bs=4096 count=$totalRAM4096bs 2>/tmp/out | \
pv > dd.img
if step "### Test 1/8 (Test disk with hdparm) ###"; then
! is_pkg_installed hdparm && HDPARM=true
installpkg hdparm
for step in {1..3}; do
say "> Buffered disk read (#${step}/3)"
hdparm -t "$device"
done
for step in {1..3}; do
say "> Cache read (#${step}/3)"
hdparm -T "$device"
done
fi
if step "### Test 2/8 (Test RAM with dd) ###"; then
! is_pkg_installed time && installpkg time
say "> Read 2x total RAM"
$time dd if=/dev/zero bs=512 count=$totalRAM512bsx2 2>/tmp/out | \
(pv -F "%N %b %t %r %p %e" -s "${totalRAMx2K}k" >/dev/null) 2>&1
cat /tmp/out
fi
$time dd if=dd.img bs=4096 count=$totalRAM4096bs 2>/tmp/out | \
pv > /dev/null
if step "### Test 3/8 (Test disk with dd) ###"; then
say "> Write and read 2x total RAM"
$time dd if=/dev/zero bs=4096 count=$totalRAM4096bsx2 2>/tmp/out | \
(pv -F "%N %b %t %r %p %e" -s "${totalRAMx2K}k" >dd.img) 2>&1
cat /tmp/out
$time dd if=dd.img bs=4096 count=$totalRAM4096bsx2 2>/tmp/out | \
(pv -F "%N %b %t %r %p %e" -s "${totalRAMx2K}k" >/dev/null) 2>&1
cat /tmp/out
done
say "> Deleting file"
$time rm dd.img 2>/tmp/out
cat /tmp/out
say "### Test 4/8 (Bench CPU with cryptsetup) ###"
! is_pkg_installed cryptsetup && CRYPTSETUP=true
installpkg cryptsetup
say "> Cryptsetup benchmark"
/sbin/cryptsetup benchmark
say "### Test 5/8 (Bench disk I/O with pg_test_fsync) ###"
say "> pg_test_fsync test"
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
install -m 755 "${INSTALLER_PATH}/files/usr/local/bin/pg_test_fsync" \
/usr/local/bin/
/usr/local/bin/pg_test_fsync
elif [[ "$arch" == "i686" ]]; then
install -m 755 "${INSTALLER_PATH}/files/usr/local/bin/pg_test_fsync32" \
/usr/local/bin/
/usr/local/bin/pg_test_fsync32
else
critical "Architecture $arch not supported!"
say "> Deleting file"
$time rm dd.img 2>/tmp/out
cat /tmp/out
fi
if step "### Test 4/8 (Bench CPU with cryptsetup) ###"; then
! is_pkg_installed cryptsetup && CRYPTSETUP=true
installpkg cryptsetup
say "> Cryptsetup benchmark"
/sbin/cryptsetup benchmark
fi
if step "### Test 5/8 (Bench disk I/O with pg_test_fsync) ###"; then
say "> pg_test_fsync test"
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
install -m 755 "${INSTALLER_PATH}/files/usr/local/bin/pg_test_fsync" \
/usr/local/bin/
/usr/local/bin/pg_test_fsync
elif [[ "$arch" == "i686" ]]; then
install -m 755 "${INSTALLER_PATH}/files/usr/local/bin/pg_test_fsync32" \
/usr/local/bin/
/usr/local/bin/pg_test_fsync32
else
critical "Architecture $arch not supported!"
fi
fi
if step "### Test 6/8 (Bench disk I/O with bonnie++) ###"; then
say "> bonnie++ tests"
! is_pkg_installed bonnie++ && BONNIE=true
installpkg bonnie++
adduser -q --disabled-password --gecos "bonnie benchmark" bonnie
bonnie -d ./ -s 6144 -r "$totalRAM" -u "bonnie" 2>&1
deluser -q bonnie
fi
if step "### Test 7/8 (Bench CPU with sysbench) ###"; then
! is_pkg_installed sysbench && SYSBENCH=true
installpkg sysbench
say "> sysbench cpu"
sysbench --test=cpu --cpu-max-prime=20000 run
fi
say "### Test 6/8 (Bench disk I/O with bonnie++) ###"
say "> bonnie++ tests"
! is_pkg_installed bonnie++ && BONNIE=true
installpkg bonnie++
adduser -q --disabled-password --gecos "bonnie benchmark" bonnie
bonnie -d ./ -s 6144 -r "$totalRAM" -u "bonnie" 2>&1
deluser -q bonnie
say "### Test 7/8 (Bench CPU with sysbench) ###"
! is_pkg_installed sysbench && SYSBENCH=true
installpkg sysbench
say "> sysbench cpu"
sysbench --test=cpu --cpu-max-prime=20000 run
say "### Test 8/8 (Bench I/O with fio) ###"
! is_pkg_installed fio && FIO=true
installpkg fio
say "> Fio Read bandwidth"
fio --direct=1 --rw=randread --bs=1m --size="$totalRAMx2K" --numjobs=4 --runtime=10 --group_reporting --name=file1
rm -f file1
say "> Fio Read IOPS"
fio --direct=1 --rw=randread --bs=4k --size="$totalRAMx2K" --numjobs=64 --runtime=10 --group_reporting --name=file1
rm -f file1
say "> Fio Write bandwidth"
fio --direct=1 --rw=randwrite --bs=1m --size="$totalRAMx2K" --numjobs=4 --runtime=10 --group_reporting --name=file1
rm -f file1
say "> Fio Write IOPS"
fio --direct=1 --rw=randwrite --bs=4k --size="$totalRAMx2K" --numjobs=64 --runtime=10 --group_reporting --name=file1
if step "### Test 8/8 (Bench I/O with fio) ###"; then
! is_pkg_installed fio && FIO=true
installpkg fio
say "> Fio Read bandwidth"
fio --direct=1 --rw=randread --bs=1m --size="$totalRAMx2K" --numjobs=4 --runtime=10 --group_reporting --name=file1
rm -f file1
say "> Fio Read IOPS"
fio --direct=1 --rw=randread --bs=4k --size="$totalRAMx2K" --numjobs=64 --runtime=10 --group_reporting --name=file1
rm -f file1
say "> Fio Write bandwidth"
fio --direct=1 --rw=randwrite --bs=1m --size="$totalRAMx2K" --numjobs=4 --runtime=10 --group_reporting --name=file1
rm -f file1
say "> Fio Write IOPS"
fio --direct=1 --rw=randwrite --bs=4k --size="$totalRAMx2K" --numjobs=64 --runtime=10 --group_reporting --name=file1
fi
warn "Removing bench directory..."
cd -
@ -164,5 +174,5 @@ if step "Starting benchmarks..."; then
$HDPARM && removepkg hdparm
apt-get -y autoremove
say " ### All tests done! ###"
say "### All tests done! ###"
fi

Loading…
Cancel
Save