Skip to content

Instantly share code, notes, and snippets.

@keithchambers
Last active August 29, 2015 14:05
Show Gist options
  • Save keithchambers/bbb9f9b3587a93e845d1 to your computer and use it in GitHub Desktop.
Save keithchambers/bbb9f9b3587a93e845d1 to your computer and use it in GitHub Desktop.
Generate system load.
#!/bin/bash -e
TIMEOUT=${1:-120}
CPU_UNITS=$(cat /proc/cpuinfo | grep processor | wc -l)
until [[ ${COUNT} -eq ${CPU_UNITS} ]]
do
timeout ${TIMEOUT} dd if=/dev/zero bs=10 | gzip | gzip -d > /dev/null &
COUNT=$((COUNT+1))
done
until [[ ${SECONDS} -eq ${TIMEOUT} ]]
do
LOAD=$(uptime | sed 's/,//g' | awk '{ print $(NF-2)}')
echo "1m load average: ${LOAD}"
sleep 1
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment