[linux thermal] 一个简单的获取温度和频率的脚本

此脚本可以获取手机soc温度变化趋势,以及各个cooling devices的频率变化。使用此脚本的前提:安卓手机可以adb root进去。

rm ./thermal_simple.log #remove the old log file

#Temp
time0=TIME
name0=$(cat /sys/class/thermal/thermal_zone0/type) #soc thermal zone

#CPU Freq
name1=cpu0_cur_freq
name2=cpu0_max_freq

name3=cpu4_cur_freq
name4=cpu4_max_freq

#write name string at the first line in thermal_simple.log
echo $time0 $name0 $name1 $name2 $name3 $name4 >> ./thermal_simple.log

#per 100ms
while [ true ]
do
	# time1=$(date "+%T")
	currentTimeStamp=$(date +"%T.%3N") #time stamp, precise to miliseconds

	value0=$(cat /sys/class/thermal/thermal_zone0/temp)
	
	value1=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
	value2=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)

	value3=$(cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq)
	value4=$(cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq)

	echo $currentTimeStamp $value0 $value1 $value2 $value9 $value3 $value4 >> ./thermal_simple.log
	#sleep 0.1
done

执行后,按Ctrl+C结束
执行后在当前路径下生成thermal_simple.log文件,文件内容(如下为示例,具体内容以实际情况为准):
TIME soc-thmzone cpu0_cur_freq cpu0_max_freq cpu4_cur_freq cpu4_max_freq
03:44:25.704 35248 768000 1200000 1600000 1600000
03:44:25.997 35248 768000 1200000 1600000 1600000
03:44:26.313 35248 768000 1200000 1600000 1600000
03:44:26.604 35248 768000 1200000 1600000 1600000
03:44:26.895 36161 768000 1200000 1600000 1600000
03:44:27.184 36161 768000 1200000 1600000 1600000
03:44:27.478 36161 768000 1200000 1600000 1600000
03:44:27.766 36161 768000 1200000 1600000 1600000
03:44:28.095 36161 768000 1200000 1600000 1600000
03:44:28.383 36161 768000 1200000 1600000 1600000
03:44:28.674 36161 768000 1200000 1600000 1600000
03:44:28.969 36161 768000 1200000 1600000 1600000
03:44:29.261 36161 768000 1200000 1600000 1600000
03:44:29.549 36161 768000 1200000 1600000 1600000
03:44:29.843 36161 768000 1200000 1600000 1600000

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值