Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to create a heavy CPU load?

Status
Not open for further replies.

noober

IS-IT--Management
Oct 10, 2003
112
US
Hello. I want to do some CPU stress testing on my RS6000 (running Aix 5.2) and I was wondering if anyone had a simple script that I might be able to use to do so? I want to create a very heavy CPU load just for background noise during application testing.

Anyone?
 
It sounds like you're wanting to find out how your application behaves when it can't get much of the CPU.

If so, you could simply define a class for your application in wlm and restrict the amount of CPU it can use. Be sure to set hardcpumax to "yes".

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Got from IBM DLPAR Tool Set for pSeries:

#!/bin/ksh
# PURPOSE: To produce a CPU-load of up to 100% for all CPUs in the OS instance
# for an input # of seconds.
# SYNTAX: cpuStress.ksh <seconds>
# e.g. cpuStress.ksh 120
# SAMPLE USAGE: onHostsBg "cpuStress.ksh 120"
# COMPONENT OF: IBM pSeries DLPAR Toolset 2.0.1.0, February 2004.
# COPYRIGHT: IBM Corporation, 2002,2003,2004. All rights reserved.

if [[ $# -ne 1 ]] ;
then
echo "SYNTAX: $0 <seconds>"
exit
fi

dir=`dirname $0`
cpus=`lsdev -Cc processor -S a | wc -l`
sec=$1;

while [[ $i -le $cpus ]]
do
$dir/loopFor $sec &
(( i = $i + 1 ))
done




And you need compile this:

/* PURPOSE: To use up a CPU via looping for an input number of seconds.
* SYNTAX: loopFor <seconds>
* COMPONENT OF: IBM pSeries DLPAR Toolset 2.0.1.0, February 2004.
* COPYRIGHT: IBM Corporation, 2002,2003,2004. All rights reserved.
*/
#include <stdio.h>
#include <time.h>
int main (argc, argv)
int argc ; /* # arguments */
char *argv[]; /* Argument list */
{
int x = 4;
int y, i, sec1, sec2, sec;
time_t t1, t2;
struct tm *timep1, *timep2;
sec = (int) atoi(argv[1]);

if (argc != 2 )
{
printf("SYNTAX: loopFor <seconds>\n");
return(-1);
}

t1= time(NULL);
timep1 = localtime(&t1);
sec1 = timep1->tm_hour * 3600 + timep1->tm_min * 60 + timep1->tm_sec;

for (;;)
{ y = x * x ;
y = y/x ;
t2 = time(NULL);
timep2 = localtime(&t2);
sec2 = timep2->tm_hour * 3600 + timep2->tm_min * 60 + timep2->tm_sec;
if ( (sec2 - sec1) >= sec )
{
return 0;
}
}
}


If you need compiled version get it from dlparToolset2010.tar.gz which you can download from:



r, m.
 
forgot about additional script:

#!/bin/ksh
# PURPOSE: To execute a command (with arguments) on a hard-coded list of hosts
# SYNTAX: onHostsBg "<command-and-its-arguments>"
# If the above command is in a directory that is not in your PATH,
# the please enter the full pathname for the command.
# For simple commands without arguments (or with simple arguments),
# one does note have to enclose the command in double quotes.
# E.g. onHostsBg "shutdown -rF"
# COMPONENT OF: IBM pSeries DLPAR Toolset 2.0.1.0, February 2004.
# COPYRIGHT: IBM Corporation, 2002,2003,2004. All rights reserved.
# AUTHOR: Joefon Jann 1993/5

for i in dr02 lpar05 lpar06 lpar07
do
echo "on $i ------------------:"
rsh $i PATH=$PATH $* &
echo ' '
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top