diff --git a/bin/measure_temp.sh b/bin/measure_temp.sh index a81bb4f..ea2d07b 100755 --- a/bin/measure_temp.sh +++ b/bin/measure_temp.sh @@ -11,6 +11,27 @@ usage() { EOF } +#format the temperature to float value +format_temp() { + ftemp=${1:0:2} + + ftemp+="." + ftemp+=${1:2:1} + + echo "${ftemp}" +} + +ZONE=/sys/class/thermal/thermal_zone0/temp + +#retrieve the cpu's temperature from /sys/class/thermal/thermal_zone0/temp +measure_temp() { + cpu_temp=$(cat ${ZONE}) + + formatted_temp=$(format_temp "${cpu_temp}") + + echo "${formatted_temp}" + } + if [[ "$1" == "-h" || "$1" == "--help" ]]; then usage exit 0 @@ -19,8 +40,8 @@ fi while true; do NOW=$(date +%s) TS=$((NOW - START)) - TEMP=$(vcgencmd measure_temp | sed 's/[^0-9.]//g') - echo "$TS $TEMP" + TEMP=$(measure_temp) + echo "${TS} ${TEMP}" sleep 1 done diff --git a/bin/run-cpu-stress.sh b/bin/run-cpu-stress.sh index 150ee7d..2726a1f 100755 --- a/bin/run-cpu-stress.sh +++ b/bin/run-cpu-stress.sh @@ -1,7 +1,7 @@ export FIO_NUMJOBS=$(nproc) measure_temp.sh > ${1} & TPID=$! -fio ~/git/pistress/fio/fio_cpu +fio ${PISTRESS_HOME}/fio/fio_cpu kill $TPID > /dev/null unset FIO_NUMJOBS