Blame tests/p_sysstat/15-mpstat-basic.sh
|
root |
2bfd68 |
#!/bin/bash
|
|
root |
2bfd68 |
# Author: Steve Barnes (steve@echo.id.au)
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# A simple mpstat test to verify cpu load is being measured
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
t_Log "Running $0 - a simple mpstat test to verify cpu load is being measured"
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Save our iostat output somewhere
|
|
root |
2bfd68 |
TMP=/tmp/mpstat.scratch
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Clean up after ourselves
|
|
root |
2bfd68 |
trap "[ -e $TMP ] && { /bin/rm -f $TMP; }" EXIT
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Run iostat on the first CPU
|
|
root |
2bfd68 |
/usr/bin/mpstat -P 0 1 5 >$TMP &
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Let the dust settle
|
|
root |
2bfd68 |
sleep 1
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Give the CPU something to chew on
|
|
root |
2bfd68 |
/bin/dd if=/dev/urandom bs=1k count=10000 2>/dev/null|sha1sum -b - &>/dev/null
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Give mpstat a chance to log our task
|
|
root |
2bfd68 |
sleep 3
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Confirm our read bytes are >0, excluding the first
|
|
root |
2bfd68 |
# line since that's the average since boot.
|
|
root |
2bfd68 |
CPU_SYS_PCENT=$(awk '$6 ~ /[0-9]\./ {$6>a ? a=$6 : $6} END {print int(a)}' $TMP)
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
# Check mpstat registered some level of cpu activity
|
|
root |
2bfd68 |
[ "$CPU_SYS_PCENT" -gt 5 ] || { t_Log "mpstat didn't log any CPU activity?!...that ain't good"; exit $FAIL; }
|
|
root |
2bfd68 |
|
|
root |
2bfd68 |
t_CheckExitStatus $?
|