bdid
April 26, 2016, 4:32pm
1
I am working on a Solaris 10 server that is quite locked down. When testing we want to add 15% more load to the CPU. We are unable to add stress or any program to do so. Does anyone have a way to do it where you can add lets say 10, 15, 20 percent load to cpu on top of this psrinfo -v gives me 175 virtual processors. psrinfo -pv gives me 4 physical processors
sparc-m5 32 virtual processors
sparc-m5 48 virtual processors
sparc-m5 48 virtual processors
sparc-m5 48 virtual processors
all clocking 3600MHz.
You can use this ksh/bash function:
# Usage: lc [number_of_virtual_cpus_to_load [number_of_seconds] ]
lc() {
(
pids=""
cpus=${1:-1}
seconds=${2:-60}
echo loading $cpus CPUs for $seconds seconds
trap 'for p in $pids; do kill $p; done' 0
for ((i=0;i<cpus;i++)); do while : ; do : ; done & pids="$pids $!"; done
sleep $seconds
)
}
1 Like
bdid
April 26, 2016, 5:20pm
3
May I ask what the colon is for in front of the numbers? can I do 3600 seconds and 20 virtual cpu? can I save this as lc.sh?
That's the default values (one vCPU for 60 seconds)
Sure, there is no hardcoded limit.
Up to you. I'd rather save it in $HOME/Functions/lc and set FPATH=~/Functions (assuming ksh is used).
bdid
April 26, 2016, 6:02pm
5
I tried this as bash and it did not do anything. This is all I changed.
cpus=${27}
seconds=${60)
There is nothing to change in the shell function I posted.
If you saved the function in lc.sh, run this:
. lc.sh
lc 27 60