How to Generate or Simulate High CPU & Memory Load & Monitor the Load in Linux Server

Posted: June 10, 2018 in Generate CPU & Memeory Load & Monitor, Performance Tune


          below testing Server load commands and script only for testing not recommended for Live production server & dont executed in Physical server Hardware may fail try in VMware and Cloud servers.


Download rpm –

Install stress rpm – rpm -ivh stress-xxx-.rpm

MEM=$(free -m | grep ‘Mem:’ | awk ‘{print $7}’)
fmem=$(echo “$MEM*0.95” | bc)
fmem=$( printf “%.0f” $fmem )
CPU=$(grep -c ^processor /proc/cpuinfo)
stress –cpu $FCPU -m 1 –vm-bytes $fmem$m –timeout 300


Monitor Load using below script

MEMORY=$(free -m | awk ‘NR==2{printf “%.2f%%\t\t\n”, $3*100/$2 }’)
CPU=$(top -d 0.5 -b -n2 | grep “Cpu(s)”|tail -n 1 | awk ‘{print $2 + $4+ $6}’)
echo “Memory Usage = ${MEMORY}”
echo “CPU Usage = ${CPU}”


useful commands during High Server Load testing


free -m
sar -r
sar 5 5

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.