forked from longtao.wu/droboticflow
27 lines
1.2 KiB
Bash
27 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
bash /scripts/guard.sh
|
|
cd /lab/data
|
|
group="/hostcg/kubepods.slice/kubepods-pod${POD_UID//-/_}.slice"
|
|
cat "$group/io.stat"
|
|
trap 'cat "$group/io.stat"' EXIT
|
|
probe() {
|
|
local name=$1 minimum=$2 start end
|
|
shift 2
|
|
start=$(date +%s%N)
|
|
"$@"
|
|
end=$(date +%s%N)
|
|
awk -v name="$name" -v start="$start" -v end="$end" -v minimum="$minimum" 'BEGIN {s=(end-start)/1e9; printf "IO_PROBE %s seconds=%.3f minimum=%s\n",name,s,minimum; if(s<minimum)exit 1}'
|
|
}
|
|
probe direct_write 3 dd if=/dev/zero of=io-direct bs=1048576 count=4 oflag=direct conv=fdatasync
|
|
probe buffered_write 3 dd if=/dev/zero of=io-buffered bs=1048576 count=4 conv=fdatasync
|
|
# Evict only the synthetic backing file's clean pages; never drop global caches.
|
|
dd if=/lab/disk.img of=/dev/null count=0 iflag=nocache status=none
|
|
probe direct_read 1 dd if=io-direct of=/dev/null bs=1048576 count=4 iflag=direct
|
|
probe write_iops 5 dd if=/dev/zero of=io-iops bs=4096 count=256 oflag=direct conv=fdatasync
|
|
dd if=/lab/disk.img of=/dev/null count=0 iflag=nocache status=none
|
|
probe read_iops 2 dd if=io-iops of=/dev/null bs=4096 count=256 iflag=direct
|
|
cat "$group/io.stat"
|
|
rm -- io-direct io-buffered io-iops
|
|
printf 'IO_PROBES_OK pod=%s\n' "$POD_UID"
|