Skip to content

Instantly share code, notes, and snippets.

@agustik
Created January 31, 2017 21:45
Show Gist options
  • Save agustik/0cbb2c95db48a3bf69e24484a6b3b606 to your computer and use it in GitHub Desktop.
Save agustik/0cbb2c95db48a3bf69e24484a6b3b606 to your computer and use it in GitHub Desktop.
Stress test hardware
#!/bin/bash
# Sækja stress
#
# yum localinstall ftp://fr2.rpmfind.net/linux/dag/redhat/el7/en/x86_64/dag/RPMS/stress-1.0.2-1.el7.rf.x86_64.rpm
#
# eða
# wget ftp://fr2.rpmfind.net/linux/dag/redhat/el7/en/x86_64/dag/RPMS/stress-1.0.2-1.el7.rf.x86_64.rpm
# yum localinstall stress-1.0.2-1.el7.rf.x86_64.rpm
#
# sækja bc
# yum install bc -y
memoryPercentage="0.9"
#Fá CPU count.
cpuCount=$(cat /proc/cpuinfo | grep MHz | wc -l)
# Fá allt memory úr proc/meminfo
totalMem=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}');
#man ekki alveg afhverju ég valdi 40 ...
memWorkers=40
# to bytes
# Sækja allt minni í vélinni
totalMem=$(echo "$totalMem * 1024" | bc );
# Sækja allt minni í vélinni sem á að testa
mostMemory=$( echo "$totalMem * $memoryPercentage" | bc -l );
# Fá allt minni sem þarf að testa í tölu..
memToTest=$(echo $mostMemory | cut -d . -f1 );
# Skipta minninu niður á workera
memPerWorker=$(echo $memToTest / $memWorkers | bc );
totalMemHuman=$(echo "$totalMem / 1024 / 1024 / 1024 " | bc )
memToTestHuman=$(echo "$memToTest / 1024 / 1024 / 1024 " | bc )
memPerWorkerHuman=$(echo "$memPerWorker / 1024 / 1024 " | bc)
echo "
Total memory: $totalMemHuman GB
Cpu Count: $cpuCount
Memory to test: $memToTestHuman GB
Workers: $memWorkers
Memory per worker: $memPerWorkerHuman MB"
# Keyra þetta í gang..
stress -c $cpuCount -t 86000 -m $memWorkers --vm-bytes $memPerWorker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment