Skip to content

Instantly share code, notes, and snippets.

@blzzua
Created September 28, 2022 13:20
Show Gist options
  • Save blzzua/dbffa9e444bdfcf284f8a7f481ba0275 to your computer and use it in GitHub Desktop.
Save blzzua/dbffa9e444bdfcf284f8a7f481ba0275 to your computer and use it in GitHub Desktop.
Generates a cpu load average and maintains it in the form of a sinusoid, with a period in time.
MAXJOBS=20
for i in `seq 1 $MAXJOBS` ; do nice -n 19 gzip -c /dev/zero > /dev/null & done
while true
do
LA=`</proc/loadavg` && LA=${LA// */}
H=$(date +%M) && H=${H/0/}
G=`echo "(${MAXJOBS}/2)*(s(2*3.14159*${H}/60) +1 ) <= ${LA}" | bc -l`
test ${G} -lt 1 && for i in `seq 1 $MAXJOBS` ; do kill -SIGCONT %$i ; done || for i in `seq 1 $MAXJOBS` ; do kill -SIGSTOP %$i; done
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment