1835708 Members
3659 Online
110082 Solutions
New Discussion

simulate high CPU

 
SOLVED
Go to solution
kholikt
Super Advisor

simulate high CPU

I want to test out the threshold in my monitoring software, is there any c program that can simulate a high CPU load
abc
9 REPLIES 9
Torsten.
Acclaimed Contributor

Re: simulate high CPU

I'm not sure if this is working for you, but you can try to run the stm exerciser tool on your CPUs to increase the load. Run mstm/xstm, select the CPU and the exercise tool.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Frank de Vries
Respected Contributor

Re: simulate high CPU

Hi
You don't even need a C prog:

You can run a i/o intensive job:
For instance switch on auditing:

man audsys
start or halt the auditing system and set or display audit
file information

SYNOPSIS
audsys [-nf] [-c file -s cafs] [-x file -z xafs]

or

This script will knock em out !

shell script
#!/bin/sh
$0 &
VAR={ps -ef | grep sh| wc -l)
if [ ${VAR} -eq 100 ]
then
exit 1
else
exec $0
fi

Try first with 100 shells , then slowly
increase.

similare in c.script,
you need to prog the 'if routine' though
main()
{ while(1)
{ fork();
}
}


Keep cooking;

Look before you leap
RAC_1
Honored Contributor

Re: simulate high CPU

few find commands will do the trick.

Depending upon how many cpus you have run about 20-30 find commands.

find / -name "xynzznn" -exec ll -d {} \;
There is no substitute to HARDWORK
Frank de Vries
Respected Contributor

Re: simulate high CPU

Hi
You don't even need a C prog:

You can run a i/o intensive job:
For instance switch on auditing:

man audsys
start or halt the auditing system and set or display audit
file information

SYNOPSIS
audsys [-nf] [-c file -s cafs] [-x file -z xafs]

or

This script will knock em out !

shell script
[root@devor:]/root<>>> more knock_em.sh
#!/bin/sh
# shell script to knock em dead
echo $$
VAR=$(ps -ef | grep knock | grep -v grep| wc -l)
if [ ${VAR} -eq 30 ]
then
exit 1
else
print -u1 -- "Running sh number $VAR"
read
$0 &
#exec $0
exit 0
fi

Try first with 30 shells , then slowly
increase depending on your cpu strenght and number.

To stop the script,
Close your telnet session and in an other
session run this:
ps -ef | grep knock | grep -v grep | awk {' print $2 '} | xargs kill -9

The effect is astonishing:
It is idle 5 seconds after starting the script !!!
[root@devor:]/root<>>> sar -u 5 55

HP-UX devor B.10.20 A 9000/861 05/24/06

09:27:57 %usr %sys %wio %idle
09:28:02 30 45 25 0
09:28:07 31 45 24 0
09:28:12 27 51 22 0
09:28:17 29 47 24 0
[root@devor:]/root<>>>

If you insist on a c prog then
this would be the basic idea:
you will need to prog the 'if routine' and
'get out routine' though

main()
{ while(1)
{ fork();
}
}

Keep cooking;

Look before you leap
Frank de Vries
Respected Contributor

Re: simulate high CPU

Sorry I did not say why I posted it again,
hope it was clear that my first posting included typo's.
(A case of serious morning blues)
After my cup of coffee
I tested it for you, hence my second posting.

Enjoy:)))
Look before you leap
Ninad_1
Honored Contributor

Re: simulate high CPU

Hi,

I remember a post in which one of our experts had suggested the very simple method

while true
do
:
done

This will load a whole CPU, you can run more of these if you want to increase the load more and more.

Regards,
Ninad
Arunvijai_4
Honored Contributor
Solution

Re: simulate high CPU

Hi,

Here it is,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=967140

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
kholikt
Super Advisor

Re: simulate high CPU

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=899730

This thread under my question. Those tool from the lab is the stuff that I am looking for.
abc
kholikt
Super Advisor

Re: simulate high CPU

closed thread read above
abc