From 088e1c4944902015e0b4a8952b29230f93b161f8 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Jul 03 2023 23:27:32 +0000 Subject: sysstat: fix iostat-cpu-basic test order Signed-off-by: Carlos Rodriguez-Fernandez --- diff --git a/tests/p_sysstat/05-iostat-cpu-basic.sh b/tests/p_sysstat/05-iostat-cpu-basic.sh new file mode 100755 index 0000000..c085fb8 --- /dev/null +++ b/tests/p_sysstat/05-iostat-cpu-basic.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Author: Steve Barnes (steve@echo.id.au) + +# A simple iostat test to verify cpu loads are being recorded + +t_Log "Running $0 - a basic iostat test to verify cpu measurement" + +# Save our iostat output somewhere +TMP=/tmp/iostat.cpu.scratch + +# Clear out the pagecache to get an accurate reading +echo 1 > /proc/sys/vm/drop_caches + +# Clean up after ourselves +trap "[ -e $TMP ] && { /bin/rm -f $TMP; }" EXIT + +# Capture a storage device name +DRIVE=$(fdisk -l|grep -Po -m1 '^/dev/[\D]+') + +# Run iostat on the cpu +/usr/bin/iostat -c 1 5 >$TMP & + +# Let the dust settle +sleep 4 + +# Give the CPU something to chew on +/bin/dd if=$DRIVE bs=4k count=25000 2>/dev/null|sha1sum -b - &>/dev/null + +# Give iostat a chance to log our task +sleep 6 + +# Extract the CPU utilisation (user field, percentage) +CPU_USER_PCENT=$(awk '$1 ~ /[0-9]/ {$1>a ? a=$1 : $1} END {print int(a)}' $TMP) + +# Confirm the CPU registered some level of user activity +[ "$CPU_USER_PCENT" -gt 3 ] || { t_Log "iostat didn't log any CPU activity?!...that ain't good"; } + +t_CheckExitStatus $? diff --git a/tests/p_sysstat/5-iostat-cpu-basic.sh b/tests/p_sysstat/5-iostat-cpu-basic.sh deleted file mode 100755 index c085fb8..0000000 --- a/tests/p_sysstat/5-iostat-cpu-basic.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Author: Steve Barnes (steve@echo.id.au) - -# A simple iostat test to verify cpu loads are being recorded - -t_Log "Running $0 - a basic iostat test to verify cpu measurement" - -# Save our iostat output somewhere -TMP=/tmp/iostat.cpu.scratch - -# Clear out the pagecache to get an accurate reading -echo 1 > /proc/sys/vm/drop_caches - -# Clean up after ourselves -trap "[ -e $TMP ] && { /bin/rm -f $TMP; }" EXIT - -# Capture a storage device name -DRIVE=$(fdisk -l|grep -Po -m1 '^/dev/[\D]+') - -# Run iostat on the cpu -/usr/bin/iostat -c 1 5 >$TMP & - -# Let the dust settle -sleep 4 - -# Give the CPU something to chew on -/bin/dd if=$DRIVE bs=4k count=25000 2>/dev/null|sha1sum -b - &>/dev/null - -# Give iostat a chance to log our task -sleep 6 - -# Extract the CPU utilisation (user field, percentage) -CPU_USER_PCENT=$(awk '$1 ~ /[0-9]/ {$1>a ? a=$1 : $1} END {print int(a)}' $TMP) - -# Confirm the CPU registered some level of user activity -[ "$CPU_USER_PCENT" -gt 3 ] || { t_Log "iostat didn't log any CPU activity?!...that ain't good"; } - -t_CheckExitStatus $?