-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_test.sh
More file actions
executable file
·44 lines (36 loc) · 783 Bytes
/
load_test.sh
File metadata and controls
executable file
·44 lines (36 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# This script creates an artificial load
# By, John Radford July 2020
# github https://bluesquare23.sh
# Usage: load_test.sh [number of cores]
killall dd >/dev/null 2>&1
ncores=`lscpu|\
grep "CPU(s):"|\
grep -v NUMA|\
awk '{print $2}'`
full_load(){
i=1
while [[ $i -le $ncores ]]
do
dd if=/dev/zero of=/dev/null &
((i++))
done
}
partial_load(){
i=1
! [[ "$1" =~ ^[0-9]+$ ]] && \
>&2 echo "Integers only!" && \
return 1
[[ $1 -gt $ncores ]] && \
>&2 echo "Value larger than core count!" && \
return 1
while [[ $i -le $1 ]]
do
dd if=/dev/zero of=/dev/null &
((i++))
done
}
[ -z $1 ] && \
full_load || \
partial_load $1 && \
echo "Run, \`killall dd\` to stop the stress test."