Archive for the ‘Generate CPU & Memeory Load & Monitor’ Category


Note

          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 – https://rpmfind.net/linux/rpm2html/search.php?query=stress

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

 

Stress.sh

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

 

Monitor Load using below script

#cat Monitor_load.sh
#!/bin/bash
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

top

uptime
free -m
sar -r
sar 5 5