You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.3 KiB

#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "run stress test to measure heat and voltage"
echo "blitz.stresstest.sh [?filenameForReport]"
exit 1
fi
# Based on https://github.com/bamarni/pi64/issues/4#issuecomment-292707581
# sysbench manual: http://imysql.com/wp-content/uploads/2014/10/sysbench-manual.pdf
# get parameter
filenameForReport=$1
# check if bechmarking tool is installed
sysbenchInstalled=$(sysbench --version 2>/dev/null | grep -c 'sysbench 0.')
if [ ${sysbenchInstalled} -eq 0 ];then
sudo apt install -y sysbench
fi
# do debug outputs to the STDERR - so that the STDOUT is just the results in the end
6 years ago
echo "RaspiBlitz Hardwaretest v0.1" >&2
echo "Starting sysbench to run for 60 seconds (--max-time=60 --cpu-max-prime=10000)" >&2
6 years ago
# result values
powerWARN=0
powerFAIL=0
powerMIN=9999999
6 years ago
tempWARN=0
tempFAIL=0
tempMAX=0
# starting bench mark
6 years ago
sysbench --max-time=60 --test=cpu --cpu-max-prime=10000 --num-threads=4 run 1>/dev/null 2>&1 &
# keep monitoring in the background
Maxfreq=$(( $(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) -15 ))
6 years ago
for (( n=0; n<15; ++n )); do
6 years ago
# make measurements
Temp=$(sudo vcgencmd measure_temp | cut -f2 -d=)
RealClockspeed=$(sudo vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
SysFSClockspeed=$(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
CoreVoltage=$(sudo vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
6 years ago
# debug output
if [ ${RealClockspeed} -ge ${Maxfreq} ]; then
echo "${Temp}$(printf "%5s" ${SysFSClockspeed}) MHz ${CoreVoltage}" >&2
else
echo "${Temp}$(printf "%5s" ${RealClockspeed})/$(printf "%4s" ${SysFSClockspeed}) MHz ${CoreVoltage}" >&2
fi
6 years ago
6 years ago
# analyse Voltage
6 years ago
voltFloat=$(echo "${CoreVoltage/V/}*1000000" | bc)
6 years ago
voltInt=${voltFloat/.*}
6 years ago
#echo "V -> ${voltFloat}/${voltInt}"
if [ ${voltInt} -lt 1200100 ] && [ ${powerWARN} -gt 1 ]; then
6 years ago
((powerFAIL=powerFAIL+1))
6 years ago
echo "--> Power FAIL detected" >&2
6 years ago
fi
if [ ${voltInt} -lt 1250000 ]; then
6 years ago
((powerWARN=powerWARN+1))
6 years ago
echo "--> Power WARN detected" >&2
6 years ago
fi
if [ ${voltInt} -lt ${powerMIN} ]; then
powerMIN=${voltInt}
6 years ago
fi
# analyse Temp
6 years ago
tempFloat=$(echo "${Temp/\'C/}*100" | bc)
tempInt=${tempFloat/.*}
6 years ago
#echo "T -> ${tempFloat}/${tempInt}"
if [ ${tempInt} -gt 6999 ]; then
6 years ago
((tempFAIL=tempFAIL+1))
6 years ago
echo "--> Temp FAIL detected" >&2
6 years ago
fi
if [ ${tempInt} -gt 6500 ]; then
6 years ago
((tempWARN=tempWARN+1))
6 years ago
echo "--> Temp WARN detected" >&2
6 years ago
fi
if [ ${tempInt} -gt ${tempMAX} ]; then
tempMAX=${tempInt}
6 years ago
fi
6 years ago
sleep 5
6 years ago
done
if [ ${#filenameForReport} -eq 0 ]; then
echo "powerFAIL=${powerFAIL}"
echo "powerWARN=${powerWARN}"
echo "powerMIN='${powerMIN} microVolt'"
echo "tempFAIL=${tempFAIL}"
echo "tempWARN=${tempWARN}"
echo "tempMAX='${tempMAX} centiGrad'"
else
echo "powerFAIL=${powerFAIL}" >${filenameForReport}
echo "powerWARN=${powerWARN}" >>${filenameForReport}
echo "powerMIN='${powerMIN} microVolt'" >>${filenameForReport}
echo "tempFAIL=${tempFAIL}" >>${filenameForReport}
echo "tempWARN=${tempWARN}" >>${filenameForReport}
echo "tempMAX='${tempMAX} centiGrad'" >>${filenameForReport}
sudo chmod 744 ${filenameForReport}
fi